python 3.11 fixes: native support for un-stringable exceptions

This commit is contained in:
Anthony Sottile 2022-01-23 13:55:48 -05:00 committed by Bruno Oliveira
parent 43d54c8b42
commit 286a2bcadb
1 changed files with 10 additions and 4 deletions

View File

@ -1648,7 +1648,7 @@ def test_raise_unprintable_assertion_error(pytester: Pytester) -> None:
)
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):
@ -1659,9 +1659,15 @@ def test_raise_assertion_error_raisin_repr(pytester: Pytester) -> None:
"""
)
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: