Issue1887

classification
Title: problem with path info embedded in generated class file? (windows)
Type: Severity: normal
Components: Core Versions: 2.7a1
Milestone:
process
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.

Messages
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).



E:\temp\tests>ls
test_jython27.py

E:\temp\tests>cat test_jython27.py
import unittest

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

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

----------------------------------------------------------------------
Ran 1 test in 0,001s

OK

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\runpy.py", line 175, in run_module
    return _run_module_code(code, init_globals, run_name,
  File "E:\jython27\Lib\runpy.py", line 81, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "E:\jython27\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "E:\jython27\Lib\unittest\__main__.py", line 12, in <module>
    main(module=None)
  File "E:\jython27\Lib\unittest\main.py", line 94, in __init__
    self.parseArgs(argv)
  File "E:\jython27\Lib\unittest\main.py", line 113, in parseArgs
    self._do_discovery(argv[2:])
  File "E:\jython27\Lib\unittest\main.py", line 211, in _do_discovery
    self.test = loader.discover(start_dir, pattern, top_level_dir)
  File "E:\jython27\Lib\unittest\loader.py", line 204, in discover
    tests = list(self._find_tests(start_dir, pattern))
  File "E:\jython27\Lib\unittest\loader.py", 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

OK

E:\temp\tests>
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.
History
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