diff options
| author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-18 11:43:23 (GMT) |
|---|---|---|
| committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-18 11:43:23 (GMT) |
| commit | ff1d2f4cc5a165b2d4dcc4b5abe6335cb3626e53 (patch) | |
| tree | 9e57aaf86c8a77c3d52420a7459c0ce0059efc52 /Lib/test/test_zipfile.py | |
| parent | 02a67ac72be5adb37431b18c3f4b7cb060be6e16 (diff) | |
| download | cpython-ff1d2f4cc5a165b2d4dcc4b5abe6335cb3626e53.zip cpython-ff1d2f4cc5a165b2d4dcc4b5abe6335cb3626e53.tar.gz cpython-ff1d2f4cc5a165b2d4dcc4b5abe6335cb3626e53.tar.bz2 | |
Backport commit 33543b4e0e5d from Python 3.2: #10801: In zipfile, support
different encodings for the header and the filenames. Patch by MvL, test by
Eli Bendersky.
Diffstat (limited to 'Lib/test/test_zipfile.py')
| -rw-r--r-- | Lib/test/test_zipfile.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 34d0fbc..825fba1 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -3,7 +3,13 @@ try: import zlib except ImportError: zlib = None -import zipfile, os, unittest, sys, shutil, struct, io +import io +import os +import shutil +import struct +import sys +import unittest +import zipfile from tempfile import TemporaryFile from random import randint, random @@ -14,6 +20,7 @@ from test.support import TESTFN, run_unittest, findfile TESTFN2 = TESTFN + "2" TESTFNDIR = TESTFN + "d" FIXEDTEST_SIZE = 1000 +DATAFILES_DIR = 'zipfile_datafiles' SMALL_TEST_DATA = [('_ziptest1', '1q2w3e4r5t'), ('ziptest2dir/_ziptest2', 'qawsedrftg'), @@ -387,9 +394,25 @@ class TestsWithSourceFile(unittest.TestCase): orig_zip.writestr(zinfo, data) orig_zip.close() + def test_unicode_filenames(self): + if __name__ == '__main__': + myfile = sys.argv[0] + else: + myfile = __file__ + + mydir = os.path.dirname(myfile) or os.curdir + fname = os.path.join(mydir, 'zip_cp437_header.zip') + + print(fname) + zipfp = zipfile.ZipFile(fname) + try: + zipfp.extractall() + finally: + zipfp.close() + def tearDown(self): - os.remove(TESTFN) - os.remove(TESTFN2) + support.unlink(TESTFN) + support.unlink(TESTFN2) class TestZip64InSmallFiles(unittest.TestCase): # These tests test the ZIP64 functionality without using large files, |
