Skip to content
Snippets Groups Projects
Commit b3f4a41d authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Autoformat test file

parent 9b0e738a
No related branches found
No related tags found
No related merge requests found
Pipeline #163022 passed
...@@ -4,9 +4,10 @@ import pytest ...@@ -4,9 +4,10 @@ import pytest
from zlib_into import compress_into, decompress_into from zlib_into import compress_into, decompress_into
def test_compress_into(): def test_compress_into():
buf_size = 5000 buf_size = 5000
data_in = b'abcde' * 5000 data_in = b"abcde" * 5000
buf = bytearray(buf_size) buf = bytearray(buf_size)
n_bytes_out = compress_into(data_in, buf) n_bytes_out = compress_into(data_in, buf)
...@@ -14,7 +15,7 @@ def test_compress_into(): ...@@ -14,7 +15,7 @@ def test_compress_into():
assert 0 < n_bytes_out < buf_size assert 0 < n_bytes_out < buf_size
# Remaining space in buffer should not have been touched # Remaining space in buffer should not have been touched
assert bytes(buf[n_bytes_out:]) == b'\0' * (buf_size - n_bytes_out) assert bytes(buf[n_bytes_out:]) == b"\0" * (buf_size - n_bytes_out)
# Roundtrip # Roundtrip
assert zlib.decompress(buf[:n_bytes_out]) == data_in assert zlib.decompress(buf[:n_bytes_out]) == data_in
...@@ -22,7 +23,7 @@ def test_compress_into(): ...@@ -22,7 +23,7 @@ def test_compress_into():
def test_compress_into_err(): def test_compress_into_err():
buf_size = 5000 buf_size = 5000
data_in = b'abcde' * 5000 data_in = b"abcde" * 5000
buf = bytearray(5000) buf = bytearray(5000)
with pytest.raises(BufferError): with pytest.raises(BufferError):
compress_into(memoryview(data_in)[::2], buf) # Input not contiguous compress_into(memoryview(data_in)[::2], buf) # Input not contiguous
...@@ -35,7 +36,7 @@ def test_compress_into_err(): ...@@ -35,7 +36,7 @@ def test_compress_into_err():
def test_decompress_into(): def test_decompress_into():
expanded_data = b'abcde' * 5000 expanded_data = b"abcde" * 5000
compressed_data = zlib.compress(expanded_data) compressed_data = zlib.compress(expanded_data)
buf = bytearray(len(expanded_data) + 10) buf = bytearray(len(expanded_data) + 10)
...@@ -46,7 +47,7 @@ def test_decompress_into(): ...@@ -46,7 +47,7 @@ def test_decompress_into():
assert buf[:n_bytes_out] == expanded_data assert buf[:n_bytes_out] == expanded_data
# Remaining space in buffer should not have been touched # Remaining space in buffer should not have been touched
assert bytes(buf[n_bytes_out:]) == b'\0' * (len(buf) - n_bytes_out) assert bytes(buf[n_bytes_out:]) == b"\0" * (len(buf) - n_bytes_out)
# Exactly the right amount of space # Exactly the right amount of space
buf2 = bytearray(len(expanded_data)) buf2 = bytearray(len(expanded_data))
...@@ -58,19 +59,19 @@ def test_decompress_into(): ...@@ -58,19 +59,19 @@ def test_decompress_into():
decompress_into(compressed_data, buf3) decompress_into(compressed_data, buf3)
# Corner case: decompress 0 bytes # Corner case: decompress 0 bytes
compressed_nothing = zlib.compress(b'') compressed_nothing = zlib.compress(b"")
buf_size_0 = bytearray(0) buf_size_0 = bytearray(0)
n_bytes_out = decompress_into(compressed_nothing, buf_size_0) n_bytes_out = decompress_into(compressed_nothing, buf_size_0)
assert n_bytes_out == 0 assert n_bytes_out == 0
def test_decompress_into_err(): def test_decompress_into_err():
expanded_data = b'abcde' * 5000 expanded_data = b"abcde" * 5000
compressed_data = zlib.compress(expanded_data) compressed_data = zlib.compress(expanded_data)
buf = bytearray(len(expanded_data) + 10) buf = bytearray(len(expanded_data) + 10)
with pytest.raises(BufferError): with pytest.raises(BufferError):
compress_into(memoryview(compressed_data)[::2], buf) # Input not contiguous compress_into(memoryview(compressed_data)[::2], buf) # Input not contiguous
with pytest.raises(TypeError): with pytest.raises(TypeError): # Output not writable
compress_into(compressed_data, memoryview(buf).toreadonly()) # Output not writable compress_into(compressed_data, memoryview(buf).toreadonly())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment