| 
10 | 10 | from zarr.codecs.bytes import BytesCodec  | 
11 | 11 | from zarr.core.buffer import default_buffer_prototype  | 
12 | 12 | from zarr.core.chunk_key_encodings import DefaultChunkKeyEncoding, V2ChunkKeyEncoding  | 
 | 13 | +from zarr.core.config import config  | 
13 | 14 | from zarr.core.group import parse_node_type, GroupMetadata  | 
14 | 15 | from zarr.core.metadata.v3 import (  | 
15 | 16 |     ArrayV3Metadata,  | 
@@ -304,17 +305,19 @@ def test_metadata_to_dict(  | 
304 | 305 |     assert observed == expected  | 
305 | 306 | 
 
  | 
306 | 307 | 
 
  | 
307 |  | -def test_json_indent():  | 
308 |  | -    m = GroupMetadata()  | 
309 |  | -    d = m.to_buffer_dict(default_buffer_prototype())["zarr.json"].to_bytes()  | 
310 |  | -    class TestIndentEncoder(json.JSONEncoder):  | 
311 |  | -        def __init__(self, *args: Any, **kwargs: Any) -> None:  | 
312 |  | -            super().__init__(*args, **kwargs)  | 
313 |  | -            self.indent = 2  | 
 | 308 | +@pytest.mark.parametrize('indent', (2, 4))  | 
 | 309 | +def test_json_indent(indent: int):  | 
 | 310 | +    with config.set({"json_indent": indent}):  | 
 | 311 | +        m = GroupMetadata()  | 
 | 312 | +        d = m.to_buffer_dict(default_buffer_prototype())["zarr.json"].to_bytes()  | 
 | 313 | +        class TestIndentEncoder(json.JSONEncoder):  | 
 | 314 | +            def __init__(self, *args: Any, **kwargs: Any) -> None:  | 
 | 315 | +                super().__init__(*args, **kwargs)  | 
 | 316 | +                self.indent = indent  | 
314 | 317 | 
 
  | 
315 |  | -    # expected has extra ' ' on each line compared with json.dumps( indent=2)  | 
316 |  | -    expected = json.dumps(json.loads(d), cls=TestIndentEncoder).encode()  | 
317 |  | -    assert d == expected  | 
 | 318 | +        # expected has extra ' ' on each line compared with json.dumps( indent=2)  | 
 | 319 | +        expected = json.dumps(json.loads(d), cls=TestIndentEncoder).encode()  | 
 | 320 | +        assert d == expected  | 
318 | 321 | 
 
  | 
319 | 322 | 
 
  | 
320 | 323 | # @pytest.mark.parametrize("fill_value", [-1, 0, 1, 2932897])  | 
 | 
0 commit comments