comparison contrib/python-zstandard/tests/test_buffer_util.py @ 44232:5e84a96d865b

python-zstandard: blacken at 80 characters I made this change upstream and it will make it into the next release of python-zstandard. I figured I'd send it Mercurial's way because it will allow us to drop this directory from the black exclusion list. # skip-blame blackening Differential Revision: https://phab.mercurial-scm.org/D7937
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 22 Jan 2020 22:23:04 -0800
parents de7838053207
children
comparison
equal deleted inserted replaced
44231:45ec64d93b3a 44232:5e84a96d865b
65 def test_multiple(self): 65 def test_multiple(self):
66 if not hasattr(zstd, "BufferWithSegments"): 66 if not hasattr(zstd, "BufferWithSegments"):
67 self.skipTest("BufferWithSegments not available") 67 self.skipTest("BufferWithSegments not available")
68 68
69 b = zstd.BufferWithSegments( 69 b = zstd.BufferWithSegments(
70 b"foofooxfooxy", b"".join([ss.pack(0, 3), ss.pack(3, 4), ss.pack(7, 5)]) 70 b"foofooxfooxy",
71 b"".join([ss.pack(0, 3), ss.pack(3, 4), ss.pack(7, 5)]),
71 ) 72 )
72 self.assertEqual(len(b), 3) 73 self.assertEqual(len(b), 3)
73 self.assertEqual(b.size, 12) 74 self.assertEqual(b.size, 12)
74 self.assertEqual(b.tobytes(), b"foofooxfooxy") 75 self.assertEqual(b.tobytes(), b"foofooxfooxy")
75 76
81 class TestBufferWithSegmentsCollection(TestCase): 82 class TestBufferWithSegmentsCollection(TestCase):
82 def test_empty_constructor(self): 83 def test_empty_constructor(self):
83 if not hasattr(zstd, "BufferWithSegmentsCollection"): 84 if not hasattr(zstd, "BufferWithSegmentsCollection"):
84 self.skipTest("BufferWithSegmentsCollection not available") 85 self.skipTest("BufferWithSegmentsCollection not available")
85 86
86 with self.assertRaisesRegex(ValueError, "must pass at least 1 argument"): 87 with self.assertRaisesRegex(
88 ValueError, "must pass at least 1 argument"
89 ):
87 zstd.BufferWithSegmentsCollection() 90 zstd.BufferWithSegmentsCollection()
88 91
89 def test_argument_validation(self): 92 def test_argument_validation(self):
90 if not hasattr(zstd, "BufferWithSegmentsCollection"): 93 if not hasattr(zstd, "BufferWithSegmentsCollection"):
91 self.skipTest("BufferWithSegmentsCollection not available") 94 self.skipTest("BufferWithSegmentsCollection not available")
92 95
93 with self.assertRaisesRegex(TypeError, "arguments must be BufferWithSegments"): 96 with self.assertRaisesRegex(
97 TypeError, "arguments must be BufferWithSegments"
98 ):
94 zstd.BufferWithSegmentsCollection(None) 99 zstd.BufferWithSegmentsCollection(None)
95 100
96 with self.assertRaisesRegex(TypeError, "arguments must be BufferWithSegments"): 101 with self.assertRaisesRegex(
102 TypeError, "arguments must be BufferWithSegments"
103 ):
97 zstd.BufferWithSegmentsCollection( 104 zstd.BufferWithSegmentsCollection(
98 zstd.BufferWithSegments(b"foo", ss.pack(0, 3)), None 105 zstd.BufferWithSegments(b"foo", ss.pack(0, 3)), None
99 ) 106 )
100 107
101 with self.assertRaisesRegex( 108 with self.assertRaisesRegex(