]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix regression in issue 22457 fix.
authorRobert Collins <rbtcollins@hp.com>
Tue, 4 Nov 2014 14:43:36 +0000 (03:43 +1300)
committerRobert Collins <rbtcollins@hp.com>
Tue, 4 Nov 2014 14:43:36 +0000 (03:43 +1300)
When used in the real world it can under some situations trigger
"    assert not _relpath.startswith('..'), "Path must be within the project"
     AssertionError: Path must be within the project
"

Because _get_name_from_path was not expecting to be called with the top level
directory.

Lib/unittest/loader.py

index 8c10ad1f41e6379bd8cb61c74e38a58096217051..8ee6c56153122f23498f7a94a757f782f357ef52 100644 (file)
@@ -343,6 +343,8 @@ class TestLoader(object):
             return os.path.dirname(full_path)
 
     def _get_name_from_path(self, path):
+        if path == self._top_level_dir:
+            return '.'
         path = _jython_aware_splitext(os.path.normpath(path))
 
         _relpath = os.path.relpath(path, self._top_level_dir)