code: def test_package_import__semantics(self):
      # Generate a couple of broken modules to try importing.
  
      # ...try loading the module when there's a SyntaxError
      self.rewrite_file("for")
      try:
          __import__(self.module_name)
      except SyntaxError:
          pass
      else:
          raise RuntimeError(
              "Failed to induce SyntaxError"
          )  # self.fail()?
      self.assertNotIn(self.module_name, sys.modules)
      self.assertFalse(hasattr(sys.modules[self.package_name], "foo"))
  
      # ...make up a variable name that isn't bound in __builtins__
      var = "a"
      while var in dir(__builtins__):
          var += random.choice(string.ascii_letters)
  
      # ...make a module that just contains that
      self.rewrite_file(var)
  
      try:
          __import__(self.module_name)
      except NameError:
          pass
      else:
          raise RuntimeError("Failed to induce NameError.")
  
      # ...now  change  the module  so  that  the NameError  doesn't
      # happen
      self.rewrite_file("%s = 1" % var)
      module = __import__(self.module_name).foo
      self.assertEqual(getattr(module, var), 1)
  
file_path: cpython/Lib/test/test_importlib/test_pkg_import.py
imports: import os
  import sys
  import shutil
  import string
  import random
  import tempfile
  import unittest
  from importlib.util import cache_from_source
  from test.support.os_helper import create_empty_file
label_desc: Use image node_id 6 for calling the TestImport obj's underlying member method code with example usage: obj.test_package_import__semantics() without return types