Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use coverage with jython #322

Closed
nedbat opened this issue Aug 6, 2014 · 9 comments
Closed

Cannot use coverage with jython #322

nedbat opened this issue Aug 6, 2014 · 9 comments
Labels
bug Something isn't working install

Comments

@nedbat
Copy link
Owner

nedbat commented Aug 6, 2014

Originally reported by Chris Bannan (Bitbucket: cmbannan, GitHub: cmbannan)


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)


@nedbat
Copy link
Owner Author

nedbat commented Aug 9, 2014

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.

@nedbat
Copy link
Owner Author

nedbat commented Aug 11, 2014

Original comment by Chris Bannan (Bitbucket: cmbannan, GitHub: cmbannan)


Sorry about the incomplete COVERAGEDIR comment. That is from the Jython coverage instructions. See section 6.2.1 at http://www.jython.org/devguide/coverage.html

There is a work-around for jython. It is in the original bug report.
However, It seems wrong. Relying on that seems foolish as it seems like an undocumented or possibly unsupported feature.

@nedbat
Copy link
Owner Author

nedbat commented Jan 22, 2015

@cmbannan Sorry I've taken so long to get back to this. I'd like to get back to testing under Jython, so I'm trying to reproduce these problems now. If you have any more information, I'd be grateful.

@nedbat
Copy link
Owner Author

nedbat commented Dec 18, 2016

Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary)


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

#!bash

$ 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

@nedbat
Copy link
Owner Author

nedbat commented Jan 8, 2017

Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary)


See another coveragepy issue for more information on jython support for coveragepy

@nedbat
Copy link
Owner Author

nedbat commented Jan 13, 2017

Also, #551 reports Jython problems that I am trying to fix. More Jython info is definitely appreciated.

@nedbat
Copy link
Owner Author

nedbat commented Jan 14, 2017

As of 4d9c54230ba7 (bb), I can run "jython -m coverage run myprog.py".

@nedbat
Copy link
Owner Author

nedbat commented Jan 14, 2017

Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary)


\o/

@nedbat
Copy link
Owner Author

nedbat commented Jan 17, 2017

This was shipping in 4.3.2.

@nedbat nedbat closed this as completed Jan 17, 2017
@nedbat nedbat added major bug Something isn't working install labels Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working install
Projects
None yet
Development

No branches or pull requests

1 participant