From 2f464b9c60ea5ddf44c1a253d8dea029b2e1c416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Sun, 1 Dec 2024 19:26:04 +0100 Subject: [PATCH] Improve `v` test coverage --- tests/test_v.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_v.py b/tests/test_v.py index 4aa97164..d2ba3f75 100644 --- a/tests/test_v.py +++ b/tests/test_v.py @@ -15,6 +15,7 @@ from cattrs import Converter, transform_error from cattrs._compat import Mapping, TypedDict +from cattrs.errors import IterableValidationError from cattrs.gen import make_dict_structure_fn from cattrs.v import format_exception @@ -22,7 +23,7 @@ @fixture def c() -> Converter: """We need only converters with detailed_validation=True.""" - return Converter() + return Converter(detailed_validation=True) def test_attribute_errors(c: Converter) -> None: @@ -190,6 +191,11 @@ class C: "invalid value for type, expected int @ $.b[1][2]", ] + # IterableValidationErrors with subexceptions without notes + exc = IterableValidationError("Test", [TypeError("Test")], list[str]) + + assert transform_error(exc) == ["invalid type (Test) @ $"] + def test_mapping_errors(c: Converter) -> None: try: