Cannot use coverage with jython

Issue #322 resolved
Chris Bannan
created an issue

Using the windows installer, there is no coveragepy directory created. Therefore python COVERAGEDIR cannot be used

But, using the bitbucket clone, that directory is created

To use coverage with python, one can run python -m coverage run sample.py There is no equivalent for jython.

However, jython \coveragepy\__main__.py run sample.py does work This seems like it is not what you intended.

Also, jython \coveragepy\__main__.py html fails. The error is attached.

My environment is

  • Coverage.py, version 3.7.1

  • Python 2.7

  • Jython 2.7b2

  • java version "1.7.0_65" Java(TM) SE Runtime Environment (build 1.7.0_65-b19) Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

Comments (11)

  1. Ned Batchelder repo owner

    I'm not sure what "python COVERAGEDIR" means: where did that come from? Generally, the problem here is that you have to get coverage installed into your Jython installation. The windows installer won't know about Jython, so you'll need to do it more manually: untar the source tarball, and use "jython setup.py install".

    The HTML issue is known, I should document that.

  2. Loic Dachary

    I tried to reproduce the problem with jython-2.5.3 on Ubuntu 16.04 but got the following error

    $ jython coverage.py/__main__.py run sample.py 
    jython coverage.py/__main__.py run sample.py 
    "my" variable $jythonHome masks earlier declaration in same scope at /usr/bin/jython line 15.
    Traceback (most recent call last):
      File "coverage.py/__main__.py", line 11, in <module>
        run_globals = runpy.run_module(PKG, run_name='__main__', alter_sys=True)
      File "coverage.py/__main__.py", line 11, in <module>
        run_globals = runpy.run_module(PKG, run_name='__main__', alter_sys=True)
      File "/usr/share/jython/Lib/runpy.py", line 94, in run_module
        return _run_module_code(code, init_globals, run_name,
      File "/usr/share/jython/Lib/runpy.py", line 51, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/usr/share/jython/Lib/runpy.py", line 32, in _run_code
        exec code in run_globals
      File "/tmp/f/coverage.py/coverage/__init__.py", line 11, in <module>
        from coverage.version import __version__, __url__, version_info
      File "/tmp/f/coverage.py/coverage/__init__.py", line 13, in <module>
        from coverage.control import Coverage, process_startup
      File "/tmp/f/coverage.py/coverage/control.py", line 339
    SyntaxError: 'with' will become a reserved keyword in Python 2.6
    
  3. Log in to comment