From 2858881961ae0c39a47dc4f3ae474f25cf1050e1 Mon Sep 17 00:00:00 2001 From: nineteendo Date: Tue, 9 Apr 2024 11:15:45 +0200 Subject: [PATCH 1/2] Truncate extremely long error message Co-authored-by: Alex Waygood --- Lib/test/test_exceptions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 36fd89dbb8896c..000337d08fa54d 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -1451,7 +1451,8 @@ def test_recursion_normalizing_infinite_exception(self): """ rc, out, err = script_helper.assert_python_failure("-c", code) self.assertEqual(rc, 1) - self.assertIn(b'RecursionError: maximum recursion depth exceeded', err) + expected = b'RecursionError: maximum recursion depth exceeded' + self.assertTrue(expected in err, msg=f"{expected} not found in {err[:3_000]!r}... (truncated)") self.assertIn(b'Done.', out) From cc28896615a6f5d7792594b3901de7fad5b533c1 Mon Sep 17 00:00:00 2001 From: nineteendo Date: Tue, 9 Apr 2024 11:26:51 +0200 Subject: [PATCH 2/2] Fix BytesWarning --- Lib/test/test_exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 000337d08fa54d..1224f143b5441f 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -1452,7 +1452,7 @@ def test_recursion_normalizing_infinite_exception(self): rc, out, err = script_helper.assert_python_failure("-c", code) self.assertEqual(rc, 1) expected = b'RecursionError: maximum recursion depth exceeded' - self.assertTrue(expected in err, msg=f"{expected} not found in {err[:3_000]!r}... (truncated)") + self.assertTrue(expected in err, msg=f"{expected!r} not found in {err[:3_000]!r}... (truncated)") self.assertIn(b'Done.', out)