diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-06-25 14:56:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-25 14:56:31 (GMT) |
commit | 700cfa8c90a90016638bac13c4efd03786b2b2a0 (patch) | |
tree | 62994f7b8d6fccd910d5f65bd6cd49a4f72bf8ae /Lib/test/test_gzip.py | |
parent | 8ea6353f60625c96ce96588c70ff24a77f8c71f9 (diff) | |
download | cpython-700cfa8c90a90016638bac13c4efd03786b2b2a0.zip cpython-700cfa8c90a90016638bac13c4efd03786b2b2a0.tar.gz cpython-700cfa8c90a90016638bac13c4efd03786b2b2a0.tar.bz2 |
bpo-41069: Make TESTFN and the CWD for tests containing non-ascii characters. (GH-21035)
Diffstat (limited to 'Lib/test/test_gzip.py')
-rw-r--r-- | Lib/test/test_gzip.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 7833421..0f235d1 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -328,8 +328,15 @@ class TestGzip(BaseTest): cmByte = fRead.read(1) self.assertEqual(cmByte, b'\x08') # deflate + try: + expectedname = self.filename.encode('Latin-1') + b'\x00' + expectedflags = b'\x08' # only the FNAME flag is set + except UnicodeEncodeError: + expectedname = b'' + expectedflags = b'\x00' + flagsByte = fRead.read(1) - self.assertEqual(flagsByte, b'\x08') # only the FNAME flag is set + self.assertEqual(flagsByte, expectedflags) mtimeBytes = fRead.read(4) self.assertEqual(mtimeBytes, struct.pack('<i', mtime)) # little-endian @@ -344,9 +351,8 @@ class TestGzip(BaseTest): # RFC 1952 specifies that this is the name of the input file, if any. # However, the gzip module defaults to storing the name of the output # file in this field. - expected = self.filename.encode('Latin-1') + b'\x00' - nameBytes = fRead.read(len(expected)) - self.assertEqual(nameBytes, expected) + nameBytes = fRead.read(len(expectedname)) + self.assertEqual(nameBytes, expectedname) # Since no other flags were set, the header ends here. # Rather than process the compressed data, let's seek to the trailer. @@ -358,6 +364,10 @@ class TestGzip(BaseTest): isizeBytes = fRead.read(4) self.assertEqual(isizeBytes, struct.pack('<i', len(data1))) + def test_metadata_ascii_name(self): + self.filename = support.TESTFN_ASCII + self.test_metadata() + def test_compresslevel_metadata(self): # see RFC 1952: http://www.faqs.org/rfcs/rfc1952.html # specifically, discussion of XFL in section 2.3.1 |