[Python-checkins] r86956 - in python/branches/py3k: Lib/test/regrtest.py Misc/NEWS

nick.coghlan python-checkins at python.org
Fri Dec 3 08:44:34 CET 2010


Author: nick.coghlan
Date: Fri Dec  3 08:44:33 2010
New Revision: 86956

Log:
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)

Modified:
   python/branches/py3k/Lib/test/regrtest.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k/Lib/test/regrtest.py	(original)
+++ python/branches/py3k/Lib/test/regrtest.py	Fri Dec  3 08:44:33 2010
@@ -1468,7 +1468,20 @@
         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.

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Fri Dec  3 08:44:33 2010
@@ -191,6 +191,9 @@
 Tests
 -----
 
+- regrtest.py once again ensures the test directory is removed from
+  sys.path when it is invoked directly as the __main__ module
+
 - Issue #9424: Deprecate the `unittest.TestCase` methods `assertEquals`,
   `assertNotEquals`, `assertAlmostEquals`, `assertNotAlmostEquals` and `assert_`
   and replace them with the correct methods in the Python test suite.


More information about the Python-checkins mailing list