From e3bf6ea251f930319c6cdd43b80137a268e93c27 Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Mon, 21 Sep 2020 14:45:03 +0200 Subject: [PATCH 1/2] Use eof instance variable to determine whether compression has ended. The unconsumed tail has a possibility to be empty, even if the end of compression is not reached --- Lib/test/test_zlib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 7f30cac64f71b9..332671164e76bb 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -358,7 +358,7 @@ def test_decompimax(self, source=None, cx=256, dcx=64): dco = zlib.decompressobj() bufs = [] cb = combuf - while cb: + while not dco.eof: #max_length = 1 + len(cb)//10 chunk = dco.decompress(cb, dcx) self.assertFalse(len(chunk) > dcx, @@ -383,7 +383,7 @@ def test_decompressmaxlen(self, flush=False): dco = zlib.decompressobj() bufs = [] cb = combuf - while cb: + while not dco.eof: max_length = 1 + len(cb)//10 chunk = dco.decompress(cb, max_length) self.assertFalse(len(chunk) > max_length, @@ -393,7 +393,7 @@ def test_decompressmaxlen(self, flush=False): if flush: bufs.append(dco.flush()) else: - while chunk: + while not dco.eof: chunk = dco.decompress(b'', max_length) self.assertFalse(len(chunk) > max_length, 'chunk too big (%d>%d)' % (len(chunk),max_length)) From bed22acd7d6854716dcbb12b3f747ad130785598 Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Fri, 25 Sep 2020 11:52:19 +0200 Subject: [PATCH 2/2] Expect only basename of file stored in gzip header. --- Lib/test/test_gzip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index c3fa9b097f8aaa..d394d22d83c967 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -331,7 +331,7 @@ def test_metadata(self): self.assertEqual(cmByte, b'\x08') # deflate try: - expectedname = self.filename.encode('Latin-1') + b'\x00' + expectedname = os.path.basename(self.filename).encode('Latin-1') + b'\x00' expectedflags = b'\x08' # only the FNAME flag is set except UnicodeEncodeError: expectedname = b''