Reputation: 1291
I want to run pytest with coverage (pytest-cov) for my set of tests (stored in ./test) + doctests (stored in ./myproj/*.py) in a single command but I seem to be unable to get it to work
Running the unittests separately and appending the results from doctest works fine e.g.
pytest --cov=myproj --cov-report=html --cov-report=xml --cov-context=test
pytest --cov=myproj --cov-report=html --cov-report=xml --cov-append --doctest-modules
for CI this is fine bug for local testing it is rather annoying to have to type the second command every time.
Attempting to combine the two commands e.g.
pytest --cov=myproj --cov-report=html --cov-report=xml --cov-context=test --doctest-modules myproj
only runs the doctests.
Am I missing something obvious?
Upvotes: 0
Views: 1480
Reputation: 1291
After a bit of searching it dawned on me that I had to include both myproj
and test
directories and now coverage includes both tests and doctests
pytest myproj test --cov=myproj --cov-report=html --cov-report=xml --cov-context=test --doctest-modules
Upvotes: 0