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

Method test_open_dict

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

Source from the content-addressed store, hash-verified

2621 os.remove(TESTFN)
2622
2623 def test_open_dict(self):
2624 # default
2625 bi = io.BytesIO()
2626 with open(bi, 'w', zstd_dict=TRAINED_DICT) as f:
2627 f.write(SAMPLES[0])
2628 bi.seek(0)
2629 with open(bi, zstd_dict=TRAINED_DICT) as f:
2630 dat = f.read()
2631 self.assertEqual(dat, SAMPLES[0])
2632
2633 # .as_(un)digested_dict
2634 bi = io.BytesIO()
2635 with open(bi, 'w', zstd_dict=TRAINED_DICT.as_digested_dict) as f:
2636 f.write(SAMPLES[0])
2637 bi.seek(0)
2638 with open(bi, zstd_dict=TRAINED_DICT.as_undigested_dict) as f:
2639 dat = f.read()
2640 self.assertEqual(dat, SAMPLES[0])
2641
2642 # invalid dictionary
2643 bi = io.BytesIO()
2644 with self.assertRaisesRegex(TypeError, 'zstd_dict'):
2645 open(bi, 'w', zstd_dict={1:2, 2:3})
2646
2647 with self.assertRaisesRegex(TypeError, 'zstd_dict'):
2648 open(bi, 'w', zstd_dict=b'1234567890')
2649
2650 def test_open_prefix(self):
2651 bi = io.BytesIO()

Callers

nothing calls this directly

Calls 6

seekMethod · 0.95
openFunction · 0.90
assertRaisesRegexMethod · 0.80
writeMethod · 0.45
readMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected