MCPcopy Index your code
hub / github.com/RustPython/RustPython / testDecompressLimited

Method testDecompressLimited

Lib/test/test_bz2.py:743–752  ·  view source on GitHub ↗

Decompressed data buffering should be limited

(self)

Source from the content-addressed store, hash-verified

741 self.assertEqual(f.name, self.filename)
742
743 def testDecompressLimited(self):
744 """Decompressed data buffering should be limited"""
745 bomb = bz2.compress(b'\0' * int(2e6), compresslevel=9)
746 self.assertLess(len(bomb), _streams.BUFFER_SIZE)
747
748 decomp = BZ2File(BytesIO(bomb))
749 self.assertEqual(decomp.read(1), b'\0')
750 max_decomp = 1 + DEFAULT_BUFFER_SIZE
751 self.assertLessEqual(decomp._buffer.raw.tell(), max_decomp,
752 "Excessive amount of data was decompressed")
753
754
755 # Tests for a BZ2File wrapping another file object:

Callers

nothing calls this directly

Calls 9

readMethod · 0.95
BZ2FileClass · 0.90
BytesIOClass · 0.90
lenFunction · 0.85
assertLessEqualMethod · 0.80
compressMethod · 0.45
assertLessMethod · 0.45
assertEqualMethod · 0.45
tellMethod · 0.45

Tested by

no test coverage detected