[Python-checkins] bpo-45400: Fix suggestion test of test_exceptions (GH-28783)

vstinner webhook-mailer at python.org
Thu Oct 7 07:47:28 EDT 2021


https://github.com/python/cpython/commit/4e605666b08b8f863cbbbdaa34bb06988e648d26
commit: 4e605666b08b8f863cbbbdaa34bb06988e648d26
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2021-10-07T13:47:23+02:00
summary:

bpo-45400: Fix suggestion test of test_exceptions (GH-28783)

Fix test_name_error_suggestions_do_not_trigger_for_too_many_locals()
of test_exceptions if a directory name contains "a1" (like
"Python-3.11.0a1"): use a stricter regular expression.

files:
A Misc/NEWS.d/next/Tests/2021-10-07-13-11-45.bpo-45400.h3iT7V.rst
M Lib/test/test_exceptions.py

diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 289288478c285..85dc3c0f22081 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -1840,7 +1840,7 @@ def f():
             with support.captured_stderr() as err:
                 sys.__excepthook__(*sys.exc_info())
 
-        self.assertNotIn("a1", err.getvalue())
+        self.assertNotRegex(err.getvalue(), r"NameError.*a1")
 
     def test_name_error_with_custom_exceptions(self):
         def f():
diff --git a/Misc/NEWS.d/next/Tests/2021-10-07-13-11-45.bpo-45400.h3iT7V.rst b/Misc/NEWS.d/next/Tests/2021-10-07-13-11-45.bpo-45400.h3iT7V.rst
new file mode 100644
index 0000000000000..61b6653320dfc
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2021-10-07-13-11-45.bpo-45400.h3iT7V.rst
@@ -0,0 +1,3 @@
+Fix test_name_error_suggestions_do_not_trigger_for_too_many_locals() of
+test_exceptions if a directory name contains "a1" (like "Python-3.11.0a1"):
+use a stricter regular expression. Patch by Victor Stinner.



More information about the Python-checkins mailing list