Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2984ab

Browse files
bpo-25711: Remove outdated zipimport tests. (GH-9404)
They were specific to the C implementation.
1 parent 3705b98 commit b2984ab

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

Lib/test/test_zipimport.py

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -539,28 +539,6 @@ def testGetData(self):
539539
z.close()
540540
os.remove(TEMP_ZIP)
541541

542-
def test_issue31291(self):
543-
# There shouldn't be an assertion failure in get_data().
544-
class FunnyStr(str):
545-
def replace(self, old, new):
546-
return 42
547-
z = ZipFile(TEMP_ZIP, "w")
548-
try:
549-
name = "test31291.dat"
550-
data = b'foo'
551-
z.writestr(name, data)
552-
z.close()
553-
zi = zipimport.zipimporter(TEMP_ZIP)
554-
try:
555-
data2 = zi.get_data(FunnyStr(name))
556-
except AttributeError:
557-
pass
558-
else:
559-
self.assertEqual(data2, data)
560-
finally:
561-
z.close()
562-
os.remove(TEMP_ZIP)
563-
564542
def testImporterAttr(self):
565543
src = """if 1: # indent hack
566544
def get_file():
@@ -687,38 +665,11 @@ def testBytesPath(self):
687665
with self.assertRaises(TypeError):
688666
zipimport.zipimporter(memoryview(os.fsencode(filename)))
689667

690-
@support.cpython_only
691-
def testUninitializedZipimporter(self):
692-
# The interpreter shouldn't crash in case of calling methods of an
693-
# uninitialized zipimport.zipimporter object.
694-
zi = zipimport.zipimporter.__new__(zipimport.zipimporter)
695-
self.assertRaises((ValueError, AttributeError), zi.find_module, 'foo')
696-
self.assertRaises((ValueError, AttributeError), zi.find_loader, 'foo')
697-
self.assertRaises((ValueError, AttributeError), zi.load_module, 'foo')
698-
self.assertRaises((ValueError, AttributeError), zi.get_filename, 'foo')
699-
self.assertRaises((ValueError, AttributeError), zi.is_package, 'foo')
700-
self.assertRaises((ValueError, AttributeError), zi.get_data, 'foo')
701-
self.assertRaises((ValueError, AttributeError), zi.get_code, 'foo')
702-
self.assertRaises((ValueError, AttributeError), zi.get_source, 'foo')
703-
704668

705669
@support.requires_zlib
706670
class CompressedZipImportTestCase(UncompressedZipImportTestCase):
707671
compression = ZIP_DEFLATED
708672

709-
@support.cpython_only
710-
def test_issue31602(self):
711-
# There shouldn't be an assertion failure in zipimporter.get_source()
712-
# in case of a bad zlib.decompress().
713-
def bad_decompress(*args):
714-
return None
715-
with ZipFile(TEMP_ZIP, 'w') as zip_file:
716-
self.addCleanup(support.unlink, TEMP_ZIP)
717-
zip_file.writestr('bar.py', b'print("hello world")', ZIP_DEFLATED)
718-
zi = zipimport.zipimporter(TEMP_ZIP)
719-
with support.swap_attr(zlib, 'decompress', bad_decompress):
720-
self.assertRaises((TypeError, AttributeError), zi.get_source, 'bar')
721-
722673

723674
class BadFileZipImportTestCase(unittest.TestCase):
724675
def assertZipFailure(self, filename):

0 commit comments

Comments
 (0)