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

Method test_write_empty_block

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

Source from the content-addressed store, hash-verified

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