code: def test_canonicalize_name_invalid():
      with pytest.raises(InvalidName):
          canonicalize_name("_not_legal", validate=True)
      assert canonicalize_name("_not_legal") == "-not-legal"
  
file_path: py-packaging/tests/test_utils.py
imports: import pytest
  from packaging.tags import Tag
  from packaging.utils import InvalidName, InvalidSdistFilename, InvalidWheelFilename, canonicalize_name, canonicalize_version, is_normalized_name, parse_sdist_filename, parse_wheel_filename
  from packaging.version import Version
label_desc: Use image node_id 2 for calling a global function with example usage: test_canonicalize_name_invalid() without return types