(self)
| 1486 | concatenation, tuple(correct_size_lst), 300*_1K, 5) |
| 1487 | |
| 1488 | def test_as_prefix(self): |
| 1489 | # V1 |
| 1490 | V1 = THIS_FILE_BYTES |
| 1491 | zd = ZstdDict(V1, is_raw=True) |
| 1492 | |
| 1493 | # V2 |
| 1494 | mid = len(V1) // 2 |
| 1495 | V2 = V1[:mid] + \ |
| 1496 | (b'a' if V1[mid] != int.from_bytes(b'a') else b'b') + \ |
| 1497 | V1[mid+1:] |
| 1498 | |
| 1499 | # compress |
| 1500 | dat = compress(V2, zstd_dict=zd.as_prefix) |
| 1501 | self.assertEqual(get_frame_info(dat).dictionary_id, 0) |
| 1502 | |
| 1503 | # decompress |
| 1504 | self.assertEqual(decompress(dat, zd.as_prefix), V2) |
| 1505 | |
| 1506 | # use wrong prefix |
| 1507 | zd2 = ZstdDict(SAMPLES[0], is_raw=True) |
| 1508 | try: |
| 1509 | decompressed = decompress(dat, zd2.as_prefix) |
| 1510 | except ZstdError: # expected |
| 1511 | pass |
| 1512 | else: |
| 1513 | self.assertNotEqual(decompressed, V2) |
| 1514 | |
| 1515 | # read only attribute |
| 1516 | with self.assertRaises(AttributeError): |
| 1517 | zd.as_prefix = b'1234' |
| 1518 | |
| 1519 | def test_as_digested_dict(self): |
| 1520 | zd = TRAINED_DICT |
nothing calls this directly
no test coverage detected