From 403f0bef9388e113977478f210ee84e995a5ac21 Mon Sep 17 00:00:00 2001 From: milesgranger Date: Sun, 16 May 2021 10:09:14 +0200 Subject: [PATCH] Fixup: test no numpy installed works as expected --- .github/workflows/CI.yml | 4 ++++ tests/test_no_numpy.py | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/test_no_numpy.py diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5427405a..b9388829 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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: diff --git a/tests/test_no_numpy.py b/tests/test_no_numpy.py new file mode 100644 index 00000000..82ed9e51 --- /dev/null +++ b/tests/test_no_numpy.py @@ -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"