FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.12] gh-89392: Remove support of test_main() in libregrtest (GH-108876) by serhiy-storchaka · Pull Request #108897 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 4 additions & 5 deletions Lib/test/libregrtest/runtest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,10 @@ def _load_run_test(result: TestResult, ns: Namespace) -> None:

the_module = importlib.import_module(abstest)

# If the test has a test_main, that will run the appropriate
# tests. If not, use normal unittest test loading.
test_func = getattr(the_module, "test_main", None)
if test_func is None:
test_func = functools.partial(_test_module, the_module)
if hasattr(the_module, "test_main"):
# https://github.com/python/cpython/issues/89392
raise Exception(f"Module {result.test_name} defines test_main() which is no longer supported by regrtest")
test_func = functools.partial(_test_module, the_module)

try:
with save_env(ns, result.test_name):
Expand Down
8 changes: 4 additions & 4 deletions Lib/test/test_regrtest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1678,9 +1678,9 @@ def my_function():
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)

Expand All @@ -1689,7 +1689,7 @@ def test_main():
self.check_executed_tests(output, [testname],
failed=[testname],
randomize=True,
stats=TestStats(3, 2, 0))
stats=TestStats(1, 1, 0))


class TestUtils(unittest.TestCase):
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed support of ``test_main()`` function in tests. They now always use
normal unittest test runner.

Back | FazBrowse Home | New Git URL