Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche authored Oct 2, 2022
1 parent 3b75043 commit 0abbf27
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class Test:
assert repr(exc.value.exceptions[0]) == repr(
ValueError("invalid literal for int() with base 10: 'a'")
)
assert exc.value.exceptions[0].__notes__ == (
"Structuring class test_class_validation.<locals>.Test @ attribute a",
)
assert exc.value.exceptions[0].__notes__ == [
"Structuring class test_class_validation.<locals>.Test @ attribute a"
]

assert repr(exc.value.exceptions[1]) == repr(KeyError("c"))
assert exc.value.exceptions[1].__notes__ == (
"Structuring class test_class_validation.<locals>.Test @ attribute c",
)
assert exc.value.exceptions[1].__notes__ == [
"Structuring class test_class_validation.<locals>.Test @ attribute c"
]


def test_external_class_validation():
Expand Down Expand Up @@ -64,16 +64,16 @@ def test_list_validation():
assert repr(exc.value.exceptions[0]) == repr(
ValueError("invalid literal for int() with base 10: 'a'")
)
assert exc.value.exceptions[0].__notes__ == (
"Structuring typing.List[int] @ index 2",
)
assert exc.value.exceptions[0].__notes__ == [
"Structuring typing.List[int] @ index 2"
]

assert repr(exc.value.exceptions[1]) == repr(
ValueError("invalid literal for int() with base 10: 'c'")
)
assert exc.value.exceptions[1].__notes__ == (
"Structuring typing.List[int] @ index 4",
)
assert exc.value.exceptions[1].__notes__ == [
"Structuring typing.List[int] @ index 4"
]


@given(...)
Expand All @@ -88,16 +88,16 @@ def test_mapping_validation(detailed_validation: bool):
assert repr(exc.value.exceptions[0]) == repr(
ValueError("invalid literal for int() with base 10: 'b'")
)
assert exc.value.exceptions[0].__notes__ == (
"Structuring mapping value @ key '2'",
)
assert exc.value.exceptions[0].__notes__ == [
"Structuring mapping value @ key '2'"
]

assert repr(exc.value.exceptions[1]) == repr(
ValueError("invalid literal for int() with base 10: 'c'")
)
assert exc.value.exceptions[1].__notes__ == (
"Structuring mapping key @ key 'c'",
)
assert exc.value.exceptions[1].__notes__ == [
"Structuring mapping key @ key 'c'"
]
else:
with pytest.raises(ValueError):
c.structure({"1": 1, "2": "b", "c": 3}, Dict[int, int])
Expand All @@ -115,9 +115,9 @@ def test_counter_validation(detailed_validation: bool):
assert repr(exc.value.exceptions[0]) == repr(
ValueError("invalid literal for int() with base 10: 'b'")
)
assert exc.value.exceptions[0].__notes__ == (
"Structuring mapping value @ key 'b'",
)
assert exc.value.exceptions[0].__notes__ == [
"Structuring mapping value @ key 'b'"
]

else:
with pytest.raises(ValueError):
Expand All @@ -134,7 +134,7 @@ def test_set_validation():
assert repr(exc.value.exceptions[0]) == repr(
ValueError("invalid literal for int() with base 10: 'a'")
)
assert exc.value.exceptions[0].__notes__ == ("Structuring set @ element 'a'",)
assert exc.value.exceptions[0].__notes__ == ["Structuring set @ element 'a'"]


def test_frozenset_validation():
Expand All @@ -147,7 +147,7 @@ def test_frozenset_validation():
assert repr(exc.value.exceptions[0]) == repr(
ValueError("invalid literal for int() with base 10: 'a'")
)
assert exc.value.exceptions[0].__notes__ == ("Structuring frozenset @ element 'a'",)
assert exc.value.exceptions[0].__notes__ == ["Structuring frozenset @ element 'a'"]


def test_homo_tuple_validation():
Expand All @@ -160,9 +160,9 @@ def test_homo_tuple_validation():
assert repr(exc.value.exceptions[0]) == repr(
ValueError("invalid literal for int() with base 10: 'a'")
)
assert exc.value.exceptions[0].__notes__ == (
"Structuring typing.Tuple[int, ...] @ index 2",
)
assert exc.value.exceptions[0].__notes__ == [
"Structuring typing.Tuple[int, ...] @ index 2"
]


def test_hetero_tuple_validation():
Expand All @@ -175,6 +175,6 @@ def test_hetero_tuple_validation():
assert repr(exc.value.exceptions[0]) == repr(
ValueError("invalid literal for int() with base 10: 'a'")
)
assert exc.value.exceptions[0].__notes__ == (
"Structuring typing.Tuple[int, int, int] @ index 2",
)
assert exc.value.exceptions[0].__notes__ == [
"Structuring typing.Tuple[int, int, int] @ index 2"
]

0 comments on commit 0abbf27

Please sign in to comment.