Skip to content

Commit 6551a91

Browse files
d-v-bclaude
andcommitted
test(codecs): collapse blosc JSON roundtrip tests into one parametrize
Replace the cname/shuffle JSON-roundtrip pair with a single parametrized test driven by [("cname", v) for v in BLOSC_CNAME] + [("shuffle", v) for v in BLOSC_SHUFFLE]. They asserted the same property (to_dict / from_dict preserves every literal) on two independent axes, so a single test covers both with clear per-case IDs (e.g. cname-lz4, shuffle-bitshuffle). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 33a2023 commit 6551a91

1 file changed

Lines changed: 18 additions & 21 deletions

File tree

tests/test_codecs/test_blosc.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -181,32 +181,29 @@ def test_blosc_codec_accepts_all_shuffles(shuffle: BloscShuffleLiteral) -> None:
181181
assert codec.shuffle == shuffle
182182

183183

184-
@pytest.mark.parametrize("cname", BLOSC_CNAME)
185-
def test_blosc_codec_json_roundtrip_all_cnames(cname: BloscCnameLiteral) -> None:
186-
"""
187-
JSON serialization (to_dict / from_dict) preserves every cname. Guards
188-
against drift in the codec's V3 JSON form for any compressor option.
189-
190-
The non-cname fields are fully specified so the codec has no tunable
191-
attributes; tunability is not part of the JSON form and would otherwise
192-
cause spurious round-trip mismatches.
193-
"""
194-
codec = BloscCodec(typesize=1, cname=cname, clevel=5, shuffle="shuffle", blocksize=0)
195-
restored = BloscCodec.from_dict(codec.to_dict())
196-
assert restored == codec
197-
198-
199-
@pytest.mark.parametrize("shuffle", BLOSC_SHUFFLE)
200-
def test_blosc_codec_json_roundtrip_all_shuffles(shuffle: BloscShuffleLiteral) -> None:
184+
@pytest.mark.parametrize(
185+
("param", "value"),
186+
[("cname", v) for v in BLOSC_CNAME] + [("shuffle", v) for v in BLOSC_SHUFFLE],
187+
)
188+
def test_blosc_codec_json_roundtrip(param: str, value: str) -> None:
201189
"""
202-
JSON serialization (to_dict / from_dict) preserves every shuffle mode.
203-
Guards against drift in the codec's V3 JSON form for any shuffle option.
190+
JSON serialization (to_dict / from_dict) preserves every value in
191+
BLOSC_CNAME and BLOSC_SHUFFLE. Guards against drift in the codec's V3
192+
JSON form for any compressor or shuffle option.
204193
205-
The non-shuffle fields are fully specified so the codec has no tunable
194+
The non-varied fields are fully specified so the codec has no tunable
206195
attributes; tunability is not part of the JSON form and would otherwise
207196
cause spurious round-trip mismatches.
208197
"""
209-
codec = BloscCodec(typesize=1, cname="zstd", clevel=5, shuffle=shuffle, blocksize=0)
198+
kwargs: dict[str, Any] = {
199+
"typesize": 1,
200+
"cname": "zstd",
201+
"clevel": 5,
202+
"shuffle": "shuffle",
203+
"blocksize": 0,
204+
param: value,
205+
}
206+
codec = BloscCodec(**kwargs)
210207
restored = BloscCodec.from_dict(codec.to_dict())
211208
assert restored == codec
212209

0 commit comments

Comments
 (0)