From b336d04acab3c879402ac022ea31208b9ebd26ed Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Mar 30 2017 13:22:08 +0000 Subject: Add a note about coveragerc files. Using a .coveragerc file _should_ work with any plugin that uses coverage. Signed-off-by: Jeremy Cline --- diff --git a/docs/dev-guide/writing-tests.rst b/docs/dev-guide/writing-tests.rst index e1bd5c8..195ee4e 100644 --- a/docs/dev-guide/writing-tests.rst +++ b/docs/dev-guide/writing-tests.rst @@ -128,17 +128,34 @@ Coverage integration for the `nose`_ test runner. It's possible (and recommended) to have the test suite fail if the coverage -percentage goes down. For example, placing the following in ``setup.cfg``:: - - [nosetests] - with-coverage=TRUE - cover-min-percentage=100 - cover-package=mypackage - -causes `nose`_ to fail the test suite if the coverage level is not 100%. New -projects should enforce 100% test coverage. Exist projects should ensure test -coverage does not drop to accept a pull request and should increase the minimum -test coverage until it is 100%. +percentage goes down. This example ``.coveragerc``:: + + [run] + # Track what conditional branches are covered. + branch = True + include = + my_python_package/* + + [report] + # Fail if the coverage is not 100% + fail_under = 100 + # Display results with up 1/100th of a percent accuracy. + precision = 2 + exclude_lines = + pragma: no cover + + # Don't complain if tests don't hit defensive assertion code + raise AssertionError + raise NotImplementedError + + if __name__ == .__main__.: + omit = + my_python_package/tests/* + +causes coverage (and any test running plugins using coverage) to fail if the +coverage level is not 100%. New projects should enforce 100% test coverage. +Existing projects should ensure test coverage does not drop to accept a pull +request and should increase the minimum test coverage until it is 100%. .. note:: `coverage`_ has great `exclusion`_ support, so you can exclude individual