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

Skip to content

Commit 4bd53b1

Browse files
committed
merge heads
2 parents 7554f0d + 5738e4f commit 4bd53b1

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

Lib/unittest/loader.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def testFailure(self):
3434
TestClass = type(classname, (case.TestCase,), attrs)
3535
return suiteClass((TestClass(methodname),))
3636

37+
def _jython_aware_splitext(path):
38+
if path.lower().endswith('$py.class'):
39+
return path[:-9]
40+
return os.path.splitext(path)[0]
41+
3742

3843
class TestLoader(object):
3944
"""
@@ -221,7 +226,7 @@ def _get_directory_containing_module(self, module_name):
221226
return os.path.dirname(full_path)
222227

223228
def _get_name_from_path(self, path):
224-
path = os.path.splitext(os.path.normpath(path))[0]
229+
path = _jython_aware_splitext(os.path.normpath(path))
225230

226231
_relpath = os.path.relpath(path, self._top_level_dir)
227232
assert not os.path.isabs(_relpath), "Path must be within the project"
@@ -258,11 +263,11 @@ def _find_tests(self, start_dir, pattern):
258263
yield _make_failed_import_test(name, self.suiteClass)
259264
else:
260265
mod_file = os.path.abspath(getattr(module, '__file__', full_path))
261-
realpath = os.path.splitext(mod_file)[0]
262-
fullpath_noext = os.path.splitext(full_path)[0]
266+
realpath = _jython_aware_splitext(mod_file)
267+
fullpath_noext = _jython_aware_splitext(full_path)
263268
if realpath.lower() != fullpath_noext.lower():
264269
module_dir = os.path.dirname(realpath)
265-
mod_name = os.path.splitext(os.path.basename(full_path))[0]
270+
mod_name = _jython_aware_splitext(os.path.basename(full_path))
266271
expected_dir = os.path.dirname(full_path)
267272
msg = ("%r module incorrectly imported from %r. Expected %r. "
268273
"Is this module globally installed?")

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Core and Builtins
2424
Library
2525
-------
2626

27+
- Issue #10543: Fix unittest test discovery with Jython bytecode files.
28+
2729
- Issue #1178863: Separate initialisation from setting when initializing
2830
Tkinter.Variables; harmonize exceptions to ValueError; only delete variables
2931
that have not been deleted; assert that variable names are strings.

0 commit comments

Comments
 (0)