[Python-checkins] bpo-45745: Remove regrtest --findleaks options (GH-29514)

vstinner webhook-mailer at python.org
Fri Nov 12 10:19:24 EST 2021


https://github.com/python/cpython/commit/9d3271438431c37c29c359f5b73e8094b5f82912
commit: 9d3271438431c37c29c359f5b73e8094b5f82912
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2021-11-12T16:19:09+01:00
summary:

bpo-45745: Remove regrtest --findleaks options (GH-29514)

Remove the --findleaks command line option of regrtest: use the
--fail-env-changed option instead. Since Python 3.7, it was a
deprecated alias to the --fail-env-changed option.

files:
A Misc/NEWS.d/next/Tests/2021-11-10-12-01-28.bpo-45745.wX5B3K.rst
M Lib/test/libregrtest/cmdline.py
M Lib/test/libregrtest/main.py
M Lib/test/libregrtest/runtest.py
M Lib/test/test_regrtest.py

diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py
index 6e6ff1201d81c..11fa0f940bb71 100644
--- a/Lib/test/libregrtest/cmdline.py
+++ b/Lib/test/libregrtest/cmdline.py
@@ -149,7 +149,6 @@ def __init__(self, **kwargs) -> None:
         self.single = False
         self.randomize = False
         self.fromfile = None
-        self.findleaks = 1
         self.fail_env_changed = False
         self.use_resources = None
         self.trace = False
@@ -266,9 +265,6 @@ def _create_parser():
                             '(instead of the Python stdlib test suite)')
 
     group = parser.add_argument_group('Special runs')
-    group.add_argument('-l', '--findleaks', action='store_const', const=2,
-                       default=1,
-                       help='deprecated alias to --fail-env-changed')
     group.add_argument('-L', '--runleaks', action='store_true',
                        help='run the leaks(1) command just before exit.' +
                             more_details)
@@ -370,9 +366,6 @@ def _parse_args(args, **kwargs):
             parser.error("unrecognized arguments: %s" % arg)
             sys.exit(1)
 
-    if ns.findleaks > 1:
-        # --findleaks implies --fail-env-changed
-        ns.fail_env_changed = True
     if ns.single and ns.fromfile:
         parser.error("-s and -f don't go together!")
     if ns.use_mp is not None and ns.trace:
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 52cc065da115d..fc3c2b9692055 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -46,7 +46,7 @@ class Regrtest:
     files beginning with test_ will be used.
 
     The other default arguments (verbose, quiet, exclude,
-    single, randomize, findleaks, use_resources, trace, coverdir,
+    single, randomize, use_resources, trace, coverdir,
     print_slow, and random_seed) allow programmers calling main()
     directly to set the values that would normally be set by flags
     on the command line.
diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py
index 23970410a28fb..83c5f249841cc 100644
--- a/Lib/test/libregrtest/runtest.py
+++ b/Lib/test/libregrtest/runtest.py
@@ -138,7 +138,7 @@ def __str__(self) -> str:
 NOTTESTS = set()
 
 
-# used by --findleaks, store for gc.garbage
+# Storage of uncollectable objects
 FOUND_GARBAGE = []
 
 
@@ -279,7 +279,7 @@ def save_env(ns: Namespace, test_name: str):
 
 def _runtest_inner2(ns: Namespace, test_name: str) -> bool:
     # Load the test function, run the test function, handle huntrleaks
-    # and findleaks to detect leaks
+    # to detect leaks.
 
     abstest = get_abs_module(ns, test_name)
 
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index dcc795de1a4b6..08e2c87e15c4d 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -1178,7 +1178,7 @@ def test_other_bug(self):
                                   no_test_ran=[testname])
 
     @support.cpython_only
-    def test_findleaks(self):
+    def test_uncollectable(self):
         code = textwrap.dedent(r"""
             import _testcapi
             import gc
@@ -1203,12 +1203,6 @@ def test_garbage(self):
                                   env_changed=[testname],
                                   fail_env_changed=True)
 
-        # --findleaks is now basically an alias to --fail-env-changed
-        output = self.run_tests("--findleaks", testname, exitcode=3)
-        self.check_executed_tests(output, [testname],
-                                  env_changed=[testname],
-                                  fail_env_changed=True)
-
     def test_multiprocessing_timeout(self):
         code = textwrap.dedent(r"""
             import time
diff --git a/Misc/NEWS.d/next/Tests/2021-11-10-12-01-28.bpo-45745.wX5B3K.rst b/Misc/NEWS.d/next/Tests/2021-11-10-12-01-28.bpo-45745.wX5B3K.rst
new file mode 100644
index 0000000000000..c3ef6800a0353
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2021-11-10-12-01-28.bpo-45745.wX5B3K.rst
@@ -0,0 +1,3 @@
+Remove the ``--findleaks`` command line option of regrtest: use the
+``--fail-env-changed`` option instead. Since Python 3.7, it was a deprecated
+alias to the ``--fail-env-changed`` option.



More information about the Python-checkins mailing list