(self)
| 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() |
nothing calls this directly
no test coverage detected