Skip to content

Commit

Permalink
Add exception note grouping test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Nov 24, 2024
1 parent 7010e32 commit 3fd98eb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,20 @@ class Test:

assert match.cl == exc.value.cl
assert rest.cl == exc.value.cl


def test_note_grouping():
"""Our ExceptionGroups can group their subexceptions by notes."""
exc1 = ValueError()
exc2 = KeyError()
exc3 = TypeError()

exc2.add_note(note := IterableValidationNote("Test Note", 0, int))
exc3.add_note("A string note")

exc = IterableValidationError("Test", [exc1, exc2, exc3], list[int])

with_notes, without_notes = exc.group_exceptions()

assert with_notes == [(exc2, note)]
assert without_notes == [exc1, exc3]

0 comments on commit 3fd98eb

Please sign in to comment.