From 350ca7737ad7c9aa6b7c09e3f48bb18845c7483b Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 27 Jul 2022 19:51:41 +0200 Subject: [PATCH] skip format-specific tests when cattrs can't be imported --- tests/serde/test_serde.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/serde/test_serde.py b/tests/serde/test_serde.py index 4588db6f..fde0eb7b 100644 --- a/tests/serde/test_serde.py +++ b/tests/serde/test_serde.py @@ -61,6 +61,10 @@ class Foo: ids=lambda x: x["class_name"], # type: ignore ) def test_serde_all_objects(fmt: str, object_info: Dict[str, Any]) -> None: + if "fmt" in ("json", "msgpack"): + # skip these format tests if cattrs is not installed + pytest.importorskip("cattr") + klass = getattr(ufoLib2.objects, object_info["class_name"]) loads = getattr(klass, f"{fmt}_loads") obj = klass(*object_info["args"])