2Tests for `javascript_data_files.decoder`.
7from javascript_data_files.decoder import decode_from_json
10@pytest.mark.parametrize(
13 '{ "sides": 3, "sides": 4 }',
14 '{ "sides": 3, "colour": "blue", "sides": 4 }',
15 '[{ "nested": { "sides": 3, "sides": 4 } }]',
18def test_object_with_duplicate_names_is_rejected(json_string: str) -> None:
20 Trying to decode a JavaScript string which includes an object
21 with duplicate names throws a ValueError.
23 with pytest.raises(ValueError, match="Found duplicate name in JSON object: sides"):
24 decode_from_json(json_string)
27def test_object_with_multiple_duplicate_names_is_rejected() -> None:
29 Trying to decode a JavaScript string which includes an object
30 with multiple duplicate names throws a ValueError.
32 with pytest.raises(ValueError, match="Found duplicate names in JSON object:"):
34 '{ "sides": 3, "colour": "blue", "sides": 4, "colour": "red" }'