import struct import sys import unittest import zstandard as zstd from . common import ( generate_samples, make_cffi, ) if sys.version_info[0] >= 3: int_type = int else: int_type = long @make_cffi 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, u'foo') with self.assertRaises(ValueError): zstd.train_dictionary(8192, [u'foo']) def test_no_params(self): d = zstd.train_dictionary(8192, generate_samples()) self.assertIsInstance(d.dict_id(), int_type) # The dictionary ID may be different across platforms. expected = b'\x37\xa4\x30\xec' + struct.pack('