From 286a2bcadb75839caaffe53e8d98a607fb58233f Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 23 Jan 2022 13:55:48 -0500 Subject: [PATCH] python 3.11 fixes: native support for un-stringable exceptions --- testing/test_assertion.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/testing/test_assertion.py b/testing/test_assertion.py index ae053f137..d57cc26a3 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -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: "] - ) + if sys.version_info >= (3, 11): + # python 3.11 has native support for un-str-able exceptions + result.stdout.fnmatch_lines( + ["E AssertionError: "] + ) + else: + result.stdout.fnmatch_lines( + ["E AssertionError: "] + ) def test_issue_1944(pytester: Pytester) -> None: