diff options
author | Tim Graham <timograham@gmail.com> | 2012-10-11 06:11:52 -0400 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2012-10-11 06:11:52 -0400 |
commit | 06f5da3d7813e9a23b1e98ecf8b75fc6073800e9 (patch) | |
tree | b452f60b10ad562b9b241afac7914a1cfce78ea6 | |
parent | 7ef2781ca0ce48872e21dce2f322c9e4106d1cfd (diff) | |
download | django-06f5da3d7813e9a23b1e98ecf8b75fc6073800e9.tar.gz |
Fixed #16817 - Added a guide of code coverage to contributing docs.
Thanks Pedro Lima for the draft patch.
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .hgignore | 2 | ||||
-rw-r--r-- | docs/internals/contributing/writing-code/unit-tests.txt | 20 | ||||
-rw-r--r-- | docs/topics/testing.txt | 2 | ||||
-rw-r--r-- | tests/.coveragerc | 5 |
5 files changed, 31 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index 17e39abd38..2d028c7287 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ MANIFEST dist/ docs/_build/ +tests/coverage_html/ +tests/.coverage
\ No newline at end of file @@ -4,3 +4,5 @@ syntax:glob *.pot *.py[co] docs/_build/ +tests/coverage_html/ +tests/.coverage
\ No newline at end of file diff --git a/docs/internals/contributing/writing-code/unit-tests.txt b/docs/internals/contributing/writing-code/unit-tests.txt index 4de506a654..a828b06b36 100644 --- a/docs/internals/contributing/writing-code/unit-tests.txt +++ b/docs/internals/contributing/writing-code/unit-tests.txt @@ -163,6 +163,26 @@ associated tests will be skipped. .. _gettext: http://www.gnu.org/software/gettext/manual/gettext.html .. _selenium: http://pypi.python.org/pypi/selenium +Code coverage +~~~~~~~~~~~~~ + +Contributors are encouraged to run coverage on the test suite to identify areas +that need additional tests. The coverage tool installation and use is described +in :ref:`testing code coverage<topics-testing-code-coverage>`. + +To run coverage on the Django test suite using the standard test settings:: + + coverage run ./runtests.py --settings=test_sqlite + +After running coverage, generate the html report by running:: + + coverage html + +When running coverage for the Django tests, the included ``.coveragerc`` +settings file defines ``coverage_html`` as the output directory for the report +and also excludes several directories not relevant to the results +(test code or external code included in Django). + .. _contrib-apps: Contrib apps diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt index f907c72a5e..d0b2e7cdf9 100644 --- a/docs/topics/testing.txt +++ b/docs/topics/testing.txt @@ -589,6 +589,8 @@ to a faster hashing algorithm:: Don't forget to also include in :setting:`PASSWORD_HASHERS` any hashing algorithm used in fixtures, if any. +.. _topics-testing-code-coverage: + Integration with coverage.py ---------------------------- diff --git a/tests/.coveragerc b/tests/.coveragerc new file mode 100644 index 0000000000..b979e94c58 --- /dev/null +++ b/tests/.coveragerc @@ -0,0 +1,5 @@ +[run] +omit = runtests,test_sqlite,regressiontests*,modeltests*,*/django/contrib/*/tests*,*/django/utils/unittest*,*/django/utils/simplejson*,*/django/utils/importlib.py,*/django/test/_doctest.py,*/django/core/servers/fastcgi.py,*/django/utils/autoreload.py,*/django/utils/dictconfig.py + +[html] +directory = coverage_html |