diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 289288478c285a..075b1c41ff3d7f 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -1840,7 +1840,13 @@ def f(): with support.captured_stderr() as err: sys.__excepthook__(*sys.exc_info()) - self.assertNotIn("a1", err.getvalue()) + traceback = err.getvalue() + + # remvoe the source path from the traceback, it could contain "a1" in it + # https://bugs.python.org/issue45400 + traceback = traceback.replace(__file__, os.path.basename(__file__)) + + self.assertNotIn("a1", traceback) def test_name_error_with_custom_exceptions(self): def f(): diff --git a/Misc/NEWS.d/next/Tests/2021-10-07-13-17-42.bpo-45400.oHgprZ.rst b/Misc/NEWS.d/next/Tests/2021-10-07-13-17-42.bpo-45400.oHgprZ.rst new file mode 100644 index 00000000000000..ac586d7a0050ac --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2021-10-07-13-17-42.bpo-45400.oHgprZ.rst @@ -0,0 +1,4 @@ +The ``test_name_error_suggestions_do_not_trigger_for_too_many_locals`` will +no longer fail when run from a directory that contains ``a1`` in the path, +which is likely to happen when building from unpacked sources of a first +alpha release.