Skip to content

Commit c090211

Browse files
bpo-25711: Rewrite zipimport in pure Python.
1 parent 8d41278 commit c090211

File tree

13 files changed

+1621
-2040
lines changed

13 files changed

+1621
-2040
lines changed

Lib/test/test_zipimport.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -677,24 +677,24 @@ def testBytesPath(self):
677677

678678
zipimport.zipimporter(filename)
679679
zipimport.zipimporter(os.fsencode(filename))
680-
with self.assertWarns(DeprecationWarning):
680+
with self.assertRaises(TypeError):
681681
zipimport.zipimporter(bytearray(os.fsencode(filename)))
682-
with self.assertWarns(DeprecationWarning):
682+
with self.assertRaises(TypeError):
683683
zipimport.zipimporter(memoryview(os.fsencode(filename)))
684684

685685
@support.cpython_only
686686
def testUninitializedZipimporter(self):
687687
# The interpreter shouldn't crash in case of calling methods of an
688688
# uninitialized zipimport.zipimporter object.
689689
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')
698698

699699

700700
@support.requires_zlib
@@ -712,7 +712,7 @@ def bad_decompress(*args):
712712
zip_file.writestr('bar.py', b'print("hello world")', ZIP_DEFLATED)
713713
zi = zipimport.zipimporter(TEMP_ZIP)
714714
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')
716716

717717

718718
class BadFileZipImportTestCase(unittest.TestCase):

0 commit comments

Comments
 (0)