summaryrefslogtreecommitdiffstats
path: root/Lib/test/regrtest.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2010-12-03 07:44:33 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2010-12-03 07:44:33 (GMT)
commit4c4c0f2fe6e6d9058911c9383bac57e4deefddb8 (patch)
treeca20947184c18a1f2e7ce172dfb776c168ab93d2 /Lib/test/regrtest.py
parent1e5c5f8f7d507af580486529399f12f7e2bbf70a (diff)
downloadcpython-4c4c0f2fe6e6d9058911c9383bac57e4deefddb8.zip
cpython-4c4c0f2fe6e6d9058911c9383bac57e4deefddb8.tar.gz
cpython-4c4c0f2fe6e6d9058911c9383bac57e4deefddb8.tar.bz2
Partially revert r78719 - it removed a check that is still needed in some cases (i.e. this will allow Michael to add the test.__main__ support that broke the buildbots previously)
Diffstat (limited to 'Lib/test/regrtest.py')
-rwxr-xr-xLib/test/regrtest.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 9eecd1d..9d82b71 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1468,7 +1468,20 @@ class _ExpectedSkips:
assert self.isvalid()
return self.expected
+
if __name__ == '__main__':
+ # Remove regrtest.py's own directory from the module search path. Despite
+ # the elimination of implicit relative imports, this is still needed to
+ # ensure that submodules of the test package do not inappropriately appear
+ # as top-level modules even when people (or buildbots!) invoke regrtest.py
+ # directly instead of using the -m switch
+ mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
+ i = len(sys.path)
+ while i >= 0:
+ i -= 1
+ if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
+ del sys.path[i]
+
# findtestdir() gets the dirname out of __file__, so we have to make it
# absolute before changing the working directory.
# For example __file__ may be relative when running trace or profile.