MCPcopy Index your code
hub / github.com/python/cpython / test_flush_flushes_compressor

Method test_flush_flushes_compressor

Lib/test/test_gzip.py:835–854  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

writeMethod · 0.95
getvalueMethod · 0.95
readMethod · 0.95
decompressMethod · 0.80
_read_gzip_headerMethod · 0.80
flushMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected