mirror of https://github.com/python/cpython
Issue #26295: When using "python3 -m test --testdir=TESTDIR", regrtest doesn't
add "test." prefix to test module names. regrtest also prepends testdir to sys.path.
This commit is contained in:
parent
7f24a98a9a
commit
9759dd3343
|
@ -116,7 +116,7 @@ def runtest(ns, test):
|
||||||
try:
|
try:
|
||||||
sys.stdout = stream
|
sys.stdout = stream
|
||||||
sys.stderr = stream
|
sys.stderr = stream
|
||||||
result = runtest_inner(test, verbose, quiet, huntrleaks,
|
result = runtest_inner(ns, test, verbose, quiet, huntrleaks,
|
||||||
display_failure=False, pgo=pgo)
|
display_failure=False, pgo=pgo)
|
||||||
if result[0] == FAILED:
|
if result[0] == FAILED:
|
||||||
output = stream.getvalue()
|
output = stream.getvalue()
|
||||||
|
@ -127,7 +127,7 @@ def runtest(ns, test):
|
||||||
sys.stderr = orig_stderr
|
sys.stderr = orig_stderr
|
||||||
else:
|
else:
|
||||||
support.verbose = verbose # Tell tests to be moderately quiet
|
support.verbose = verbose # Tell tests to be moderately quiet
|
||||||
result = runtest_inner(test, verbose, quiet, huntrleaks,
|
result = runtest_inner(ns, test, verbose, quiet, huntrleaks,
|
||||||
display_failure=not verbose, pgo=pgo)
|
display_failure=not verbose, pgo=pgo)
|
||||||
return result
|
return result
|
||||||
finally:
|
finally:
|
||||||
|
@ -137,14 +137,14 @@ def runtest(ns, test):
|
||||||
runtest.stringio = None
|
runtest.stringio = None
|
||||||
|
|
||||||
|
|
||||||
def runtest_inner(test, verbose, quiet,
|
def runtest_inner(ns, test, verbose, quiet,
|
||||||
huntrleaks=False, display_failure=True, *, pgo=False):
|
huntrleaks=False, display_failure=True, *, pgo=False):
|
||||||
support.unload(test)
|
support.unload(test)
|
||||||
|
|
||||||
test_time = 0.0
|
test_time = 0.0
|
||||||
refleak = False # True if the test leaked references.
|
refleak = False # True if the test leaked references.
|
||||||
try:
|
try:
|
||||||
if test.startswith('test.'):
|
if test.startswith('test.') or ns.testdir:
|
||||||
abstest = test
|
abstest = test
|
||||||
else:
|
else:
|
||||||
# Always import it from the test package
|
# Always import it from the test package
|
||||||
|
|
|
@ -29,6 +29,11 @@ def setup_tests(ns):
|
||||||
replace_stdout()
|
replace_stdout()
|
||||||
support.record_original_stdout(sys.stdout)
|
support.record_original_stdout(sys.stdout)
|
||||||
|
|
||||||
|
if ns.testdir:
|
||||||
|
# Prepend test directory to sys.path, so runtest() will be able
|
||||||
|
# to locate tests
|
||||||
|
sys.path.insert(0, os.path.abspath(ns.testdir))
|
||||||
|
|
||||||
# Some times __path__ and __file__ are not absolute (e.g. while running from
|
# Some times __path__ and __file__ are not absolute (e.g. while running from
|
||||||
# Lib/) and, if we change the CWD to run the tests in a temporary dir, some
|
# Lib/) and, if we change the CWD to run the tests in a temporary dir, some
|
||||||
# imports might fail. This affects only the modules imported before os.chdir().
|
# imports might fail. This affects only the modules imported before os.chdir().
|
||||||
|
|
|
@ -879,6 +879,9 @@ Documentation
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- Issue #26295: When using "python3 -m test --testdir=TESTDIR", regrtest
|
||||||
|
doesn't add "test." prefix to test module names.
|
||||||
|
|
||||||
- Issue #26523: The multiprocessing thread pool (multiprocessing.dummy.Pool)
|
- Issue #26523: The multiprocessing thread pool (multiprocessing.dummy.Pool)
|
||||||
was untested.
|
was untested.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue