]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45400: Fix suggestion test of test_exceptions (GH-28783)
authorVictor Stinner <vstinner@python.org>
Thu, 7 Oct 2021 11:47:23 +0000 (13:47 +0200)
committerGitHub <noreply@github.com>
Thu, 7 Oct 2021 11:47:23 +0000 (13:47 +0200)
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.

Lib/test/test_exceptions.py
Misc/NEWS.d/next/Tests/2021-10-07-13-11-45.bpo-45400.h3iT7V.rst [new file with mode: 0644]

index 289288478c285ae16d1ce81f0d35a47fa8ef522e..85dc3c0f22081d32fc4b16f26ff16bd5acb8609e 100644 (file)
@@ -1840,7 +1840,7 @@ class NameErrorTests(unittest.TestCase):
             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 (file)
index 0000000..61b6653
--- /dev/null
@@ -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.