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

Method test_open_dict

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

Source from the content-addressed store, hash-verified

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