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

Method test_write_append

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

Source from the content-addressed store, hash-verified

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