Skip to content

Commit

Permalink
Fixup: test no numpy installed works as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
milesgranger committed May 16, 2021
1 parent 0f6274e commit 403f0be
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ jobs:
pip install cramjam --no-index --find-links dist --force-reinstall
pip install -r dev-requirements.txt
make test
- name: Test no numpy installed works
run: |
pip uninstall numpy -y
python -m pytest tests/test_no_numpy.py
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand Down
23 changes: 23 additions & 0 deletions tests/test_no_numpy.py
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"

0 comments on commit 403f0be

Please sign in to comment.