Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4c4c0f2

Browse files
committed
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)
1 parent 1e5c5f8 commit 4c4c0f2

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

Lib/test/regrtest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,20 @@ def getexpected(self):
14681468
assert self.isvalid()
14691469
return self.expected
14701470

1471+
14711472
if __name__ == '__main__':
1473+
# Remove regrtest.py's own directory from the module search path. Despite
1474+
# the elimination of implicit relative imports, this is still needed to
1475+
# ensure that submodules of the test package do not inappropriately appear
1476+
# as top-level modules even when people (or buildbots!) invoke regrtest.py
1477+
# directly instead of using the -m switch
1478+
mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
1479+
i = len(sys.path)
1480+
while i >= 0:
1481+
i -= 1
1482+
if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
1483+
del sys.path[i]
1484+
14721485
# findtestdir() gets the dirname out of __file__, so we have to make it
14731486
# absolute before changing the working directory.
14741487
# For example __file__ may be relative when running trace or profile.

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ C-API
191191
Tests
192192
-----
193193

194+
- regrtest.py once again ensures the test directory is removed from
195+
sys.path when it is invoked directly as the __main__ module
196+
194197
- Issue #9424: Deprecate the `unittest.TestCase` methods `assertEquals`,
195198
`assertNotEquals`, `assertAlmostEquals`, `assertNotAlmostEquals` and `assert_`
196199
and replace them with the correct methods in the Python test suite.

0 commit comments

Comments
 (0)