summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-04-26 05:01:33 (GMT)
committerGitHub <noreply@github.com>2022-04-26 05:01:33 (GMT)
commit4153f2cbcb41a1a9057bfba28d5f65d48ea39283 (patch)
tree04e6362b03fa54c21c047f5a827da1673f65a548
parenta568585069174cec35ce26cdf4d4862c634d9f6d (diff)
downloadcpython-4153f2cbcb41a1a9057bfba28d5f65d48ea39283.zip
cpython-4153f2cbcb41a1a9057bfba28d5f65d48ea39283.tar.gz
cpython-4153f2cbcb41a1a9057bfba28d5f65d48ea39283.tar.bz2
gh-91917: Fix test_zipfile on non-UTF-8 locale (GH-91921)
Skip the extraction test if file names are not encodable.
-rw-r--r--Lib/test/test_zipfile.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index 17111b3..848bf4f 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -3391,8 +3391,19 @@ class EncodedMetadataTests(unittest.TestCase):
for name in self.file_names:
self.assertIn(name, listing)
+ def test_cli_with_metadata_encoding_extract(self):
os.mkdir(TESTFN2)
self.addCleanup(rmtree, TESTFN2)
+ # Depending on locale, extracted file names can be not encodable
+ # with the filesystem encoding.
+ for fn in self.file_names:
+ try:
+ os.stat(os.path.join(TESTFN2, fn))
+ except OSError:
+ pass
+ except UnicodeEncodeError:
+ self.skipTest(f'cannot encode file name {fn!r}')
+
zipfile.main(["--metadata-encoding=shift_jis", "-e", TESTFN, TESTFN2])
listing = os.listdir(TESTFN2)
for name in self.file_names: