(self)
| 833 | self.assertEqual(f.tell(), LENGTH) |
| 834 | |
| 835 | def test_flush_flushes_compressor(self): |
| 836 | # See issue GH-105808. |
| 837 | b = io.BytesIO() |
| 838 | message = b"important message here." |
| 839 | with gzip.GzipFile(fileobj=b, mode='w') as f: |
| 840 | f.write(message) |
| 841 | f.flush() |
| 842 | partial_data = b.getvalue() |
| 843 | full_data = b.getvalue() |
| 844 | self.assertEqual(gzip.decompress(full_data), message) |
| 845 | # The partial data should contain the gzip header and the complete |
| 846 | # message, but not the end-of-stream markers (so we can't just |
| 847 | # decompress it directly). |
| 848 | with self.assertRaises(EOFError): |
| 849 | gzip.decompress(partial_data) |
| 850 | d = zlib.decompressobj(wbits=-zlib.MAX_WBITS) |
| 851 | f = io.BytesIO(partial_data) |
| 852 | gzip._read_gzip_header(f) |
| 853 | read_message = d.decompress(f.read()) |
| 854 | self.assertEqual(read_message, message) |
| 855 | |
| 856 | def test_flush_modes(self): |
| 857 | # Make sure the argument to flush is properly passed to the |
nothing calls this directly
no test coverage detected