Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 605ebdd

Browse files
committed
Added a simple test suite for gzip. It simply opens a temp file,
writes a chunk of compressed data, closes it, writes another chunk, and reads the contents back to verify that they are the same.
1 parent f4f119c commit 605ebdd

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lib/test/test_gzip.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
import sys, os
3+
import gzip, tempfile
4+
5+
filename = tempfile.mktemp()
6+
7+
data1 = """ int length=DEFAULTALLOC, err = Z_OK;
8+
PyObject *RetVal;
9+
int flushmode = Z_FINISH;
10+
unsigned long start_total_out;
11+
12+
"""
13+
14+
data2 = """/* zlibmodule.c -- gzip-compatible data compression */
15+
/* See http://www.cdrom.com/pub/infozip/zlib/ */
16+
/* See http://www.winimage.com/zLibDll for Windows */
17+
"""
18+
19+
f = gzip.GzipFile(filename, 'w') ; f.write(data1) ; f.close()
20+
21+
f = gzip.GzipFile(filename, 'r') ; d = f.read() ; f.close()
22+
assert d == data1
23+
24+
# Append to the previous file
25+
f = gzip.GzipFile(filename, 'a') ; f.write(data2) ; f.close()
26+
27+
f = gzip.GzipFile(filename, 'r') ; d = f.read() ; f.close()
28+
assert d == data1+data2
29+
30+
os.unlink( filename )

0 commit comments

Comments
 (0)