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

Coverage fails to generate report with 0% coverage #884

Closed
wlcx opened this issue Dec 16, 2019 · 2 comments
Closed

Coverage fails to generate report with 0% coverage #884

wlcx opened this issue Dec 16, 2019 · 2 comments
Labels
Milestone

Comments

@wlcx
Copy link

@wlcx wlcx commented Dec 16, 2019

Describe the bug
Coverage >5.0a6 seems to fail to generate a report when coverage is 0%, when run by pytest-cov under tox.

To Reproduce
Please see https://github.com/wlcx/coverage-bug-repro for a minimum working reproduction of this. Essentially, it is a single module project, with a test that doesn't actually result in any code coverage. I appreciate this is a bit of a useless edge case, but this did used to not cause any errors!

  • Run tox (which runs python -m pytest --cov=foo tests/):
PS C:\Users\sam.willcocks\prog\coverage-bug-repro> tox
py3 recreate: C:\Users\sam.willcocks\prog\coverage-bug-repro\.tox\py3
py3 installdeps: py, pytest, pytest-cov, coverage
py3 installed: atomicwrites==1.3.0,attrs==19.3.0,colorama==0.4.3,coverage==5.0,importlib-metadata==1.3.0,more-itertools==8.0.2,packaging==19.2,pluggy==0.13.1,py==1.8.0,pyparsing==2.4.5,pytest==5.3.2,pytest-cov==2.8.1,six==1.13.0,wcwidth==0.1.7,zipp==0.6.0
py3 run-test-pre: PYTHONHASHSEED='286'
py3 run-test: commands[0] | python -m pytest --cov=foo tests/
=========================================================== test session starts ============================================================ 
platform win32 -- Python 3.7.4, pytest-5.3.2, py-1.8.0, pluggy-0.13.1
cachedir: .tox\py3\.pytest_cache
rootdir: C:\Users\sam.willcocks\prog\coverage-bug-repro
plugins: cov-2.8.1
collected 1 item                                                                                                                             

tests\test_nothing.py .                                                                                                               [100%]Coverage.py warning: No data was collected. (no-data-collected)
WARNING: Failed to generate report: No data to report.

C:\Users\sam.willcocks\prog\coverage-bug-repro\.tox\py3\lib\site-packages\pytest_cov\plugin.py:254: PytestWarning: Failed to generate report: No data to report.

  self.cov_controller.finish()


----------- coverage: platform win32, python 3.7.4-final-0 -----------


============================================================ 1 passed in 0.07s ============================================================= 
_________________________________________________________________ summary __________________________________________________________________ 
  py3: commands succeeded
  congratulations :)
  • then, subsequently running tox -e coverage-report (running coverage html):
PS C:\Users\sam.willcocks\prog\coverage-bug-repro> tox -e coverage-report   
coverage-report recreate: C:\Users\sam.willcocks\prog\coverage-bug-repro\.tox\coverage-report
coverage-report installdeps: coverage
coverage-report installed: coverage==5.0
coverage-report run-test-pre: PYTHONHASHSEED='242'
coverage-report run-test: commands[0] | coverage html
No data to report.
ERROR: InvocationError for command 'C:\Users\sam.willcocks\prog\coverage-bug-repro\.tox\coverage-report\Scripts\coverage.EXE' html (exited with code 1)
_________________________________________________________________ summary __________________________________________________________________ 
ERROR:   coverage-report: commands failed

Expected behavior
If I pin the version of coverage used to ==5.0a5:

PS C:\Users\sam.willcocks\prog\coverage-bug-repro> tox
py3 recreate: C:\Users\sam.willcocks\prog\coverage-bug-repro\.tox\py3
py3 installdeps: py, pytest, pytest-cov, coverage==5.0a5
py3 installed: atomicwrites==1.3.0,attrs==19.3.0,colorama==0.4.3,coverage==5.0a5,importlib-metadata==1.3.0,more-itertools==8.0.2,packaging==19.2,pluggy==0.13.1,py==1.8.0,pyparsing==2.4.5,pytest==5.3.2,pytest-cov==2.8.1,six==1.13.0,wcwidth==0.1.7,zipp==0.6.0
py3 run-test-pre: PYTHONHASHSEED='845'
py3 run-test: commands[0] | python -m pytest --cov=foo tests/
=========================================================== test session starts ============================================================ 
platform win32 -- Python 3.7.4, pytest-5.3.2, py-1.8.0, pluggy-0.13.1
cachedir: .tox\py3\.pytest_cache
rootdir: C:\Users\sam.willcocks\prog\coverage-bug-repro
plugins: cov-2.8.1
collected 1 item                                                                                                                             

tests\test_nothing.py .                                                                                                               [100%]Coverage.py warning: No data was collected. (no-data-collected)


----------- coverage: platform win32, python 3.7.4-final-0 -----------
Name         Stmts   Miss  Cover
--------------------------------
foo\bar.py       2      2     0%


============================================================ 1 passed in 0.21s ============================================================= 
_________________________________________________________________ summary __________________________________________________________________ 
  py3: commands succeeded
  congratulations :)
  • then, running coverage html:
PS C:\Users\sam.willcocks\prog\coverage-bug-repro> tox -e coverage-report   
coverage-report recreate: C:\Users\sam.willcocks\prog\coverage-bug-repro\.tox\coverage-report
coverage-report installdeps: coverage==5.0a5
coverage-report installed: coverage==5.0a5
coverage-report run-test-pre: PYTHONHASHSEED='595'
coverage-report run-test: commands[0] | coverage html
_________________________________________________________________ summary __________________________________________________________________ 
  coverage-report: commands succeeded
  congratulations :)
@wlcx wlcx added the bug label Dec 16, 2019
@nedbat nedbat modified the milestones: 5.0.1, 5.0.2 Dec 16, 2019
nedbat added a commit that referenced this issue Jan 4, 2020
nedbat added a commit that referenced this issue Jan 4, 2020
@nedbat

This comment has been minimized.

Copy link
Owner

@nedbat nedbat commented Jan 4, 2020

This is fixed in aefe08b

@nedbat nedbat closed this Jan 4, 2020
@nedbat nedbat added the fixed label Jan 4, 2020
@nedbat

This comment has been minimized.

Copy link
Owner

@nedbat nedbat commented Jan 5, 2020

This is now available in coverage 5.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.