mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-91917: Fix test_zipfile on non-UTF-8 locale (GH-91921)
Skip the extraction test if file names are not encodable.
This commit is contained in:
parent
a568585069
commit
4153f2cbcb
1 changed files with 11 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue