File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed
Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ def check_json_v2(data: object) -> TypeGuard[Crc32cJSON_V2]:
4444
4545
4646def check_json_v3 (data : object ) -> TypeGuard [Crc32cJSON_V3 ]:
47+ if data == "crc32c" :
48+ return True
4749 return (
4850 isinstance (data , Mapping )
4951 and set (data .keys ()) in ({"name" , "configuration" }, {"name" })
Original file line number Diff line number Diff line change @@ -23,16 +23,24 @@ class BaseTestCodec:
2323 """
2424
2525 test_cls : type [Codec ]
26- valid_json_v2 : ClassVar [tuple [CodecJSON_V2 , ...]]
27- valid_json_v3 : ClassVar [tuple [CodecJSON_V3 , ...]]
28-
29- def test_from_json_roundtrip_v2 (self , valid_json_v2 : CodecJSON_V2 ) -> None :
26+ valid_json_v2 : ClassVar [tuple [CodecJSON_V2 | object , ...]]
27+ valid_json_v3 : ClassVar [tuple [CodecJSON_V3 | object , ...]]
28+
29+ def test_from_json_v2 (self , valid_json_v2 : CodecJSON_V2 ) -> None :
30+ """
31+ Test that the codec generated from valid JSON generates a JSON representation that generates
32+ the same codec
33+ """
3034 codec = self .test_cls .from_json (valid_json_v2 )
31- assert codec .to_json (zarr_format = 2 ) == valid_json_v2
35+ assert codec .from_json ( codec . to_json (zarr_format = 2 )) == codec
3236
33- def test_from_json_roundtrip_v3 (self , valid_json_v3 : CodecJSON_V3 ) -> None :
37+ def test_from_json_v3 (self , valid_json_v3 : CodecJSON_V3 ) -> None :
38+ """
39+ Test that the codec generated from valid JSON generates a JSON representation that generates
40+ the same codec
41+ """
3442 codec = self .test_cls .from_json (valid_json_v3 )
35- assert codec .to_json (zarr_format = 3 ) == valid_json_v3
43+ assert codec .from_json ( codec . to_json (zarr_format = 3 )) == codec
3644
3745
3846def pytest_generate_tests (metafunc : Any ) -> None :
Original file line number Diff line number Diff line change 3434
3535class TestCrc32cCodec (BaseTestCodec ):
3636 test_cls = Crc32cCodec
37- valid_json_v2 = ({"id" : "crc32c" },)
38- valid_json_v3 = ({"name" : "crc32c" },)
37+ valid_json_v2 = (
38+ {"id" : "crc32c" },
39+ pytest .param (
40+ {"id" : "crc32c" , "location" : "start" },
41+ marks = pytest .mark .xfail (reason = "start location not supported" ),
42+ ),
43+ {"id" : "crc32c" , "location" : "end" },
44+ )
45+ valid_json_v3 = ({"name" : "crc32c" }, "crc32c" )
3946
4047
4148class TestCrc32cCodecJSON :
You can’t perform that action at this time.
0 commit comments