Skip to content

Commit

Permalink
Improve v test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Dec 1, 2024
1 parent 2fe721e commit 2f464b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_v.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

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


@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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 2f464b9

Please sign in to comment.