Issue #8585: improved tests for zipimporter2. Patch from Mark Lawrence.
This commit is contained in:
parent
0811c5d7ba
commit
9e1bf4968f
|
@ -214,7 +214,8 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
|
||||||
packdir2 = packdir + TESTPACK2 + os.sep
|
packdir2 = packdir + TESTPACK2 + os.sep
|
||||||
files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc),
|
files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc),
|
||||||
packdir2 + "__init__" + pyc_ext: (NOW, test_pyc),
|
packdir2 + "__init__" + pyc_ext: (NOW, test_pyc),
|
||||||
packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)}
|
packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc),
|
||||||
|
"spam" + pyc_ext: (NOW, test_pyc)}
|
||||||
|
|
||||||
z = ZipFile(TEMP_ZIP, "w")
|
z = ZipFile(TEMP_ZIP, "w")
|
||||||
try:
|
try:
|
||||||
|
@ -228,6 +229,14 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
|
||||||
zi = zipimport.zipimporter(TEMP_ZIP)
|
zi = zipimport.zipimporter(TEMP_ZIP)
|
||||||
self.assertEqual(zi.archive, TEMP_ZIP)
|
self.assertEqual(zi.archive, TEMP_ZIP)
|
||||||
self.assertEqual(zi.is_package(TESTPACK), True)
|
self.assertEqual(zi.is_package(TESTPACK), True)
|
||||||
|
|
||||||
|
find_mod = zi.find_module('spam')
|
||||||
|
self.assertIsNotNone(find_mod)
|
||||||
|
self.assertIsInstance(find_mod, zipimport.zipimporter)
|
||||||
|
self.assertFalse(find_mod.is_package('spam'))
|
||||||
|
load_mod = find_mod.load_module('spam')
|
||||||
|
self.assertEqual(find_mod.get_filename('spam'), load_mod.__file__)
|
||||||
|
|
||||||
mod = zi.load_module(TESTPACK)
|
mod = zi.load_module(TESTPACK)
|
||||||
self.assertEqual(zi.get_filename(TESTPACK), mod.__file__)
|
self.assertEqual(zi.get_filename(TESTPACK), mod.__file__)
|
||||||
|
|
||||||
|
@ -287,6 +296,16 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
zi.is_package(TESTPACK2 + os.sep + TESTMOD), False)
|
zi.is_package(TESTPACK2 + os.sep + TESTMOD), False)
|
||||||
|
|
||||||
|
pkg_path = TEMP_ZIP + os.sep + packdir + TESTPACK2
|
||||||
|
zi2 = zipimport.zipimporter(pkg_path)
|
||||||
|
find_mod_dotted = zi2.find_module(TESTMOD)
|
||||||
|
self.assertIsNotNone(find_mod_dotted)
|
||||||
|
self.assertIsInstance(find_mod_dotted, zipimport.zipimporter)
|
||||||
|
self.assertFalse(zi2.is_package(TESTMOD))
|
||||||
|
load_mod = find_mod_dotted.load_module(TESTMOD)
|
||||||
|
self.assertEqual(
|
||||||
|
find_mod_dotted.get_filename(TESTMOD), load_mod.__file__)
|
||||||
|
|
||||||
mod_path = TESTPACK2 + os.sep + TESTMOD
|
mod_path = TESTPACK2 + os.sep + TESTMOD
|
||||||
mod_name = module_path_to_dotted_name(mod_path)
|
mod_name = module_path_to_dotted_name(mod_path)
|
||||||
__import__(mod_name)
|
__import__(mod_name)
|
||||||
|
|
|
@ -13,6 +13,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #8585: improved tests for zipimporter2. Patch from Mark Lawrence.
|
||||||
|
|
||||||
- Issue #18622: unittest.mock.mock_open().reset_mock would recurse infinitely.
|
- Issue #18622: unittest.mock.mock_open().reset_mock would recurse infinitely.
|
||||||
Patch from Nicola Palumbo and Laurent De Buyst.
|
Patch from Nicola Palumbo and Laurent De Buyst.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue