@@ -551,8 +551,6 @@ def testZipImporterMethods(self):
551551 "spam" + pyc_ext : test_pyc }
552552 self .makeZip (files , file_comment = b"spam" )
553553
554- sys .path .insert (0 , TEMP_ZIP )
555-
556554 zi = zipimport .zipimporter (TEMP_ZIP )
557555 self .assertEqual (zi .archive , TEMP_ZIP )
558556 self .assertTrue (zi .is_package (TESTPACK ))
@@ -571,6 +569,8 @@ def testZipImporterMethods(self):
571569 spec .loader .exec_module (mod )
572570 self .assertEqual (zi .get_filename (TESTPACK ), mod .__file__ )
573571
572+ sys .path .insert (0 , TEMP_ZIP )
573+
574574 existing_pack_path = importlib .import_module (TESTPACK ).__path__ [0 ]
575575 expected_path_path = os .path .join (TEMP_ZIP , TESTPACK )
576576 self .assertEqual (existing_pack_path , expected_path_path )
@@ -665,8 +665,6 @@ def testZipImporterMethodsInSubDirectory(self):
665665 packdir2 + TESTMOD + pyc_ext : test_pyc }
666666 self .makeZip (files , file_comment = b"eggs" )
667667
668- sys .path .insert (0 , TEMP_ZIP + os .sep + TESTPACK )
669-
670668 zi = zipimport .zipimporter (TEMP_ZIP + os .sep + packdir )
671669 self .assertEqual (zi .archive , TEMP_ZIP )
672670 self .assertEqual (zi .prefix , packdir )
@@ -693,9 +691,12 @@ def testZipImporterMethodsInSubDirectory(self):
693691 self .assertEqual (
694692 spec .loader .get_filename (TESTMOD ), load_mod .__file__ )
695693
694+ sys .path .insert (0 , TEMP_ZIP + os .sep + TESTPACK )
695+
696696 mod_path = TESTPACK2 + os .sep + TESTMOD
697697 mod_name = module_path_to_dotted_name (mod_path )
698698 mod = importlib .import_module (mod_name )
699+
699700 self .assertTrue (mod_name in sys .modules )
700701 self .assertIsNone (zi .get_source (TESTPACK2 ))
701702 self .assertIsNone (zi .get_source (mod_path ))
0 commit comments