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

Method test_read_truncated

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

Source from the content-addressed store, hash-verified

1927 self.assertRaises(ZstdError, f.read)
1928
1929 def test_read_truncated(self):
1930 # Drop stream epilogue: 4 bytes checksum
1931 truncated = DAT_130K_C[:-4]
1932 with ZstdFile(io.BytesIO(truncated)) as f:
1933 self.assertRaises(EOFError, f.read)
1934
1935 with ZstdFile(io.BytesIO(truncated)) as f:
1936 # this is an important test, make sure it doesn't raise EOFError.
1937 self.assertEqual(f.read(130*_1K), DAT_130K_D)
1938 with self.assertRaises(EOFError):
1939 f.read(1)
1940
1941 # Incomplete header
1942 for i in range(1, 20):
1943 with ZstdFile(io.BytesIO(truncated[:i])) as f:
1944 self.assertRaises(EOFError, f.read, 1)
1945
1946 def test_read_bad_args(self):
1947 f = ZstdFile(io.BytesIO(COMPRESSED_DAT))

Callers

nothing calls this directly

Calls 4

ZstdFileClass · 0.90
assertRaisesMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected