Add tests for return_bytearray in block functions
@@ -35,6 +35,31 @@ def data(request):
def store_size(request):
return request.param
+@pytest.fixture(
+ params=[
+ (
+ {
+ 'return_bytearray': True
+ }
+ ),
+ (
+ {
+ 'return_bytearray': False
+ }
+ ),
+ ]
+)
+def return_bytearray(request):
+ return request.param
+
+@pytest.fixture
+def c_return_bytearray(return_bytearray):
+ return return_bytearray
+
+@pytest.fixture
+def d_return_bytearray(return_bytearray):
+ return return_bytearray
+
@pytest.fixture(
params=[
('fast', None)
@@ -60,7 +85,7 @@ def get_stored_size(buff):
# Test single threaded usage with all valid variations of input
-def test_1(data, mode, store_size):
+def test_1(data, mode, store_size, c_return_bytearray, d_return_bytearray):
kwargs = {}
if mode[0] != None:
@@ -69,18 +94,19 @@ def test_1(data, mode, store_size):
kwargs.update(mode[1])
kwargs.update(store_size)
+ kwargs.update(c_return_bytearray)
c = []
c += [lz4.block.compress(data, **kwargs)]
c += [lz4.block.compress(bytearray(data), **kwargs)]
- c += [bytearray(c[0])]
assert (c.count(c[0]) == len(c)) # Check all list members equal
for cc in c:
if store_size['store_size']:
assert(get_stored_size(cc) == len(data))
- d = lz4.block.decompress(cc)
+ d = lz4.block.decompress(cc, **d_return_bytearray)
else:
- d = lz4.block.decompress(cc, uncompressed_size=len(data))
+ d = lz4.block.decompress(cc, uncompressed_size=len(data),
+ **d_return_bytearray)
assert(d == data)
