diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-06-06 16:43:59 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-06-06 16:43:59 (GMT) |
commit | 5b1284d0b757f28d97fb21d487b4fe19a858c88f (patch) | |
tree | e95b77d4e44a31dd6826e1ba81d8d8659cc8af62 /Lib/test | |
parent | 3a77c7ab16d737a19cfb3fae4bd0f92517abe149 (diff) | |
download | cpython-5b1284d0b757f28d97fb21d487b4fe19a858c88f.zip cpython-5b1284d0b757f28d97fb21d487b4fe19a858c88f.tar.gz cpython-5b1284d0b757f28d97fb21d487b4fe19a858c88f.tar.bz2 |
Fix gzip.py: Use bytes where 8bit strings have been used formerly.
(The filename gets written in utf-8 encoded form which probably
isn't correct.)
Fix the test.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_gzip.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 124a469..31000df 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -8,14 +8,14 @@ import sys, os import gzip -data1 = """ int length=DEFAULTALLOC, err = Z_OK; +data1 = b""" int length=DEFAULTALLOC, err = Z_OK; PyObject *RetVal; int flushmode = Z_FINISH; unsigned long start_total_out; """ -data2 = """/* zlibmodule.c -- gzip-compatible data compression */ +data2 = b"""/* zlibmodule.c -- gzip-compatible data compression */ /* See http://www.gzip.org/zlib/ /* See http://www.winimage.com/zLibDll for Windows */ """ @@ -63,22 +63,22 @@ class TestGzip(unittest.TestCase): # many, many members. Create such a file and verify that reading it # works. f = gzip.open(self.filename, 'wb', 9) - f.write('a') + f.write(b'a') f.close() - for i in range(0,200): + for i in range(0, 200): f = gzip.open(self.filename, "ab", 9) # append - f.write('a') + f.write(b'a') f.close() # Try reading the file zgfile = gzip.open(self.filename, "rb") - contents = "" + contents = b"" while 1: ztxt = zgfile.read(8192) contents += ztxt if not ztxt: break zgfile.close() - self.assertEquals(contents, 'a'*201) + self.assertEquals(contents, b'a'*201) def test_readline(self): @@ -89,7 +89,7 @@ class TestGzip(unittest.TestCase): line_length = 0 while 1: L = f.readline(line_length) - if L == "" and line_length != 0: break + if not L and line_length != 0: break self.assert_(len(L) <= line_length) line_length = (line_length + 1) % 50 f.close() @@ -144,7 +144,7 @@ class TestGzip(unittest.TestCase): f = gzip.GzipFile(self.filename, 'w') for pos in range(0, 256, 16): f.seek(pos) - f.write('GZ\n') + f.write(b'GZ\n') f.close() def test_mode(self): |