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

Method test_write_empty_block

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

Source from the content-addressed store, hash-verified

2145 self.assertNotEqual(bo.getvalue(), b'')
2146
2147 def test_write_empty_block(self):
2148 # If no internal data, .FLUSH_BLOCK return b''.
2149 c = ZstdCompressor()
2150 self.assertEqual(c.flush(c.FLUSH_BLOCK), b'')
2151 self.assertNotEqual(c.compress(b'123', c.FLUSH_BLOCK),
2152 b'')
2153 self.assertEqual(c.flush(c.FLUSH_BLOCK), b'')
2154 self.assertEqual(c.compress(b''), b'')
2155 self.assertEqual(c.compress(b''), b'')
2156 self.assertEqual(c.flush(c.FLUSH_BLOCK), b'')
2157
2158 # mode = .last_mode
2159 bo = io.BytesIO()
2160 with ZstdFile(bo, 'w') as f:
2161 f.write(b'123')
2162 f.flush(f.FLUSH_BLOCK)
2163 fp_pos = f._fp.tell()
2164 self.assertNotEqual(fp_pos, 0)
2165 f.flush(f.FLUSH_BLOCK)
2166 self.assertEqual(f._fp.tell(), fp_pos)
2167
2168 # mode != .last_mode
2169 bo = io.BytesIO()
2170 with ZstdFile(bo, 'w') as f:
2171 f.flush(f.FLUSH_BLOCK)
2172 self.assertEqual(f._fp.tell(), 0)
2173 f.write(b'')
2174 f.flush(f.FLUSH_BLOCK)
2175 self.assertEqual(f._fp.tell(), 0)
2176
2177 def test_write_101(self):
2178 with io.BytesIO() as dst:

Callers

nothing calls this directly

Calls 7

ZstdFileClass · 0.90
assertNotEqualMethod · 0.80
assertEqualMethod · 0.45
flushMethod · 0.45
compressMethod · 0.45
writeMethod · 0.45
tellMethod · 0.45

Tested by

no test coverage detected