Skip to content
This repository has been archived by the owner on Nov 2, 2022. It is now read-only.

Commit

Permalink
Add more unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Schindler committed Sep 7, 2020
1 parent ba7e87a commit c5ec907
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions exceptiongroup/_tests/test_exceptiongroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def test_exception_group_init_when_exceptions_messages_not_equal():


def test_exception_group_bool():
assert not ExceptionGroup("E", [], [])
assert ExceptionGroup("E", [ValueError()], [""])
assert bool(ExceptionGroup("E", [], [])) is False
assert bool(ExceptionGroup("E", [ValueError()], [""])) is True


def test_exception_group_contains():
Expand Down Expand Up @@ -89,6 +89,37 @@ def test_exception_group_len():
assert len(ExceptionGroup("E", [ValueError()], [""])) == 1


def test_exception_group_maybe_reraise_empty():
group = ExceptionGroup("E", [], [])
group.maybe_reraise()


def test_exception_group_maybe_reraise_unwrap():
err = ValueError()
group = ExceptionGroup("E", [err], [""])
try:
group.maybe_reraise()
except ValueError as caught_err:
assert caught_err is err
try:
group.maybe_reraise(unwrap=False)
except ExceptionGroup as caught_err:
assert caught_err is group


def test_exception_group_maybe_reraise_from_exception():
err = ValueError()
try:
raise_group()
except ExceptionGroup as group1:
group2 = ExceptionGroup("E", [err], [""])
try:
group2.maybe_reraise()
except ValueError as caught_err:
assert caught_err is err
assert caught_err.__cause__ is group1


def test_exception_group_str():
memberA = ValueError("memberA")
memberB = ValueError("memberB")
Expand Down

0 comments on commit c5ec907

Please sign in to comment.