Skip to content

Commit ee4694e

Browse files
authored
Add instructions to view the test coverage reports locally (#468)
After tests, run `coverage html` to generate coverage reports in HTML format. It's automatically by `make test`. The coverage reports are located in the `htmlcov` directory by default, and can be viewed by opening `htmlcov/index.html` in a browser.
1 parent ec5e92c commit ee4694e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ MANIFEST
1212
.ipynb_checkpoints/
1313
.vscode/
1414
tmp-test-dir-with-unique-name/
15+
htmlcov
1516
build/
1617
dist/
1718
doc/_build

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ Run the tests and calculate test coverage using:
303303
make test
304304

305305
The coverage report will let you know which lines of code are touched by the tests.
306-
**Strive to get 100% coverage for the lines you changed.**
306+
If all the tests pass, you can view the coverage reports by opening `htmlcov/index.html`
307+
in your browser. **Strive to get 100% coverage for the lines you changed.**
307308
It's OK if you can't or don't know how to test something.
308309
Leave a comment in the PR and we'll help you out.
309310

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test:
2727
@cd $(TESTDIR); python -c "import $(PROJECT); $(PROJECT).show_versions()"
2828
@echo ""
2929
cd $(TESTDIR); pytest $(PYTEST_ARGS) $(PROJECT)
30-
cp $(TESTDIR)/.coverage* .
30+
cp $(TESTDIR)/.coverage* . && coverage html
3131
rm -r $(TESTDIR)
3232

3333
format:
@@ -43,6 +43,6 @@ lint:
4343
clean:
4444
find . -name "*.pyc" -exec rm -v {} \;
4545
find . -name "*~" -exec rm -v {} \;
46-
rm -rvf build dist MANIFEST *.egg-info __pycache__ .coverage .cache
46+
rm -rvf build dist MANIFEST *.egg-info __pycache__ .coverage .cache htmlcov
4747
rm -rvf $(TESTDIR)
4848
rm -rvf baseline

0 commit comments

Comments
 (0)