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

Method test_compress_flushblock

Lib/test/test_zstd.py:349–365  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

347 f.write(b)
348
349 def test_compress_flushblock(self):
350 point = len(THIS_FILE_BYTES) // 2
351
352 c = ZstdCompressor()
353 self.assertEqual(c.last_mode, c.FLUSH_FRAME)
354 dat1 = c.compress(THIS_FILE_BYTES[:point])
355 self.assertEqual(c.last_mode, c.CONTINUE)
356 dat1 += c.compress(THIS_FILE_BYTES[point:], c.FLUSH_BLOCK)
357 self.assertEqual(c.last_mode, c.FLUSH_BLOCK)
358 dat2 = c.flush()
359 pattern = "Compressed data ended before the end-of-stream marker"
360 with self.assertRaisesRegex(ZstdError, pattern):
361 decompress(dat1)
362
363 dat3 = decompress(dat1 + dat2)
364
365 self.assertEqual(dat3, THIS_FILE_BYTES)
366
367 def test_compress_flushframe(self):
368 # test compress & decompress

Callers

nothing calls this directly

Calls 5

decompressFunction · 0.90
assertRaisesRegexMethod · 0.80
assertEqualMethod · 0.45
compressMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected