diff options
author | Robert Collins <rbtcollins@hp.com> | 2014-11-05 03:43:36 +1300 |
---|---|---|
committer | Robert Collins <rbtcollins@hp.com> | 2014-11-05 03:43:36 +1300 |
commit | 68b11d129dc28f741e5522fe07b4b935c0d59198 (patch) | |
tree | a7741d97f90a7ee5c6f35974fcbbe60f252178e8 /Lib/unittest/loader.py | |
parent | Close #22457: Honour load_tests in the start_dir of discovery. (diff) | |
download | cpython-68b11d129dc28f741e5522fe07b4b935c0d59198.tar.gz cpython-68b11d129dc28f741e5522fe07b4b935c0d59198.tar.bz2 cpython-68b11d129dc28f741e5522fe07b4b935c0d59198.zip |
Fix regression in issue 22457 fix.
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.
Diffstat (limited to 'Lib/unittest/loader.py')
-rw-r--r-- | Lib/unittest/loader.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py index 8c10ad1f41e..8ee6c561531 100644 --- a/Lib/unittest/loader.py +++ b/Lib/unittest/loader.py @@ -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) |