Skip to content

Commit 53f2096

Browse files
Temporary: skip tests that require crc32c
1 parent 0638a91 commit 53f2096

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

numcodecs/tests/test_checksum32.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@
33
import numpy as np
44
import pytest
55

6-
from numcodecs.checksum32 import CRC32, CRC32C, Adler32
6+
from numcodecs.checksum32 import CRC32, Adler32
7+
8+
# Try to import CRC32C, skip entire module if not available
9+
# This is a temporary skip until we update the crc32c package
10+
# in Pyodide and make a release.
11+
try:
12+
import crc32c # noqa: F401, I001
13+
from numcodecs.checksum32 import CRC32C
14+
15+
HAS_CRC32C = True
16+
except ImportError: # pragma: no cover
17+
HAS_CRC32C = False
18+
719
from numcodecs.tests.common import (
820
check_backwards_compatibility,
921
check_config,
@@ -32,15 +44,23 @@
3244
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[m]'),
3345
]
3446

47+
# Initialize base codecs
3548
codecs = [
3649
CRC32(),
3750
CRC32(location="end"),
38-
CRC32C(location="start"),
39-
CRC32C(),
4051
Adler32(),
4152
Adler32(location="end"),
4253
]
4354

55+
# Add CRC32C codecs if available
56+
if HAS_CRC32C:
57+
codecs.extend(
58+
[
59+
CRC32C(location="start"),
60+
CRC32C(),
61+
]
62+
)
63+
4464

4565
@pytest.mark.parametrize(("codec", "arr"), itertools.product(codecs, arrays))
4666
def test_encode_decode(codec, arr):
@@ -84,25 +104,28 @@ def test_err_encode_list(codec):
84104
def test_err_location():
85105
with pytest.raises(ValueError):
86106
CRC32(location="foo")
87-
with pytest.raises(ValueError):
88-
CRC32C(location="foo")
89107
with pytest.raises(ValueError):
90108
Adler32(location="foo")
109+
if HAS_CRC32C:
110+
with pytest.raises(ValueError):
111+
CRC32C(location="foo")
91112

92113

93114
def test_repr():
94115
check_repr("CRC32(location='start')")
95-
check_repr("CRC32C(location='start')")
96116
check_repr("Adler32(location='start')")
97117
check_repr("CRC32(location='end')")
98-
check_repr("CRC32C(location='end')")
99118
check_repr("Adler32(location='end')")
119+
if HAS_CRC32C:
120+
check_repr("CRC32C(location='start')")
121+
check_repr("CRC32C(location='end')")
100122

101123

102124
def test_backwards_compatibility():
103125
check_backwards_compatibility(CRC32.codec_id, arrays, [CRC32()])
104126
check_backwards_compatibility(Adler32.codec_id, arrays, [Adler32()])
105-
check_backwards_compatibility(CRC32C.codec_id, arrays, [CRC32C()])
127+
if HAS_CRC32C:
128+
check_backwards_compatibility(CRC32C.codec_id, arrays, [CRC32C()])
106129

107130

108131
@pytest.mark.parametrize("codec", codecs)
@@ -123,6 +146,7 @@ def test_err_out_too_small(codec):
123146
codec.decode(codec.encode(arr), out)
124147

125148

149+
@pytest.mark.skipif(not HAS_CRC32C, reason="CRC32C not available")
126150
def test_crc32c_checksum():
127151
arr = np.arange(0, 64, dtype="uint8")
128152
buf = CRC32C(location="end").encode(arr)

0 commit comments

Comments
 (0)