99import time
1010import unittest
1111import unittest .mock
12- import warnings
1312
1413from test import support
1514from test .support import import_helper
@@ -556,13 +555,6 @@ def testZipImporterMethods(self):
556555 self .assertEqual (zi .archive , TEMP_ZIP )
557556 self .assertTrue (zi .is_package (TESTPACK ))
558557
559- # PEP 302
560- with warnings .catch_warnings ():
561- warnings .simplefilter ("ignore" , DeprecationWarning )
562-
563- mod = zi .load_module (TESTPACK )
564- self .assertEqual (zi .get_filename (TESTPACK ), mod .__file__ )
565-
566558 # PEP 451
567559 spec = zi .find_spec ('spam' )
568560 self .assertIsNotNone (spec )
@@ -577,6 +569,8 @@ def testZipImporterMethods(self):
577569 spec .loader .exec_module (mod )
578570 self .assertEqual (zi .get_filename (TESTPACK ), mod .__file__ )
579571
572+ sys .path .insert (0 , TEMP_ZIP )
573+
580574 existing_pack_path = importlib .import_module (TESTPACK ).__path__ [0 ]
581575 expected_path_path = os .path .join (TEMP_ZIP , TESTPACK )
582576 self .assertEqual (existing_pack_path , expected_path_path )
@@ -675,11 +669,6 @@ def testZipImporterMethodsInSubDirectory(self):
675669 self .assertEqual (zi .archive , TEMP_ZIP )
676670 self .assertEqual (zi .prefix , packdir )
677671 self .assertTrue (zi .is_package (TESTPACK2 ))
678- # PEP 302
679- with warnings .catch_warnings ():
680- warnings .simplefilter ("ignore" , DeprecationWarning )
681- mod = zi .load_module (TESTPACK2 )
682- self .assertEqual (zi .get_filename (TESTPACK2 ), mod .__file__ )
683672 # PEP 451
684673 spec = zi .find_spec (TESTPACK2 )
685674 mod = importlib .util .module_from_spec (spec )
@@ -702,9 +691,12 @@ def testZipImporterMethodsInSubDirectory(self):
702691 self .assertEqual (
703692 spec .loader .get_filename (TESTMOD ), load_mod .__file__ )
704693
694+ sys .path .insert (0 , TEMP_ZIP + os .sep + TESTPACK )
695+
705696 mod_path = TESTPACK2 + os .sep + TESTMOD
706697 mod_name = module_path_to_dotted_name (mod_path )
707698 mod = importlib .import_module (mod_name )
699+
708700 self .assertTrue (mod_name in sys .modules )
709701 self .assertIsNone (zi .get_source (TESTPACK2 ))
710702 self .assertIsNone (zi .get_source (mod_path ))
@@ -1069,9 +1061,6 @@ def _testBogusZipFile(self):
10691061 z = zipimport .zipimporter (TESTMOD )
10701062
10711063 try :
1072- with warnings .catch_warnings ():
1073- warnings .simplefilter ("ignore" , DeprecationWarning )
1074- self .assertRaises (TypeError , z .load_module , None )
10751064 self .assertRaises (TypeError , z .find_module , None )
10761065 self .assertRaises (TypeError , z .find_spec , None )
10771066 self .assertRaises (TypeError , z .exec_module , None )
@@ -1082,10 +1071,6 @@ def _testBogusZipFile(self):
10821071
10831072 error = zipimport .ZipImportError
10841073 self .assertIsNone (z .find_spec ('abc' ))
1085-
1086- with warnings .catch_warnings ():
1087- warnings .simplefilter ("ignore" , DeprecationWarning )
1088- self .assertRaises (error , z .load_module , 'abc' )
10891074 self .assertRaises (error , z .get_code , 'abc' )
10901075 self .assertRaises (OSError , z .get_data , 'abc' )
10911076 self .assertRaises (error , z .get_source , 'abc' )
0 commit comments