Message7101

Author irmen
Recipients irmen
Date 2012-05-17.10:16:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1337249805.77.0.703274363443.issue1887@psf.upfronthosting.co.za>
In-reply-to
Content
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>
History
Date User Action Args
2012-05-17 10:16:45irmensetrecipients: + irmen
2012-05-17 10:16:45irmensetmessageid: <1337249805.77.0.703274363443.issue1887@psf.upfronthosting.co.za>
2012-05-17 10:16:45irmenlinkissue1887 messages
2012-05-17 10:16:45irmencreate