diff -r 1ce7a55b09d1 -r b1fb341d8a61 contrib/python-zstandard/tests/test_train_dictionary.py --- a/contrib/python-zstandard/tests/test_train_dictionary.py Sun Apr 08 01:08:43 2018 +0200 +++ b/contrib/python-zstandard/tests/test_train_dictionary.py Mon Apr 09 10:13:29 2018 -0700 @@ -1,13 +1,11 @@ +import struct import sys +import unittest -try: - import unittest2 as unittest -except ImportError: - import unittest - -import zstd +import zstandard as zstd from . common import ( + generate_samples, make_cffi, ) @@ -30,55 +28,18 @@ with self.assertRaises(ValueError): zstd.train_dictionary(8192, [u'foo']) - def test_basic(self): - samples = [] - for i in range(128): - samples.append(b'foo' * 64) - samples.append(b'bar' * 64) - samples.append(b'foobar' * 64) - samples.append(b'baz' * 64) - samples.append(b'foobaz' * 64) - samples.append(b'bazfoo' * 64) + def test_no_params(self): + d = zstd.train_dictionary(8192, generate_samples()) + self.assertIsInstance(d.dict_id(), int_type) - d = zstd.train_dictionary(8192, samples) - self.assertLessEqual(len(d), 8192) - - dict_id = d.dict_id() - self.assertIsInstance(dict_id, int_type) + # The dictionary ID may be different across platforms. + expected = b'\x37\xa4\x30\xec' + struct.pack('