diff options
Diffstat (limited to 'Lib/test/test_zipimport.py')
| -rw-r--r-- | Lib/test/test_zipimport.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 7ddbc509f9..daa5138751 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -521,6 +521,23 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): 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) + self.assertEqual(data, zi.get_data(FunnyStr(name))) + finally: + z.close() + os.remove(TEMP_ZIP) + def testImporterAttr(self): src = """if 1: # indent hack def get_file(): |
