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

Method test_finalize_dict

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

finalize_dictFunction · 0.90
compressFunction · 0.90
decompressFunction · 0.90
lenFunction · 0.85
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