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

Method test_train_dict

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

Source from the content-addressed store, hash-verified

1286 ZstdDecompressor((zd, -2**1000))
1287
1288 def test_train_dict(self):
1289 TRAINED_DICT = train_dict(SAMPLES, DICT_SIZE1)
1290 ZstdDict(TRAINED_DICT.dict_content, is_raw=False)
1291
1292 self.assertNotEqual(TRAINED_DICT.dict_id, 0)
1293 self.assertGreater(len(TRAINED_DICT.dict_content), 0)
1294 self.assertLessEqual(len(TRAINED_DICT.dict_content), DICT_SIZE1)
1295 self.assertTrue(re.match(r'^<ZstdDict dict_id=\d+ dict_size=\d+>$', str(TRAINED_DICT)))
1296
1297 # compress/decompress
1298 c = ZstdCompressor(zstd_dict=TRAINED_DICT)
1299 for sample in SAMPLES:
1300 dat1 = compress(sample, zstd_dict=TRAINED_DICT)
1301 dat2 = decompress(dat1, TRAINED_DICT)
1302 self.assertEqual(sample, dat2)
1303
1304 dat1 = c.compress(sample)
1305 dat1 += c.flush()
1306 dat2 = decompress(dat1, TRAINED_DICT)
1307 self.assertEqual(sample, dat2)
1308
1309 def test_finalize_dict(self):
1310 DICT_SIZE2 = 200*_1K

Callers

nothing calls this directly

Calls 13

train_dictFunction · 0.90
compressFunction · 0.90
decompressFunction · 0.90
lenFunction · 0.85
strFunction · 0.85
assertNotEqualMethod · 0.80
assertGreaterMethod · 0.80
assertLessEqualMethod · 0.80
assertTrueMethod · 0.80
matchMethod · 0.45
assertEqualMethod · 0.45
compressMethod · 0.45

Tested by

no test coverage detected