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

Method test_write_append

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

Source from the content-addressed store, hash-verified

2184 self.assertEqual(dst.getvalue(), expected)
2185
2186 def test_write_append(self):
2187 def comp(data):
2188 comp = ZstdCompressor()
2189 return comp.compress(data) + comp.flush()
2190
2191 part1 = THIS_FILE_BYTES[:_1K]
2192 part2 = THIS_FILE_BYTES[_1K:1536]
2193 part3 = THIS_FILE_BYTES[1536:]
2194 expected = b"".join(comp(x) for x in (part1, part2, part3))
2195 with io.BytesIO() as dst:
2196 with ZstdFile(dst, "w") as f:
2197 f.write(part1)
2198 with ZstdFile(dst, "a") as f:
2199 f.write(part2)
2200 with ZstdFile(dst, "a") as f:
2201 f.write(part3)
2202 self.assertEqual(dst.getvalue(), expected)
2203
2204 def test_write_bad_args(self):
2205 f = ZstdFile(io.BytesIO(), "w")

Callers

nothing calls this directly

Calls 5

ZstdFileClass · 0.90
joinMethod · 0.45
writeMethod · 0.45
assertEqualMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected