From: Serhiy Storchaka Date: Tue, 26 Apr 2022 05:01:33 +0000 (+0300) Subject: gh-91917: Fix test_zipfile on non-UTF-8 locale (GH-91921) X-Git-Tag: v3.11.0b1~211 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4153f2cbcb41a1a9057bfba28d5f65d48ea39283;p=thirdparty%2FPython%2Fcpython.git gh-91917: Fix test_zipfile on non-UTF-8 locale (GH-91921) Skip the extraction test if file names are not encodable. --- diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 17111b3a40fe..848bf4f76d45 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: