From 87a187d6d571ce6541efa9aaec6fdc29012ebf17 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 31 May 2020 19:05:42 -0400 Subject: [PATCH] Add instructions to view the test coverage reports locally After tests, run `coverage html` to generate coverage reports in HTML format. The coverage reports is located in the `htmlcov` directory by default. --- .gitignore | 1 + CONTRIBUTING.md | 3 ++- Makefile | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 7e18dc2d5bb..1eb612389e0 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ MANIFEST .ipynb_checkpoints/ .vscode/ tmp-test-dir-with-unique-name/ +htmlcov build/ dist/ doc/_build diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 98c1ef166a5..9c0560beb47 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -303,7 +303,8 @@ Run the tests and calculate test coverage using: make test The coverage report will let you know which lines of code are touched by the tests. -**Strive to get 100% coverage for the lines you changed.** +If all the tests pass, you can view the coverage reports by opening `htmlcov/index.html` +in your browser. **Strive to get 100% coverage for the lines you changed.** It's OK if you can't or don't know how to test something. Leave a comment in the PR and we'll help you out. diff --git a/Makefile b/Makefile index d618ae51cb9..97e93bcfbda 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ test: @cd $(TESTDIR); python -c "import $(PROJECT); $(PROJECT).show_versions()" @echo "" cd $(TESTDIR); pytest $(PYTEST_ARGS) $(PROJECT) - cp $(TESTDIR)/.coverage* . + cp $(TESTDIR)/.coverage* . && coverage html rm -r $(TESTDIR) format: @@ -43,6 +43,6 @@ lint: clean: find . -name "*.pyc" -exec rm -v {} \; find . -name "*~" -exec rm -v {} \; - rm -rvf build dist MANIFEST *.egg-info __pycache__ .coverage .cache + rm -rvf build dist MANIFEST *.egg-info __pycache__ .coverage .cache htmlcov rm -rvf $(TESTDIR) rm -rvf baseline