@@ -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
3843class 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?" )
0 commit comments