Skip to content
Prev Previous commit
Next Next commit
python 3.11 fixes: native support for un-stringable exceptions
  • Loading branch information
asottile authored and nicoddemus committed Feb 11, 2022
commit 286a2bcadb75839caaffe53e8d98a607fb58233f
14 changes: 10 additions & 4 deletions testing/test_assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ def test_raise_assertion_error():
)


def test_raise_assertion_error_raisin_repr(pytester: Pytester) -> None:
def test_raise_assertion_error_raising_repr(pytester: Pytester) -> None:
pytester.makepyfile(
"""
class RaisingRepr(object):
Expand All @@ -1659,9 +1659,15 @@ def test_raising_repr():
"""
)
result = pytester.runpytest()
result.stdout.fnmatch_lines(
["E AssertionError: <unprintable AssertionError object>"]
)
if sys.version_info >= (3, 11):
# python 3.11 has native support for un-str-able exceptions
result.stdout.fnmatch_lines(
["E AssertionError: <exception str() failed>"]
)
else:
result.stdout.fnmatch_lines(
["E AssertionError: <unprintable AssertionError object>"]
)


def test_issue_1944(pytester: Pytester) -> None:
Expand Down