mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
[3.12] gh-89392: Remove support of test_main() in libregrtest (GH-108876) (#108897)
[3.12] gh-89392: Remove support of test_main() in libregrtest (GH-108876).
(cherry picked from commit 04a0830b00
)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
8c551a7f2a
commit
5121faabd1
3 changed files with 10 additions and 9 deletions
|
@ -345,10 +345,9 @@ def _load_run_test(result: TestResult, ns: Namespace) -> None:
|
||||||
|
|
||||||
the_module = importlib.import_module(abstest)
|
the_module = importlib.import_module(abstest)
|
||||||
|
|
||||||
# If the test has a test_main, that will run the appropriate
|
if hasattr(the_module, "test_main"):
|
||||||
# tests. If not, use normal unittest test loading.
|
# https://github.com/python/cpython/issues/89392
|
||||||
test_func = getattr(the_module, "test_main", None)
|
raise Exception(f"Module {result.test_name} defines test_main() which is no longer supported by regrtest")
|
||||||
if test_func is None:
|
|
||||||
test_func = functools.partial(_test_module, the_module)
|
test_func = functools.partial(_test_module, the_module)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1678,9 +1678,9 @@ class ArgsTestCase(BaseTestCase):
|
||||||
7948648
|
7948648
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test_main():
|
def load_tests(loader, tests, pattern):
|
||||||
testmod = sys.modules[__name__]
|
tests.addTest(doctest.DocTestSuite())
|
||||||
return support.run_doctest(testmod)
|
return tests
|
||||||
''')
|
''')
|
||||||
testname = self.create_test(code=code)
|
testname = self.create_test(code=code)
|
||||||
|
|
||||||
|
@ -1689,7 +1689,7 @@ class ArgsTestCase(BaseTestCase):
|
||||||
self.check_executed_tests(output, [testname],
|
self.check_executed_tests(output, [testname],
|
||||||
failed=[testname],
|
failed=[testname],
|
||||||
randomize=True,
|
randomize=True,
|
||||||
stats=TestStats(3, 2, 0))
|
stats=TestStats(1, 1, 0))
|
||||||
|
|
||||||
|
|
||||||
class TestUtils(unittest.TestCase):
|
class TestUtils(unittest.TestCase):
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Removed support of ``test_main()`` function in tests. They now always use
|
||||||
|
normal unittest test runner.
|
Loading…
Add table
Add a link
Reference in a new issue