Coverage.py Vs pytest-cov
Asked Answered
C

1

27

The documentation of coverage.py says that Many people choose to use the pytest-cov plugin, but for most purposes, it is unnecessary. So I would like to know what is the difference between these two? And which one is the most efficient ?

Thank you in advance

Chou answered 7/3, 2022 at 10:59 Comment(0)
M
26

pytest-cov uses coverage.py, so there's no different in efficiency, or basic behavior. pytest-cov auto-configures multiprocessing settings, and ferries data around if you use pytest-xdist.

Maturation answered 8/3, 2022 at 0:46 Comment(3)
One unusual case where you'd rather use coverage directly is when you test the coverage of a pytest plugin, as discussed in how-to-get-coverage-reporting-when-testing-a-pytest-pluginAestheticism
So If I want to create a github action and calculate my code coverage using coverage run -m pytest do I need to install coverage.py also or just existing pytest-cov will do the work for me?Flaviaflavian
When you install pytest-cov, it pulls in coverage.py as a dependency. If you want to use coverage run -m pytest, you don't need pytest-cov at all.Maturation

© 2022 - 2024 — McMap. All rights reserved.