diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-02 17:50:59 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-02 17:50:59 (GMT) |
commit | e5e64444979f0bb6c922f1c2742440f964ce6801 (patch) | |
tree | fb29f3273e7626bba610332461bfef7bc303a1e0 /Lib/test | |
parent | f458a036178844beae8bc332e5b5a0570276be3c (diff) | |
download | cpython-e5e64444979f0bb6c922f1c2742440f964ce6801.zip cpython-e5e64444979f0bb6c922f1c2742440f964ce6801.tar.gz cpython-e5e64444979f0bb6c922f1c2742440f964ce6801.tar.bz2 |
Fix the test for issue #6972.
Remove trailing dots on Windows.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_zipfile.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 85cd074..c00c83e 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -456,8 +456,6 @@ class TestsWithSourceFile(unittest.TestCase): ('/foo/bar', 'foo/bar'), ('/foo/../bar', 'foo/bar'), ('/foo/../../bar', 'foo/bar'), - ('//foo/bar', 'foo/bar'), - ('../../foo../../ba..r', 'foo../ba..r'), ] if os.path.sep == '\\': # Windows. hacknames.extend([ @@ -479,19 +477,32 @@ class TestsWithSourceFile(unittest.TestCase): (r'\\?\C:\foo\bar', 'foo/bar'), (r'C:/../C:/foo/bar', 'C_/foo/bar'), (r'a:b\c<d>e|f"g?h*i', 'b/c_d_e_f_g_h_i'), + ('../../foo../../ba..r', 'foo/ba..r'), + ]) + else: # Unix + hacknames.extend([ + ('//foo/bar', 'foo/bar'), + ('../../foo../../ba..r', 'foo../ba..r'), + (r'foo/..\bar', r'foo/..\bar'), ]) for arcname, fixedname in hacknames: content = b'foobar' + arcname.encode() with zipfile.ZipFile(TESTFN2, 'w', zipfile.ZIP_STORED) as zipfp: - zipfp.writestr(arcname, content) + zinfo = zipfile.ZipInfo() + # preserve backslashes + zinfo.filename = arcname + zinfo.external_attr = 0o600 << 16 + zipfp.writestr(zinfo, content) + arcname = arcname.replace(os.sep, "/") targetpath = os.path.join('target', 'subdir', 'subsub') correctfile = os.path.join(targetpath, *fixedname.split('/')) with zipfile.ZipFile(TESTFN2, 'r') as zipfp: writtenfile = zipfp.extract(arcname, targetpath) - self.assertEqual(writtenfile, correctfile) + self.assertEqual(writtenfile, correctfile, + msg="extract %r" % arcname) self.check_file(correctfile, content) shutil.rmtree('target') @@ -504,7 +515,8 @@ class TestsWithSourceFile(unittest.TestCase): with zipfile.ZipFile(TESTFN2, 'r') as zipfp: writtenfile = zipfp.extract(arcname) - self.assertEqual(writtenfile, correctfile) + self.assertEqual(writtenfile, correctfile, + msg="extract %r" % arcname) self.check_file(correctfile, content) shutil.rmtree(fixedname.split('/')[0]) |