import struct import unittest import zstandard as zstd from .common import ( generate_samples, get_optimal_dict_size_heuristically, random_input_data, ) class TestTrainDictionary(unittest.TestCase): def test_no_args(self): with self.assertRaises(TypeError): zstd.train_dictionary() def test_bad_args(self): with self.assertRaises(TypeError): zstd.train_dictionary(8192, "foo") with self.assertRaises(ValueError): zstd.train_dictionary(8192, ["foo"]) def test_no_params(self): d = zstd.train_dictionary(8192, random_input_data()) self.assertIsInstance(d.dict_id(), int) # The dictionary ID may be different across platforms. expected = b"\x37\xa4\x30\xec" + struct.pack("