Title: problem with path info embedded in generated class file? (windows)
Type: Severity: normal
Components: Core Versions: 2.7a1
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: alex.gronholm Nosy List: alex.gronholm, amak, fwierzbicki, irmen
Priority: Keywords:

Created on 2012-05-17.10:16:45 by irmen, last changed 2012-10-29.17:21:32 by alex.gronholm.

msg7101 (view) Author: Irmen de Jong (irmen) Date: 2012-05-17.10:16:45
I encountered a problem with running unit tests. After a while of experimenting it seems that it is related to some kind of path information that jython embeds in the generated class file. I'm running the session below on windows with Jython 2.7a1.

Notice that when I launch the interpreter with a different path (first with a preceding driver letter, then without), it fails at the second launch with a strange path related error. When I delete the generated .class file, and retry, it works fine (but now an attempt to launch it again with a drive letter will fail with the same error, and I need to delete the class file again).


import unittest

class TestJython(unittest.TestCase):
    def test_stuff(self):

E:\temp\tests>e:\jython27\jython.bat -m unittest discover -v
test_stuff (test_jython27.TestJython) ... ok

Ran 1 test in 0,001s


E:\temp\tests>\jython27\jython.bat -m unittest discover -v
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "E:\jython27\Lib\", line 175, in run_module
    return _run_module_code(code, init_globals, run_name,
  File "E:\jython27\Lib\", line 81, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "E:\jython27\Lib\", line 72, in _run_code
    exec code in run_globals
  File "E:\jython27\Lib\unittest\", line 12, in <module>
  File "E:\jython27\Lib\unittest\", line 94, in __init__
  File "E:\jython27\Lib\unittest\", line 113, in parseArgs
  File "E:\jython27\Lib\unittest\", line 211, in _do_discovery
    self.test =, pattern, top_level_dir)
  File "E:\jython27\Lib\unittest\", line 204, in discover
    tests = list(self._find_tests(start_dir, pattern))
  File "E:\jython27\Lib\unittest\", line 265, in _find_tests
    raise ImportError(msg % (mod_name, module_dir, expected_dir))
ImportError: 'test_jython27' module incorrectly imported from 'E:\\temp\\tests'.
 Expected 'E:\\temp\\tests'. Is this module globally installed?

E:\temp\tests>del *.class

E:\temp\tests>\jython27\jython.bat -m unittest discover -v
test_stuff (test_jython27.TestJython) ... ok

Ran 1 test in 0,001s


msg7495 (view) Author: Alex Grönholm (alex.gronholm) Date: 2012-10-29.17:21:32
The code in unittest.loader wrongly assumes that removing the file extension is enough to normalize the module file name. An appropriate workaround was added in changeset f79d600c1908.
Date User Action Args
2012-10-29 17:21:32alex.gronholmsetstatus: open -> closed
nosy: + alex.gronholm
messages: + msg7495
assignee: alex.gronholm
components: - Jythonc compiler
resolution: fixed
2012-06-05 20:08:02amaksetnosy: + amak
2012-05-18 17:30:24fwierzbickisetnosy: + fwierzbicki
2012-05-17 10:16:45irmencreate