File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -456,6 +456,13 @@ def test_with_open(self):
456
456
else :
457
457
self .fail ("1/0 didn't raise an exception" )
458
458
459
+ def test_read_and_compresslevel (self ):
460
+ with igzip .GzipFile (self .filename , "wb" ) as f :
461
+ f .write (b"xxx" )
462
+ with igzip .GzipFile (self .filename , "rb" , compresslevel = 17 ) as f :
463
+ data = f .read ()
464
+ assert data == b"xxx"
465
+
459
466
def test_zero_padded_file (self ):
460
467
with igzip .GzipFile (self .filename , "wb" ) as f :
461
468
f .write (data1 * 50 )
@@ -785,6 +792,13 @@ def test_newline(self):
785
792
with igzip .open (self .filename , "rt" , newline = "\r " ) as f :
786
793
self .assertEqual (f .readlines (), [uncompressed ])
787
794
795
+ def test_reading_and_compresslevel (self ):
796
+ with igzip .open (self .filename , "wb" ) as f :
797
+ f .write (data1 )
798
+ with igzip .open (self .filename , "rb" , compresslevel = 17 ) as f :
799
+ text = f .read ()
800
+ assert text == data1
801
+
788
802
789
803
def create_and_remove_directory (directory ):
790
804
def decorator (function ):
Original file line number Diff line number Diff line change @@ -191,3 +191,11 @@ def test_igzip_threaded_append_text_mode(tmp_path):
191
191
with gzip .open (test_file , "rt" ) as f :
192
192
contents = f .read ()
193
193
assert contents == "ABCD"
194
+
195
+
196
+ def test_igzip_threaded_open_compresslevel_and_reading (tmp_path ):
197
+ test_file = tmp_path / "test.txt.gz"
198
+ test_file .write_bytes (gzip .compress (b"thisisatest" ))
199
+ with igzip_threaded .open (test_file , compresslevel = 5 ) as f :
200
+ text = f .read ()
201
+ assert text == b"thisisatest"
You can’t perform that action at this time.
0 commit comments