cpython: ca5431a434d6 (original) (raw)
--- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -456,8 +456,7 @@ class ZipFileModifiedAfterImportTestCase # Now that the zipfile has been replaced, import something else from it # which should fail as the file contents are now garbage. with self.assertRaises(ImportError):
ziptest_a = __import__("ziptest_a", globals(), locals(),[](#l1.7)
["test_value"])[](#l1.8)
ziptest_a = __import__("ziptest_a", {}, {}, ["test_value"])[](#l1.9) # The code path used by the __import__ call is different than[](#l1.10) # that used by import statements. Try these as well. Some of[](#l1.11) # these may create new zipimporter instances. We need to[](#l1.12)
@@ -486,9 +485,9 @@ class ZipFileModifiedAfterImportTestCase exec("from {} import {}".format(TESTPACK, TESTMOD), test_ns) self.assertEqual(test_ns[TESTMOD].test_value, 38)
ziptest_a = __import__("ziptest_a", globals(), locals(), ["test_value"])[](#l1.17)
ziptest_a = __import__("ziptest_a", {}, {}, ["test_value"])[](#l1.18) self.assertEqual(ziptest_a.test_value, 23)[](#l1.19)
ziptest_c = __import__("ziptest_c", globals(), locals(), ["test_value"])[](#l1.20)
ziptest_c = __import__("ziptest_c", {}, {}, ["test_value"])[](#l1.21) self.assertEqual(ziptest_c.test_value, 1337)[](#l1.22)
def testZipFileSubpackageImport(self): @@ -497,7 +496,7 @@ class ZipFileModifiedAfterImportTestCase # Put a subdirectory within the zip file into the import path. sys.path.insert(0, self.zipfile_path + os.sep + TESTPACK)
testmod = __import__(TESTMOD, globals(), locals(), ["test_value"])[](#l1.29)
testmod = __import__(TESTMOD, {}, {}, ["test_value"])[](#l1.30) self.assertEqual(testmod.test_value, 38)[](#l1.31) del sys.modules[TESTMOD][](#l1.32) test_ns = {}[](#l1.33)
@@ -507,7 +506,7 @@ class ZipFileModifiedAfterImportTestCase # Confirm that imports from the top level of the zip file # (already in sys.path from the setup call above) still work.
ziptest_a = __import__("ziptest_a", globals(), locals(), ["test_value"])[](#l1.38)
ziptest_a = __import__("ziptest_a", {}, {}, ["test_value"])[](#l1.39) self.assertEqual(ziptest_a.test_value, 23)[](#l1.40) del sys.modules["ziptest_a"][](#l1.41) import ziptest_c[](#l1.42)
@@ -517,7 +516,7 @@ class ZipFileModifiedAfterImportTestCase self.truncateAndFillZipWithNonZipGarbage() # Imports should now fail. with self.assertRaises(ImportError):
testmod = __import__(TESTMOD, globals(), locals(), ["test_value"])[](#l1.47)
testmod = __import__(TESTMOD, {}, {}, ["test_value"])[](#l1.48) with self.assertRaises(ImportError):[](#l1.49) exec("from {} import test_value".format(TESTMOD), {})[](#l1.50) with self.assertRaises(ImportError):[](#l1.51)
@@ -525,14 +524,14 @@ class ZipFileModifiedAfterImportTestCase self.restoreZipFileWithDifferentHeaderOffsets() # Imports should work again, the central directory TOC will be re-read.
testmod = __import__(TESTMOD, globals(), locals(), ["test_value"])[](#l1.56)
testmod = __import__(TESTMOD, {}, {}, ["test_value"])[](#l1.57) self.assertEqual(testmod.test_value, 38)[](#l1.58) del sys.modules[TESTMOD][](#l1.59) test_ns = {}[](#l1.60) exec("from {} import test_value".format(TESTMOD), test_ns)[](#l1.61) self.assertEqual(test_ns['test_value'], 38)[](#l1.62)
ziptest_a = __import__("ziptest_a", globals(), locals(), ["test_value"])[](#l1.64)
ziptest_a = __import__("ziptest_a", {}, {}, ["test_value"])[](#l1.65) self.assertEqual(ziptest_a.test_value, 23)[](#l1.66) import ziptest_c[](#l1.67) self.assertEqual(ziptest_c.test_value, 1337)[](#l1.68)