mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Implementing an idea from Guido on the checkins list:
When regrtest.py finds an attribute "test_main" in a test it imports, regrtest runs the test's test_main after the import. test_threaded_import needs this else the cross-thread import lock prevents it from making progress. Other tests can use this hack too, but I doubt it will ever be popular.
This commit is contained in:
parent
bc5619826e
commit
d97422115e
2 changed files with 25 additions and 24 deletions
|
|
@ -244,7 +244,14 @@ def runtest(test, generate, verbose, quiet, testdir = None):
|
|||
if cfp:
|
||||
sys.stdout = cfp
|
||||
print test # Output file starts with test name
|
||||
__import__(test, globals(), locals(), [])
|
||||
the_module = __import__(test, globals(), locals(), [])
|
||||
# Most tests run to completion simply as a side-effect of
|
||||
# being imported. For the benefit of tests that can't run
|
||||
# that way (like test_threaded_import), explicitly invoke
|
||||
# their test_main() function (if it exists).
|
||||
indirect_test = getattr(the_module, "test_main", None)
|
||||
if indirect_test is not None:
|
||||
indirect_test()
|
||||
if cfp and not (generate or verbose):
|
||||
cfp.close()
|
||||
finally:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue