9
9
import time
10
10
import unittest
11
11
import unittest .mock
12
- import warnings
13
12
14
13
from test import support
15
14
from test .support import import_helper
@@ -556,13 +555,6 @@ def testZipImporterMethods(self):
556
555
self .assertEqual (zi .archive , TEMP_ZIP )
557
556
self .assertTrue (zi .is_package (TESTPACK ))
558
557
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
-
566
558
# PEP 451
567
559
spec = zi .find_spec ('spam' )
568
560
self .assertIsNotNone (spec )
@@ -577,6 +569,8 @@ def testZipImporterMethods(self):
577
569
spec .loader .exec_module (mod )
578
570
self .assertEqual (zi .get_filename (TESTPACK ), mod .__file__ )
579
571
572
+ sys .path .insert (0 , TEMP_ZIP )
573
+
580
574
existing_pack_path = importlib .import_module (TESTPACK ).__path__ [0 ]
581
575
expected_path_path = os .path .join (TEMP_ZIP , TESTPACK )
582
576
self .assertEqual (existing_pack_path , expected_path_path )
@@ -675,11 +669,6 @@ def testZipImporterMethodsInSubDirectory(self):
675
669
self .assertEqual (zi .archive , TEMP_ZIP )
676
670
self .assertEqual (zi .prefix , packdir )
677
671
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__ )
683
672
# PEP 451
684
673
spec = zi .find_spec (TESTPACK2 )
685
674
mod = importlib .util .module_from_spec (spec )
@@ -702,9 +691,12 @@ def testZipImporterMethodsInSubDirectory(self):
702
691
self .assertEqual (
703
692
spec .loader .get_filename (TESTMOD ), load_mod .__file__ )
704
693
694
+ sys .path .insert (0 , TEMP_ZIP + os .sep + TESTPACK )
695
+
705
696
mod_path = TESTPACK2 + os .sep + TESTMOD
706
697
mod_name = module_path_to_dotted_name (mod_path )
707
698
mod = importlib .import_module (mod_name )
699
+
708
700
self .assertTrue (mod_name in sys .modules )
709
701
self .assertIsNone (zi .get_source (TESTPACK2 ))
710
702
self .assertIsNone (zi .get_source (mod_path ))
@@ -1069,9 +1061,6 @@ def _testBogusZipFile(self):
1069
1061
z = zipimport .zipimporter (TESTMOD )
1070
1062
1071
1063
try :
1072
- with warnings .catch_warnings ():
1073
- warnings .simplefilter ("ignore" , DeprecationWarning )
1074
- self .assertRaises (TypeError , z .load_module , None )
1075
1064
self .assertRaises (TypeError , z .find_module , None )
1076
1065
self .assertRaises (TypeError , z .find_spec , None )
1077
1066
self .assertRaises (TypeError , z .exec_module , None )
@@ -1082,10 +1071,6 @@ def _testBogusZipFile(self):
1082
1071
1083
1072
error = zipimport .ZipImportError
1084
1073
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' )
1089
1074
self .assertRaises (error , z .get_code , 'abc' )
1090
1075
self .assertRaises (OSError , z .get_data , 'abc' )
1091
1076
self .assertRaises (error , z .get_source , 'abc' )
0 commit comments