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

Method test_decompress_limited

Lib/test/test_gzip.py:717–727  ·  view source on GitHub ↗

Decompressed data buffering should be limited

(self)

Source from the content-addressed store, hash-verified

715 self.assertEqual(f.name, self.filename)
716
717 def test_decompress_limited(self):
718 """Decompressed data buffering should be limited"""
719 bomb = gzip.compress(b'\0' * int(2e6), compresslevel=9)
720 self.assertLess(len(bomb), io.DEFAULT_BUFFER_SIZE)
721
722 bomb = io.BytesIO(bomb)
723 decomp = gzip.GzipFile(fileobj=bomb)
724 self.assertEqual(decomp.read(1), b'\0')
725 max_decomp = 1 + io.DEFAULT_BUFFER_SIZE
726 self.assertLessEqual(decomp._buffer.raw.tell(), max_decomp,
727 "Excessive amount of data was decompressed")
728
729 # Testing compress/decompress shortcut functions
730

Callers

nothing calls this directly

Calls 6

readMethod · 0.95
assertLessEqualMethod · 0.80
compressMethod · 0.45
assertLessMethod · 0.45
assertEqualMethod · 0.45
tellMethod · 0.45

Tested by

no test coverage detected