-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conversion of input is evaluated in order of variants declared in `BytesType`. If numpy is not installed, it would error that numpy was not installed if the input was a Buffer b/c Buffer was evaluated after a potential numpy input. The patch fixes this behavior by moving the numpy variant as the last variant evaluated. Thus wiill only raise an error if it's a numpy input/output and numpy is not installed.
- Loading branch information
1 parent
a15fda8
commit 4042d45
Showing
4 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pytest | ||
import cramjam | ||
|
||
|
||
@pytest.mark.parametrize("obj", (bytes, bytearray, cramjam.Buffer, cramjam.File)) | ||
@pytest.mark.parametrize( | ||
"variant_str", ("snappy", "brotli", "lz4", "gzip", "deflate", "zstd") | ||
) | ||
def test_no_numpy_installed(tmpdir, obj, variant_str): | ||
""" | ||
These operations should work even when numpy is not installed | ||
""" | ||
if cramjam.File == obj: | ||
data = obj(str(tmpdir.join("tmp.txt"))) | ||
data.write(b"data") | ||
data.seek(0) | ||
else: | ||
data = obj(b"data") | ||
|
||
variant = getattr(cramjam, variant_str) | ||
compressed = variant.compress(data) | ||
decompressed = variant.decompress(compressed) | ||
assert decompressed.read() == b"data" |