@@ -677,24 +677,24 @@ def testBytesPath(self):
677
677
678
678
zipimport .zipimporter (filename )
679
679
zipimport .zipimporter (os .fsencode (filename ))
680
- with self .assertWarns ( DeprecationWarning ):
680
+ with self .assertRaises ( TypeError ):
681
681
zipimport .zipimporter (bytearray (os .fsencode (filename )))
682
- with self .assertWarns ( DeprecationWarning ):
682
+ with self .assertRaises ( TypeError ):
683
683
zipimport .zipimporter (memoryview (os .fsencode (filename )))
684
684
685
685
@support .cpython_only
686
686
def testUninitializedZipimporter (self ):
687
687
# The interpreter shouldn't crash in case of calling methods of an
688
688
# uninitialized zipimport.zipimporter object.
689
689
zi = zipimport .zipimporter .__new__ (zipimport .zipimporter )
690
- self .assertRaises (ValueError , zi .find_module , 'foo' )
691
- self .assertRaises (ValueError , zi .find_loader , 'foo' )
692
- self .assertRaises (ValueError , zi .load_module , 'foo' )
693
- self .assertRaises (ValueError , zi .get_filename , 'foo' )
694
- self .assertRaises (ValueError , zi .is_package , 'foo' )
695
- self .assertRaises (ValueError , zi .get_data , 'foo' )
696
- self .assertRaises (ValueError , zi .get_code , 'foo' )
697
- self .assertRaises (ValueError , zi .get_source , 'foo' )
690
+ self .assertRaises (( ValueError , AttributeError ) , zi .find_module , 'foo' )
691
+ self .assertRaises (( ValueError , AttributeError ) , zi .find_loader , 'foo' )
692
+ self .assertRaises (( ValueError , AttributeError ) , zi .load_module , 'foo' )
693
+ self .assertRaises (( ValueError , AttributeError ) , zi .get_filename , 'foo' )
694
+ self .assertRaises (( ValueError , AttributeError ) , zi .is_package , 'foo' )
695
+ self .assertRaises (( ValueError , AttributeError ) , zi .get_data , 'foo' )
696
+ self .assertRaises (( ValueError , AttributeError ) , zi .get_code , 'foo' )
697
+ self .assertRaises (( ValueError , AttributeError ) , zi .get_source , 'foo' )
698
698
699
699
700
700
@support .requires_zlib
@@ -712,7 +712,7 @@ def bad_decompress(*args):
712
712
zip_file .writestr ('bar.py' , b'print("hello world")' , ZIP_DEFLATED )
713
713
zi = zipimport .zipimporter (TEMP_ZIP )
714
714
with support .swap_attr (zlib , 'decompress' , bad_decompress ):
715
- self .assertRaises (TypeError , zi .get_source , 'bar' )
715
+ self .assertRaises (( TypeError , AttributeError ) , zi .get_source , 'bar' )
716
716
717
717
718
718
class BadFileZipImportTestCase (unittest .TestCase ):
0 commit comments