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

Method testDecompressLimited

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

Decompressed data buffering should be limited

(self)

Source from the content-addressed store, hash-verified

750 self.assertEqual(f.name, self.filename)
751
752 def testDecompressLimited(self):
753 """Decompressed data buffering should be limited"""
754 bomb = bz2.compress(b'\0' * int(2e6), compresslevel=9)
755 self.assertLess(len(bomb), _streams.BUFFER_SIZE)
756
757 decomp = BZ2File(BytesIO(bomb))
758 self.assertEqual(decomp.read(1), b'\0')
759 max_decomp = 1 + DEFAULT_BUFFER_SIZE
760 self.assertLessEqual(decomp._buffer.raw.tell(), max_decomp,
761 "Excessive amount of data was decompressed")
762
763
764 # Tests for a BZ2File wrapping another file object:

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected