Coverage is not measured with Python 3.7.0
See original GitHub issueI’ve noticed that pytest-cov
doesn’t report properly the coverage with Python 3.7.0. Here a simple repro:
Directory structure
|-- foo
| |-- __init__.py
| `-- bar.py
`-- tests
|-- __init__.py
`-- test_baz.py
Files content
All __init__.py
files are empty.
bar.py
def baz():
print('baz')
test_baz.py
from foo import bar
def test_foo():
bar.baz()
pip freeze
for both Python 3.6.5 and 3.7.0 environments
$ pip freeze
atomicwrites==1.1.5
attrs==18.1.0
coverage==4.5.1
more-itertools==4.2.0
pluggy==0.6.0
py==1.5.4
pytest==3.6.3
pytest-cov==2.5.1
six==1.11.0
Test results with Python 3.6.5 (correct result)
$ py.test -p no:logging --strict --cov-report=term-missing --cov=foo tests
=========================================== test session starts ============================================
platform darwin -- Python 3.6.5, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /private/tmp/foo, inifile:
plugins: cov-2.5.1
collected 1 item
tests/test_baz.py . [100%]
---------- coverage: platform darwin, python 3.6.5-final-0 -----------
Name Stmts Miss Cover Missing
-----------------------------------------------
foo/__init__.py 0 0 100%
foo/bar.py 2 0 100%
-----------------------------------------------
TOTAL 2 0 100%
========================================= 1 passed in 0.03 seconds =========================================
Test results with Python 3.7.0 (incorrect result)
$ py.test -p no:logging --strict --cov-report=term-missing --cov=foo tests
=========================================== test session starts ============================================
platform darwin -- Python 3.7.0, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /private/tmp/foo, inifile:
plugins: cov-2.5.1
collected 1 item
tests/test_baz.py . [100%]
---------- coverage: platform darwin, python 3.7.0-final-0 -----------
Name Stmts Miss Cover Missing
-----------------------------------------------
foo/__init__.py 0 0 100%
foo/bar.py 2 2 0% 1-2
-----------------------------------------------
TOTAL 2 2 0%
========================================= 1 passed in 0.03 seconds =========================================
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Coverage.py — Coverage.py 7.0.0 documentation
Coverage.py is a tool for measuring code coverage of Python programs. It monitors your program, noting which parts of the code have been...
Read more >coverage 3.7.1 - PyPI
Coverage.py measures code coverage, typically during test execution. It uses the code analysis tools and tracing hooks provided in the Python standard ...
Read more >Sonarqube python code coverage show 0% - Sonar Community
My firm is running SonarQube via SonarQube Scanner for Jenkins. I am having an issue where SonarQube shows 0% code coverage for my...
Read more >pipenv requires python 3.7 but installed version is 3.8 and ...
[requires] python_version = "3.7". and the error: Warning: Python 3.7 was not found on your system… Sort of hints that pipenv is installed ......
Read more >Coverage.py - Read the Docs
By default, coverage.py does not measure code installed with the Python ... ,dnspython==2.1.0,eventlet==0.25.1,execnet==1.8.0,filelock==3.0.12,flaky==3.7.0,.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fwiw, i’m currently experiencing
the samea significant drop of covered statements with Python 3.8 (compared to 3.7).I cannot reproduce it either anymore, so either some new version of any of the dependency fixed it or there was something in my test environment that caused it.