Skip to content

bpo-25711: Remove outdated zipimport tests. #9404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions Lib/test/test_zipimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,28 +539,6 @@ def testGetData(self):
z.close()
os.remove(TEMP_ZIP)

def test_issue31291(self):
# There shouldn't be an assertion failure in get_data().
class FunnyStr(str):
def replace(self, old, new):
return 42
z = ZipFile(TEMP_ZIP, "w")
try:
name = "test31291.dat"
data = b'foo'
z.writestr(name, data)
z.close()
zi = zipimport.zipimporter(TEMP_ZIP)
try:
data2 = zi.get_data(FunnyStr(name))
except AttributeError:
pass
else:
self.assertEqual(data2, data)
finally:
z.close()
os.remove(TEMP_ZIP)

def testImporterAttr(self):
src = """if 1: # indent hack
def get_file():
Expand Down Expand Up @@ -687,38 +665,11 @@ def testBytesPath(self):
with self.assertRaises(TypeError):
zipimport.zipimporter(memoryview(os.fsencode(filename)))

@support.cpython_only
def testUninitializedZipimporter(self):
# The interpreter shouldn't crash in case of calling methods of an
# uninitialized zipimport.zipimporter object.
zi = zipimport.zipimporter.__new__(zipimport.zipimporter)
self.assertRaises((ValueError, AttributeError), zi.find_module, 'foo')
self.assertRaises((ValueError, AttributeError), zi.find_loader, 'foo')
self.assertRaises((ValueError, AttributeError), zi.load_module, 'foo')
self.assertRaises((ValueError, AttributeError), zi.get_filename, 'foo')
self.assertRaises((ValueError, AttributeError), zi.is_package, 'foo')
self.assertRaises((ValueError, AttributeError), zi.get_data, 'foo')
self.assertRaises((ValueError, AttributeError), zi.get_code, 'foo')
self.assertRaises((ValueError, AttributeError), zi.get_source, 'foo')


@support.requires_zlib
class CompressedZipImportTestCase(UncompressedZipImportTestCase):
compression = ZIP_DEFLATED

@support.cpython_only
def test_issue31602(self):
# There shouldn't be an assertion failure in zipimporter.get_source()
# in case of a bad zlib.decompress().
def bad_decompress(*args):
return None
with ZipFile(TEMP_ZIP, 'w') as zip_file:
self.addCleanup(support.unlink, TEMP_ZIP)
zip_file.writestr('bar.py', b'print("hello world")', ZIP_DEFLATED)
zi = zipimport.zipimporter(TEMP_ZIP)
with support.swap_attr(zlib, 'decompress', bad_decompress):
self.assertRaises((TypeError, AttributeError), zi.get_source, 'bar')


class BadFileZipImportTestCase(unittest.TestCase):
def assertZipFailure(self, filename):
Expand Down