Mercurial > public > mercurial-scm > hg-stable
diff contrib/python-zstandard/tests/test_buffer_util.py @ 42070:675775c33ab6
zstandard: vendor python-zstandard 0.11
The upstream source distribution from PyPI was extracted. Unwanted
files were removed.
The clang-format ignore list was updated to reflect the new source
of files.
The project contains a vendored copy of zstandard 1.3.8. The old
version was 1.3.6. This should result in some minor performance wins.
test-check-py3-compat.t was updated to reflect now-passing tests on
Python 3.8.
Some HTTP tests were updated to reflect new zstd compression output.
# no-check-commit because 3rd party code has different style guidelines
Differential Revision: https://phab.mercurial-scm.org/D6199
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 04 Apr 2019 17:34:43 -0700 |
parents | b1fb341d8a61 |
children | de7838053207 |
line wrap: on
line diff
--- a/contrib/python-zstandard/tests/test_buffer_util.py Thu Apr 04 15:24:03 2019 -0700 +++ b/contrib/python-zstandard/tests/test_buffer_util.py Thu Apr 04 17:34:43 2019 -0700 @@ -8,6 +8,9 @@ class TestBufferWithSegments(unittest.TestCase): def test_arguments(self): + if not hasattr(zstd, 'BufferWithSegments'): + self.skipTest('BufferWithSegments not available') + with self.assertRaises(TypeError): zstd.BufferWithSegments() @@ -19,10 +22,16 @@ zstd.BufferWithSegments(b'foo', b'\x00\x00') def test_invalid_offset(self): + if not hasattr(zstd, 'BufferWithSegments'): + self.skipTest('BufferWithSegments not available') + with self.assertRaisesRegexp(ValueError, 'offset within segments array references memory'): zstd.BufferWithSegments(b'foo', ss.pack(0, 4)) def test_invalid_getitem(self): + if not hasattr(zstd, 'BufferWithSegments'): + self.skipTest('BufferWithSegments not available') + b = zstd.BufferWithSegments(b'foo', ss.pack(0, 3)) with self.assertRaisesRegexp(IndexError, 'offset must be non-negative'): @@ -35,6 +44,9 @@ test = b[2] def test_single(self): + if not hasattr(zstd, 'BufferWithSegments'): + self.skipTest('BufferWithSegments not available') + b = zstd.BufferWithSegments(b'foo', ss.pack(0, 3)) self.assertEqual(len(b), 1) self.assertEqual(b.size, 3) @@ -45,6 +57,9 @@ self.assertEqual(b[0].tobytes(), b'foo') def test_multiple(self): + if not hasattr(zstd, 'BufferWithSegments'): + self.skipTest('BufferWithSegments not available') + b = zstd.BufferWithSegments(b'foofooxfooxy', b''.join([ss.pack(0, 3), ss.pack(3, 4), ss.pack(7, 5)])) @@ -59,10 +74,16 @@ class TestBufferWithSegmentsCollection(unittest.TestCase): def test_empty_constructor(self): + if not hasattr(zstd, 'BufferWithSegmentsCollection'): + self.skipTest('BufferWithSegmentsCollection not available') + with self.assertRaisesRegexp(ValueError, 'must pass at least 1 argument'): zstd.BufferWithSegmentsCollection() def test_argument_validation(self): + if not hasattr(zstd, 'BufferWithSegmentsCollection'): + self.skipTest('BufferWithSegmentsCollection not available') + with self.assertRaisesRegexp(TypeError, 'arguments must be BufferWithSegments'): zstd.BufferWithSegmentsCollection(None) @@ -74,6 +95,9 @@ zstd.BufferWithSegmentsCollection(zstd.BufferWithSegments(b'', b'')) def test_length(self): + if not hasattr(zstd, 'BufferWithSegmentsCollection'): + self.skipTest('BufferWithSegmentsCollection not available') + b1 = zstd.BufferWithSegments(b'foo', ss.pack(0, 3)) b2 = zstd.BufferWithSegments(b'barbaz', b''.join([ss.pack(0, 3), ss.pack(3, 3)])) @@ -91,6 +115,9 @@ self.assertEqual(c.size(), 9) def test_getitem(self): + if not hasattr(zstd, 'BufferWithSegmentsCollection'): + self.skipTest('BufferWithSegmentsCollection not available') + b1 = zstd.BufferWithSegments(b'foo', ss.pack(0, 3)) b2 = zstd.BufferWithSegments(b'barbaz', b''.join([ss.pack(0, 3), ss.pack(3, 3)]))