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

Method test_finalize_dict

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

Source from the content-addressed store, hash-verified

1306 self.assertEqual(sample, dat2)
1307
1308 def test_finalize_dict(self):
1309 DICT_SIZE2 = 200*_1K
1310 C_LEVEL = 6
1311
1312 try:
1313 dic2 = finalize_dict(TRAINED_DICT, SAMPLES, DICT_SIZE2, C_LEVEL)
1314 except NotImplementedError:
1315 # < v1.4.5 at compile-time, >= v.1.4.5 at run-time
1316 return
1317
1318 self.assertNotEqual(dic2.dict_id, 0)
1319 self.assertGreater(len(dic2.dict_content), 0)
1320 self.assertLessEqual(len(dic2.dict_content), DICT_SIZE2)
1321
1322 # compress/decompress
1323 c = ZstdCompressor(C_LEVEL, zstd_dict=dic2)
1324 for sample in SAMPLES:
1325 dat1 = compress(sample, C_LEVEL, zstd_dict=dic2)
1326 dat2 = decompress(dat1, dic2)
1327 self.assertEqual(sample, dat2)
1328
1329 dat1 = c.compress(sample)
1330 dat1 += c.flush()
1331 dat2 = decompress(dat1, dic2)
1332 self.assertEqual(sample, dat2)
1333
1334 # dict mismatch
1335 self.assertNotEqual(TRAINED_DICT.dict_id, dic2.dict_id)
1336
1337 dat1 = compress(SAMPLES[0], zstd_dict=TRAINED_DICT)
1338 with self.assertRaises(ZstdError):
1339 decompress(dat1, dic2)
1340
1341 def test_train_dict_arguments(self):
1342 with self.assertRaises(ValueError):

Callers

nothing calls this directly

Calls 10

finalize_dictFunction · 0.90
compressFunction · 0.90
decompressFunction · 0.90
assertNotEqualMethod · 0.80
assertGreaterMethod · 0.80
assertLessEqualMethod · 0.80
assertEqualMethod · 0.45
compressMethod · 0.45
flushMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected