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
No coverage data is collected for installed package when py.test is run in the project's root directory #98
Comments
Hey, I need more details to figure out what's going on:
|
Steps to reproduce the bug:
|
Seems to be working as expected for me:
|
Note the I think what you need here is a path mapping in |
To be honest I have never figured out how to get that damn mapping to work (https://coverage.readthedocs.org/en/latest/config.html#paths) so I always have two envs, one for normal runs and one for coverage runs (where something alone the lines of |
What was your PWD and command from the output you posted? |
I was in the root of the repo (/home/ionel/sandbox/mylib).
|
You also appear to have the expected result:
|
I think this can be closed. I don't think there's a way to solve this in pytest-cov. Maybe report issue with paths mapping at https://bitbucket.org/ned/coveragepy/ ? |
I have the expected result when my pwd is the tests subdirectory. When I run from the project root, I get nothing. |
Ok, and if you run just |
aah, I get the same results as you in that case. |
Ok, so not a |
Had a problem where coverage wasn't being executed properly, and solved it with the solution at: pytest-dev/pytest-cov#98.
When running under Travis, I stumbled upon this issue: pytest-dev/pytest-cov#98 Editable install seems to fix.
When having the issue with tox, I turned |
I had the same problem. I had a wrong folder name here: |
Another option with tox is to set the [testenv]
setenv =
PYTHONPATH = {toxinidir}
commands =
pytest --cov=<your package>
- codecov |
This does not appear to work with an intermediate edit: Actually, nevermind... I started with a fresh clone and was not able to reproduce this. FWIW, |
@dmtucker please open an issue and post some details to help reproduce your problem. |
More annoying than anything I see "Coverage.py warning: No data was collected. (no-data-collected)" in the command output when I run "make test" from the root of the following repo https://github.com/geoff-coppertop/python-hw-railroad I'm still getting the coverage data in the reports directory. |
@geoff-coppertop For the source path I would define that with tox. I'm referring to this line. I'd rather write in [testenv]
commands =
pytest --cov={envsitepackagesdir}/hw_railroad |
that solved it for me |
I got the same issue and adding a tests/init.py helped. Refer to http://thomas-cokelaer.info/blog/2017/01/pytest-cov-collects-no-data-on-travis/ |
# This is the 1st commit message: Import latest version # This is the commit message #2: Added PyCharm stuff to ignore file. # This is the commit message #3: Added package skeleton. # This is the commit message #4: Updated license, now Apache 2.0. # This is the commit message #5: Changed README to RST format. # This is the commit message #6: Added requirements stuff. # This is the commit message #7: Added misc utility scripts. # This is the commit message #8: Added tox draft. To be tested. # This is the commit message #9: Added tox draft. To be tested. # This is the commit message #10: Added test skeleton. # This is the commit message #11: Added source skeleton. # This is the commit message #12: Added version info. # This is the commit message #13: Renamed test->tests to match directory naming. # This is the commit message #14: Added setup.py. # This is the commit message #15: Added fixture file. Misc, minor changes. # This is the commit message #16: Added missing config files. # This is the commit message #17: Added misc drafts. # This is the commit message #18: Added Sphinx stuff. To be reviewed. # This is the commit message #19: Added misc drafts. # This is the commit message #20: Fixed Event class. # This is the commit message #21: Added misc drafts. # This is the commit message #22: Fixed Sphinx configuration. # This is the commit message #23: Added missing flake8 requirements file. # This is the commit message #24: Fixed misc setup files. # This is the commit message #25: Fixed linting. # This is the commit message #26: Added TravisCI config file. # This is the commit message #27: Added service badges to README. # This is the commit message #28: Added TODO tag to automaton meta to break pylint. ...I needed a forcing reminder. # This is the commit message #29: Working on tdd, test failure is wanted. # This is the commit message #30: Fixed TravisCI badge. Fixed the TravisCI badge, the SVG link pointed to another project (Zirkon by @simone-campagna from which the snippet was stolen). # This is the commit message #31: Tests added. Still working on TDD. # This is the commit message #32: Removed HTTPS badge retrieval (Read The Docs). # This is the commit message #33: Added exceptions file. # This is the commit message #34: Added static property util. # This is the commit message #35: API change: a base class is now provided instead of a (less neat) metaclass. # This is the commit message #36: API change: fixed metaclass mechanics for the new API. # This is the commit message #37: Fixed tests for the new API. # This is the commit message #38: Event: it was almost useless, changed from a class to a namedtuple. # This is the commit message #39: Added basic transition logic. # This is the commit message #40: Added license. # This is the commit message #41: Finalized transition mechanics. # This is the commit message #42: Removed unused import. # This is the commit message #43: Cosmetics. # This is the commit message #44: Added stubs for connection check. # This is the commit message #45: Addes proper tests for connection check. # This is the commit message #46: Removed class properties: they are evil while playing with metaclasses. Added state graph connection check. Added tests. # This is the commit message #47: Added class methods tests. # This is the commit message #48: Fixed linting. # This is the commit message #49: Fixed linting and docstrings. # This is the commit message #50: Fixed documentation structure and generated apidoc. # This is the commit message #51: Added todo file. # This is the commit message #52: Improved readme. # This is the commit message #53: Fixed doctests while executed in Sphinx. # This is the commit message #54: Fixed doctests while executed in Sphinx. # This is the commit message #55: Added empty definition test. # This is the commit message #56: Working on README. # This is the commit message #57: Working on README. # This is the commit message #58: Fixed rst syntax. # This is the commit message #59: Added event methods to automaton instances. # This is the commit message #60: Moved event interface methods at class level. # This is the commit message #61: Fixed linting. # This is the commit message #62: Fixed linting. # This is the commit message #63: API change: Event is now a descriptor, it acts as a class property and as a bound method at the same time (just like SQLAlchemy's Column attributes). # This is the commit message #64: Cosmetics. # This is the commit message #65: API change: removed state setter, it was reduntant. # This is the commit message #66: Fixed linting. # This is the commit message #67: Working on README. # This is the commit message #68: Working on README. # This is the commit message #69: Working on README. # This is the commit message #70: Fixed link. # This is the commit message #71: Working on README. # This is the commit message #72: Working on README. # This is the commit message #73: Fixed RST syntax. # This is the commit message #74: Fixed RST syntax. # This is the commit message #75: Added Event binding test. # This is the commit message #76: Updated TODOs. # This is the commit message #77: Removed TODO file, corresponding issues opened. # This is the commit message #78: Cached event delegates. # This is the commit message #79: Event made a read-only data descriptor. # This is the commit message #80: Tests fixtured. # This is the commit message #81: Accepting (final) states support. # This is the commit message #82: Fixed linting. # This is the commit message #83: Fixed coverage. # This is the commit message #84: Added descriptor test. # This is the commit message #85: Replaced the delegate class with a closure. # This is the commit message #86: Fixed setup.py, now PyPi compliant. # This is the commit message #87: Fixed setup.py, now PyPi compliant. # This is the commit message #88: Added (failing) tests for sink states. # This is the commit message #89: Added sink states. Closes #5. # This is the commit message #90: Version 0.2.0. # This is the commit message #91: Added loop automaton test. # This is the commit message #92: Moved graph stuff to a file on its own. # This is the commit message #93: Added tricky graph test. # This is the commit message #94: Small fixes on docs. # This is the commit message #95: Fixed Travis badge after username change. # This is the commit message #96: Fixed Travis badge after username change. # This is the commit message #97: Fixed package metadata after username change. # This is the commit message #98: Fixed documentation. # This is the commit message #99: cleaning up setup stuff, previous approach was the usual pip+distutils mess # This is the commit message #100: packaging and testing machinery cleanup * fixed requirement files and setup.py following PPA guidelines * streamlined tox.ini * removed a lot of useless crap # This is the commit message #101: added local development virtualenv to ignores # This is the commit message #102: fixed missing import # This is the commit message #103: fixed travis config and moved to codecov # This is the commit message #104: fixed glitch in travis file # This is the commit message #105: fixed pytest-cov nasty issue When running under Travis, I stumbled upon this issue: pytest-dev/pytest-cov#98 Editable install seems to fix. # This is the commit message #106: First attempt in having tox driving Travis (including codecov upload) # This is the commit message #107: Fixed tox-travis env key # This is the commit message #108: Fixed tox-travis using the 'python' key in [travis] section # This is the commit message #109: Fixing again pytest-cov 'no data was collected' issue # This is the commit message #110: Trying to fix pytest-cov issue with explicit editable install in codecov section # This is the commit message #111: Comments errata corrige # This is the commit message #112: Added install deps to linting, it was complaining about missing imports # This is the commit message #113: Removed all homebrewed graph stuff, switched to networkx # This is the commit message #114: Fixed documentation # This is the commit message #115: Updated project virtualenv dir name in gitignore # This is the commit message #116: Added test for inbound events # This is the commit message #117: Fixed glitch # This is the commit message #118: Fixed edges generator in Event # This is the commit message #119: Added methods to retrieve a subgraph cut (inbound and outbound) # This is the commit message #120: Linting # This is the commit message #121: Fixed doctests # This is the commit message #122: Fixed a lot of TODOs and linting # This is the commit message #123: Removed redundant exceptions file # This is the commit message #124: Draft for formatting stuff, needs streamlining # This is the commit message #125: Tabulation function cleanup # This is the commit message #126: Fancy tests # This is the commit message #127: Added tests for transition table formatting Still missing a lot of coverage. # This is the commit message #128: Updated coverage badge # This is the commit message #129: Add Codacy badge # This is the commit message #130: Moved Codacy Badge # This is the commit message #131: Enabled doctests # This is the commit message #132: Updated ReadTheDocs badge # This is the commit message #133: Bump version: 0.2.0 → 1.0.0 # This is the commit message #134: Added PyPI badge to README.rst # This is the commit message #135: Generator streamlining and added missing docstrings Squashed commit of the following: commit e95b94c35a396c86800b47360c9220747ffb6012 Author: Federico Ficarelli <federico.ficarelli@gmail.com> Date: Fri Jan 27 23:20:57 2017 +0100 WIP commit bf39b4995c80e426fec600984ecaeba9fa0caeff Author: Federico Ficarelli <federico.ficarelli@gmail.com> Date: Fri Jan 27 22:58:23 2017 +0100 WIP commit 162ee37db66c33e40448697ffed5e94c26605c97 Author: Federico Ficarelli <federico.ficarelli@gmail.com> Date: Fri Jan 27 20:30:35 2017 +0100 WIP commit caf59df89ed82a22ce1d4464f0cdb4547677d742 Author: Federico Ficarelli <federico.ficarelli@gmail.com> Date: Fri Jan 27 20:28:37 2017 +0100 WIP commit 73c5d4a5f7e62150897bbec7ec18a9ac48388d77 Author: Federico Ficarelli <federico.ficarelli@gmail.com> Date: Fri Jan 27 20:21:37 2017 +0100 WIP # This is the commit message #136: Fixed plantuml function parameters, tests and misc docstrings # This is the commit message #137: Added traversal tests for formatting fuctions # This is the commit message #138: Added changelog to README.rst # This is the commit message #139: Minor cosmetic changes to README.rst # This is the commit message #140: Bump version: 1.0.0 → 1.1.0 # This is the commit message #141: Refactored formatting stuff, added initial support for custom 'format()' specifiers # This is the commit message #142: Fixed __format__ for both instances and Automaton subclasses # This is the commit message #143: Added auto completion of class docstring with formatted automaton representation # This is the commit message #144: Fixed cosmetics in README.rst # This is the commit message #145: Removed package, the whole library now lives in a single module file # This is the commit message #146: Updated changelog in README # This is the commit message #147: Bump version: 1.1.0 → 1.2.0 # This is the commit message #148: Fixed minor README glitches # This is the commit message #149: Uncovered severe issue to packaging As explained here https://hynek.me/articles/testing-packaging/ and here pyca/cryptography@c62a78c the problem was that we were running tests *against the source package, not the installed one*. # This is the commit message #150: Fixed dist and tox - now running tests against installed module # This is the commit message #151: Updated changelog # This is the commit message #152: Fixed bumpversion and Sphynx # This is the commit message #153: Bump version: 1.2.0 → 1.2.1 # This is the commit message #154: Updated changelog in README.rst # This is the commit message #155: Updated changelog with next release TODOs # This is the commit message #156: Tests cleanup # This is the commit message #157: Added failing tests for next fixes to be done # This is the commit message #158: Added xfailing tests for new features, xfailed others # This is the commit message #159: Requirements cleanup # This is the commit message #160: Added descriptor proxy to access all Event stuff from automaton instances # This is the commit message #161: Added docstring to proxy type # This is the commit message #162: Fixed Sphinx internal references # This is the commit message #163: Added support for initial event startup # This is the commit message #164: Typo # This is the commit message #165: Changelog updated # This is the commit message #166: Fixed README.rst glitches # This is the commit message #167: Fixed Sphinx glitches # This is the commit message #168: Improving README.rst # This is the commit message #169: Improving README.rst # This is the commit message #170: Improving README.rst # This is the commit message #171: Improving README.rst # This is the commit message #172: Updated README.rst with external link to images # This is the commit message #173: Fixed changelog in README.rst # This is the commit message #174: Bump version: 1.2.1 → 1.3.0 # This is the commit message #175: Fixed README.rst for pypi rendering # This is the commit message #176: Bump version: 1.3.0 → 1.3.1
Might fix coverage as per pytest-dev/pytest-cov#98
I have an omit =
# All dot-files and dirs
*/.*
... |
I have finished up a minimal Python package repo just yesterday. It demonstrates how to combine tox with an installed package from You can find the full-implementation branch here. In order to get codecov.io working, I had to configure the following section. [coverage:paths]
source =
src/demo
*/site-packages/demo where |
@rogerdahl if Midnighter didn't address your problem already it would be best to open a new issue for your problem (with a reproducer and such). |
Thanks, @ionelmc. My issue is resolved. I just added it as a datapoint for others who might have this issue. |
I spent a long time troubleshooting that problem (on travis), and I fixed it by adding an init.py file in my tests directory. That was it ... |
adding |
Just to add on the discussion:
but when in
line to It there any fault added to this strategy? For example, not testing a proper installation?
|
Yes, it makes it slightly more likely that breaking the build/install would not be caught (because the package and its deps are not reinstalled for every Tox run). |
Hi @dmtucker Thanks for the explanation |
I sometimes have this issue when I run The py38 version outputs a warning "warning: No data was collected" yet there is no warning for py36 or py37. (I am new to tox and was looking for a solution which is what brought me here.) Though it takes longer I probably have done something unconventional along the way. |
It turns out that the mv .coverage .coverage.hack # I can't combine it without renaming
coverage combine
coverage report |
For newbies like me, just for clarity, please note this solution requires adding file tests/(underscore)(underscore)init(underscore)(underscore).py aka Is it preferable to extend the file |
If I have a package(and pytest-cov) installed in a virtualenv, and I run pytest-cov from the project's root directory(which has the package folder), then no coverage data is collected.
The text was updated successfully, but these errors were encountered: