Skip to content

Commit 205075e

Browse files
committed
Fix error on POSIX
1 parent b0edd76 commit 205075e

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

Lib/test/test_zipfile/test_core.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4830,25 +4830,25 @@ def test_overlap_with_archive_comment(self):
48304830
def test_append_keep_filename(self):
48314831
"""Files loaded from an archive should keep original filename when
48324832
rewritten to central directory in append mode."""
4833-
with mock.patch('os.sep', '/'), mock.patch('os.altsep', None), \
4834-
zipfile.ZipFile(TESTFN, mode="w") as zipfp:
4835-
zinfo = zipfile.ZipInfo('MyFolder/My\\File.txt')
4836-
zipfp.writestr(zinfo, 'foo')
4837-
4838-
with mock.patch('os.sep', '\\'), mock.patch('os.altsep', '/'), \
4839-
zipfile.ZipFile(TESTFN, "a") as zipfp:
4840-
zi = zipfp.infolist()[0]
4841-
self.assertEqual(zi.orig_filename, 'MyFolder/My\\File.txt')
4842-
self.assertEqual(zi.filename, 'MyFolder/My/File.txt')
4843-
self.assertIsNone(zipfp.testzip())
4844-
# trigger archive rewriting
4845-
zipfp.comment = b''
4846-
4847-
with zipfile.ZipFile(TESTFN, "r") as zipfp:
4848-
zi = zipfp.infolist()[0]
4849-
self.assertEqual(zi.orig_filename, 'MyFolder/My\\File.txt')
4850-
self.assertEqual(zi.filename, 'MyFolder/My/File.txt')
4851-
self.assertIsNone(zipfp.testzip())
4833+
with mock.patch('os.sep', '/'), mock.patch('os.altsep', None):
4834+
with zipfile.ZipFile(TESTFN, mode="w") as zipfp:
4835+
zinfo = zipfile.ZipInfo('MyFolder/My\\File.txt')
4836+
zipfp.writestr(zinfo, 'foo')
4837+
4838+
with mock.patch('os.sep', '\\'), mock.patch('os.altsep', '/'):
4839+
with zipfile.ZipFile(TESTFN, "a") as zipfp:
4840+
zi = zipfp.infolist()[0]
4841+
self.assertEqual(zi.orig_filename, 'MyFolder/My\\File.txt')
4842+
self.assertEqual(zi.filename, 'MyFolder/My/File.txt')
4843+
self.assertIsNone(zipfp.testzip())
4844+
# trigger archive rewriting
4845+
zipfp.comment = b''
4846+
4847+
with zipfile.ZipFile(TESTFN, "r") as zipfp:
4848+
zi = zipfp.infolist()[0]
4849+
self.assertEqual(zi.orig_filename, 'MyFolder/My\\File.txt')
4850+
self.assertEqual(zi.filename, 'MyFolder/My/File.txt')
4851+
self.assertIsNone(zipfp.testzip())
48524852

48534853
def tearDown(self):
48544854
unlink(TESTFN)

0 commit comments

Comments
 (0)