diff options
author | Michael Foord <michael@voidspace.org.uk> | 2012-03-13 07:14:19 (GMT) |
---|---|---|
committer | Michael Foord <michael@voidspace.org.uk> | 2012-03-13 07:14:19 (GMT) |
commit | 5738e4f3dff7abb1d15b9774a8a4fcf5fc421766 (patch) | |
tree | ab8f950a5938765a8652b6b2899dbef19510543e /Lib | |
parent | a9719057a2ee1875c6334b1d5fbbf66cfc02ca78 (diff) | |
parent | e01c62cd6bc413db0895696f22d7188890757431 (diff) | |
download | cpython-5738e4f3dff7abb1d15b9774a8a4fcf5fc421766.zip cpython-5738e4f3dff7abb1d15b9774a8a4fcf5fc421766.tar.gz cpython-5738e4f3dff7abb1d15b9774a8a4fcf5fc421766.tar.bz2 |
Merge
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/unittest/loader.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py index ab36400..541884e 100644 --- a/Lib/unittest/loader.py +++ b/Lib/unittest/loader.py @@ -34,6 +34,11 @@ def _make_failed_test(classname, methodname, exception, suiteClass): TestClass = type(classname, (case.TestCase,), attrs) return suiteClass((TestClass(methodname),)) +def _jython_aware_splitext(path): + if path.lower().endswith('$py.class'): + return path[:-9] + return os.path.splitext(path)[0] + class TestLoader(object): """ @@ -221,7 +226,7 @@ class TestLoader(object): return os.path.dirname(full_path) def _get_name_from_path(self, path): - path = os.path.splitext(os.path.normpath(path))[0] + path = _jython_aware_splitext(os.path.normpath(path)) _relpath = os.path.relpath(path, self._top_level_dir) assert not os.path.isabs(_relpath), "Path must be within the project" @@ -258,11 +263,11 @@ class TestLoader(object): yield _make_failed_import_test(name, self.suiteClass) else: mod_file = os.path.abspath(getattr(module, '__file__', full_path)) - realpath = os.path.splitext(mod_file)[0] - fullpath_noext = os.path.splitext(full_path)[0] + realpath = _jython_aware_splitext(mod_file) + fullpath_noext = _jython_aware_splitext(full_path) if realpath.lower() != fullpath_noext.lower(): module_dir = os.path.dirname(realpath) - mod_name = os.path.splitext(os.path.basename(full_path))[0] + mod_name = _jython_aware_splitext(os.path.basename(full_path)) expected_dir = os.path.dirname(full_path) msg = ("%r module incorrectly imported from %r. Expected %r. " "Is this module globally installed?") |