diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-09-05 05:36:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-05 05:36:43 (GMT) |
commit | 04a0830b00879efe057e3dfe75e9aa9c0caf1a26 (patch) | |
tree | 2219e6dbf7f6051e539d83a3ebede253a9e6f5b8 | |
parent | 1170d5a292b46f754cd29c245a040f1602f70301 (diff) | |
download | cpython-04a0830b00879efe057e3dfe75e9aa9c0caf1a26.zip cpython-04a0830b00879efe057e3dfe75e9aa9c0caf1a26.tar.gz cpython-04a0830b00879efe057e3dfe75e9aa9c0caf1a26.tar.bz2 |
gh-89392: Remove support of test_main() in libregrtest (GH-108876)
-rw-r--r-- | Lib/test/libregrtest/runtest.py | 13 | ||||
-rw-r--r-- | Lib/test/test_regrtest.py | 8 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2023-09-04-15-18-14.gh-issue-89392.8A4T5p.rst | 2 |
3 files changed, 11 insertions, 12 deletions
diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py index 6e3fab1..9cb71fb 100644 --- a/Lib/test/libregrtest/runtest.py +++ b/Lib/test/libregrtest/runtest.py @@ -440,14 +440,11 @@ def _load_run_test(result: TestResult, ns: Namespace) -> None: test_mod = importlib.import_module(module_name) - # If the test has a test_main, that will run the appropriate - # tests. If not, use normal unittest test runner. - test_main = getattr(test_mod, "test_main", None) - if test_main is not None: - test_func = test_main - else: - def test_func(): - return run_unittest(test_mod) + if hasattr(test_mod, "test_main"): + # https://github.com/python/cpython/issues/89392 + raise Exception("Module {result.test_name} defines test_main() which is no longer supported by regrtest") + def test_func(): + return run_unittest(test_mod) try: with save_env(ns, result.test_name): diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index c5fb3dc..aff5404 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -1803,9 +1803,9 @@ class ArgsTestCase(BaseTestCase): 7948648 """ - def test_main(): - testmod = sys.modules[__name__] - return support.run_doctest(testmod) + def load_tests(loader, tests, pattern): + tests.addTest(doctest.DocTestSuite()) + return tests ''') testname = self.create_test(code=code) @@ -1814,7 +1814,7 @@ class ArgsTestCase(BaseTestCase): self.check_executed_tests(output, [testname], failed=[testname], randomize=True, - stats=TestStats(4, 2, 1)) + stats=TestStats(1, 1, 0)) class TestUtils(unittest.TestCase): diff --git a/Misc/NEWS.d/next/Tests/2023-09-04-15-18-14.gh-issue-89392.8A4T5p.rst b/Misc/NEWS.d/next/Tests/2023-09-04-15-18-14.gh-issue-89392.8A4T5p.rst new file mode 100644 index 0000000..e1dea8e --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2023-09-04-15-18-14.gh-issue-89392.8A4T5p.rst @@ -0,0 +1,2 @@ +Removed support of ``test_main()`` function in tests. They now always use +normal unittest test runner. |