Skip to content

Commit

Permalink
Fixed django#16817 - Added a guide of code coverage to contributing d…
Browse files Browse the repository at this point in the history
…ocs.

Thanks Pedro Lima for the draft patch.
  • Loading branch information
timgraham committed Oct 11, 2012
1 parent 7ef2781 commit 06f5da3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -4,3 +4,5 @@
MANIFEST
dist/
docs/_build/
tests/coverage_html/
tests/.coverage
2 changes: 2 additions & 0 deletions .hgignore
Expand Up @@ -4,3 +4,5 @@ syntax:glob
*.pot
*.py[co]
docs/_build/
tests/coverage_html/
tests/.coverage
20 changes: 20 additions & 0 deletions docs/internals/contributing/writing-code/unit-tests.txt
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/topics/testing.txt
Expand Up @@ -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
----------------------------

Expand Down
5 changes: 5 additions & 0 deletions 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

0 comments on commit 06f5da3

Please sign in to comment.