From c757370143241e8f6d8135eb9100239489f1d7e3 Mon Sep 17 00:00:00 2001 From: Blayne Chard Date: Thu, 4 Nov 2021 09:26:06 +1300 Subject: [PATCH] test: validate that named tuples error --- bindings/python/tests-py/test_jsonschema.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bindings/python/tests-py/test_jsonschema.py b/bindings/python/tests-py/test_jsonschema.py index e88de863..a363ad9d 100644 --- a/bindings/python/tests-py/test_jsonschema.py +++ b/bindings/python/tests-py/test_jsonschema.py @@ -1,3 +1,4 @@ +from collections import namedtuple from contextlib import suppress from functools import partial @@ -87,6 +88,14 @@ def test_array_tuple_invalid(val): validate(schema, val) +def test_named_tuple(): + Person = namedtuple("Person", "first_name last_name") + person_a = Person("Joe", "Smith") + schema = {"type": "array", "items": {"type": "string"}} + with pytest.raises(ValueError): + validate(schema, person_a) + + def test_recursive_dict(): instance = {} instance["foo"] = instance