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