summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-03-30 00:32:52 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-03-30 00:32:52 (GMT)
commit9759dd334325f341318ff5f2ef25409a5e44dc98 (patch)
treec20e555a40c347b1a66cfb208202711a35a1b76d /Lib/test
parent7f24a98a9aa01d6c548b3740fe3a5da409403c3d (diff)
downloadcpython-9759dd334325f341318ff5f2ef25409a5e44dc98.zip
cpython-9759dd334325f341318ff5f2ef25409a5e44dc98.tar.gz
cpython-9759dd334325f341318ff5f2ef25409a5e44dc98.tar.bz2
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.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/libregrtest/runtest.py8
-rw-r--r--Lib/test/libregrtest/setup.py5
2 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py
index daff476..601f2b2 100644
--- a/Lib/test/libregrtest/runtest.py
+++ b/Lib/test/libregrtest/runtest.py
@@ -116,7 +116,7 @@ def runtest(ns, test):
try:
sys.stdout = stream
sys.stderr = stream
- result = runtest_inner(test, verbose, quiet, huntrleaks,
+ result = runtest_inner(ns, test, verbose, quiet, huntrleaks,
display_failure=False, pgo=pgo)
if result[0] == FAILED:
output = stream.getvalue()
@@ -127,7 +127,7 @@ def runtest(ns, test):
sys.stderr = orig_stderr
else:
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)
return result
finally:
@@ -137,14 +137,14 @@ def runtest(ns, test):
runtest.stringio = None
-def runtest_inner(test, verbose, quiet,
+def runtest_inner(ns, test, verbose, quiet,
huntrleaks=False, display_failure=True, *, pgo=False):
support.unload(test)
test_time = 0.0
refleak = False # True if the test leaked references.
try:
- if test.startswith('test.'):
+ if test.startswith('test.') or ns.testdir:
abstest = test
else:
# Always import it from the test package
diff --git a/Lib/test/libregrtest/setup.py b/Lib/test/libregrtest/setup.py
index de52bb5..1d24531 100644
--- a/Lib/test/libregrtest/setup.py
+++ b/Lib/test/libregrtest/setup.py
@@ -29,6 +29,11 @@ def setup_tests(ns):
replace_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
# 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().