Skip to content

Commit e37d84c

Browse files
committed
python 3.11 fixes: native support for un-stringable exceptions
1 parent b7b3a53 commit e37d84c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

testing/test_assertion.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ def test_raise_assertion_error():
16481648
)
16491649

16501650

1651-
def test_raise_assertion_error_raisin_repr(pytester: Pytester) -> None:
1651+
def test_raise_assertion_error_raising_repr(pytester: Pytester) -> None:
16521652
pytester.makepyfile(
16531653
"""
16541654
class RaisingRepr(object):
@@ -1659,9 +1659,15 @@ def test_raising_repr():
16591659
"""
16601660
)
16611661
result = pytester.runpytest()
1662-
result.stdout.fnmatch_lines(
1663-
["E AssertionError: <unprintable AssertionError object>"]
1664-
)
1662+
if sys.version_info >= (3, 11):
1663+
# python 3.11 has native support for un-str-able exceptions
1664+
result.stdout.fnmatch_lines(
1665+
["E AssertionError: <exception str() failed>"]
1666+
)
1667+
else:
1668+
result.stdout.fnmatch_lines(
1669+
["E AssertionError: <unprintable AssertionError object>"]
1670+
)
16651671

16661672

16671673
def test_issue_1944(pytester: Pytester) -> None:

0 commit comments

Comments
 (0)