|
31 | 31 | /* See http://www.winimage.com/zLibDll for Windows */ |
32 | 32 | """ |
33 | 33 |
|
| 34 | +# A single unsigned short - for testing memoryviews with itemsize > 1 |
| 35 | +data3 = array.array('H', [1]) |
34 | 36 |
|
35 | 37 | TEMPDIR = os.path.abspath(os_helper.TESTFN) + '-gzdir' |
36 | 38 |
|
@@ -101,6 +103,7 @@ def test_write_memoryview(self): |
101 | 103 | m = memoryview(bytes(range(256))) |
102 | 104 | data = m.cast('B', shape=[8,8,4]) |
103 | 105 | self.write_and_read_back(data) |
| 106 | + self.write_and_read_back(memoryview(data3)) |
104 | 107 |
|
105 | 108 | def test_write_bytearray(self): |
106 | 109 | self.write_and_read_back(bytearray(data1 * 50)) |
@@ -795,6 +798,16 @@ def test_decompress_missing_trailer(self): |
795 | 798 | compressed_data = gzip.compress(data1) |
796 | 799 | self.assertRaises(EOFError, gzip.decompress, compressed_data[:-8]) |
797 | 800 |
|
| 801 | + def roundtrip_compress_decompress(self, data): |
| 802 | + compressed_data = gzip.compress(data) |
| 803 | + decompressed_data = gzip.decompress(compressed_data) |
| 804 | + self.assertEqual(decompressed_data, data) |
| 805 | + |
| 806 | + def test_compress_decompress(self): |
| 807 | + self.roundtrip_compress_decompress(data1) |
| 808 | + self.roundtrip_compress_decompress(data2) |
| 809 | + self.roundtrip_compress_decompress(data3) |
| 810 | + |
798 | 811 | def test_read_truncated(self): |
799 | 812 | data = data1*50 |
800 | 813 | # Drop the CRC (4 bytes) and file size (4 bytes). |
|
0 commit comments