Skip to content

Commit

Permalink
refactor: expand tests around arrays and tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Nov 3, 2021
1 parent d042801 commit 8df27d1
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions bindings/python/tests-py/test_jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,26 @@ def test_from_str_error():
JSONSchema.from_str(42)


def test_tuple():
schema = {"properties": {"foo": {"type": "array"}}}
instance = {"foo": (1, 2, 3)}
assert is_valid(instance, schema) == True
@pytest.mark.parametrize(
"val",
(
("A", "B", "C"),
["A", "B", "C"],
),
)
def test_array_tuple(val):
schema = {"type": "array", "items": {"type": "string"}}
validate(schema, val)


@pytest.mark.parametrize(
"val",
((1, 2, 3), [1, 2, 3], {"foo": 1}),
)
def test_array_tuple_invalid(val):
schema = {"type": "array", "items": {"type": "string"}}
with pytest.raises(ValueError):
validate(schema, val)


def test_recursive_dict():
Expand Down

0 comments on commit 8df27d1

Please sign in to comment.