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

Calling subprocess fails (and outright crashes on python 2.6) when given a relative path for --cov-config #94

Closed
embray opened this issue Oct 1, 2015 · 2 comments
Labels

Comments

@embray
Copy link

embray commented Oct 1, 2015

As I documented over in astropy/astropy-helpers#193, if I specify a relative path to a coveragerc file with the --cov-config option, and then one of my tests changes to a different directory and starts a subprocess, then an exception occurs during processing of the pytest-cov.pth file:

Traceback (most recent call last):
  File "/home/embray/miniconda/envs/test/lib/python2.6/site.py", line 525, in <module>
    main()
  File "/home/embray/miniconda/envs/test/lib/python2.6/site.py", line 508, in main
    known_paths = addsitepackages(known_paths)
  File "/home/embray/miniconda/envs/test/lib/python2.6/site.py", line 288, in addsitepackages
    addsitedir(sitedir, known_paths)
  File "home/embray/miniconda/envs/test/lib/python2.6/site.py", line 185, in addsitedir
    addpackage(sitedir, name, known_paths)
  File "/home/embray/miniconda/envs/test/lib/python2.6/site.py", line 155, in addpackage
    exec line
  File "<string>", line 1, in <module>
  File "<string>", line 4, in <module>
  File "/home/embray/miniconda/envs/test/lib/python2.6/site-packages/pytest_cov/embed.py", line 58, in init
    auto_data=True)
  File "/home/embray/miniconda/envs/test/lib/python2.6/site-packages/coverage/control.py", line 138, in __init__
    "Couldn't read '%s' as a config file" % config_file
coverage.misc.CoverageException: Couldn't read 'astropy_helpers/tests/coveragerc' as a config file

This is because the relative path is written into the COV_CORE_CONFIG environment variable. So after changing directories that file cannot be found and we get a crash upon trying to process it.

On most Python versions this exception is ignored in site.py (so the coverage feature is still broken, but otherwise the tests pass). On Python 2.6, however, the exception is not ignored and the tests fail too.

A simple workaround would be to always store the path to the config file as an absolute path.

@ionelmc ionelmc added the bug label Oct 1, 2015
@ionelmc
Copy link
Member

ionelmc commented Oct 1, 2015

Also: #77

ionelmc added a commit that referenced this issue Oct 1, 2015
Use absolute paths for coverage config file and sources. Add a new internal variable "COV_CORE_DATAFILE" to workaround the misplacement of .coverage.foobar.123 files.

Because needs to be an absolute path COV_CORE_CONFIG we need to do some special things: coverage treats config_file='.coveragerc' as if it was config_file=True. We need to keep that behavior.

Closes #94. Closes #77.
@ionelmc
Copy link
Member

ionelmc commented Oct 1, 2015

Feel free to try #95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants