Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #16817 - Added a guide of code coverage to contributing docs.

Thanks Pedro Lima for the draft patch.
  • Loading branch information...
commit 06f5da3d7813e9a23b1e98ecf8b75fc6073800e9 1 parent 7ef2781
Tim Graham authored October 11, 2012
2  .gitignore
@@ -4,3 +4,5 @@
4 4
 MANIFEST
5 5
 dist/
6 6
 docs/_build/
  7
+tests/coverage_html/
  8
+tests/.coverage
2  .hgignore
@@ -4,3 +4,5 @@ syntax:glob
4 4
 *.pot
5 5
 *.py[co]
6 6
 docs/_build/
  7
+tests/coverage_html/
  8
+tests/.coverage
20  docs/internals/contributing/writing-code/unit-tests.txt
@@ -163,6 +163,26 @@ associated tests will be skipped.
163 163
 .. _gettext: http://www.gnu.org/software/gettext/manual/gettext.html
164 164
 .. _selenium: http://pypi.python.org/pypi/selenium
165 165
 
  166
+Code coverage
  167
+~~~~~~~~~~~~~
  168
+
  169
+Contributors are encouraged to run coverage on the test suite to identify areas
  170
+that need additional tests. The coverage tool installation and use is described
  171
+in :ref:`testing code coverage<topics-testing-code-coverage>`.
  172
+
  173
+To run coverage on the Django test suite using the standard test settings::
  174
+
  175
+    coverage run ./runtests.py --settings=test_sqlite
  176
+
  177
+After running coverage, generate the html report by running::
  178
+
  179
+    coverage html
  180
+
  181
+When running coverage for the Django tests, the included ``.coveragerc``
  182
+settings file  defines ``coverage_html`` as the output directory for the report
  183
+and also excludes several directories not relevant to the results
  184
+(test code or external code included in Django).
  185
+
166 186
 .. _contrib-apps:
167 187
 
168 188
 Contrib apps
2  docs/topics/testing.txt
@@ -589,6 +589,8 @@ to a faster hashing algorithm::
589 589
 Don't forget to also include in :setting:`PASSWORD_HASHERS` any hashing
590 590
 algorithm used in fixtures, if any.
591 591
 
  592
+.. _topics-testing-code-coverage:
  593
+
592 594
 Integration with coverage.py
593 595
 ----------------------------
594 596
 
5  tests/.coveragerc
... ...
@@ -0,0 +1,5 @@
  1
+[run]
  2
+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
  3
+
  4
+[html]
  5
+directory = coverage_html

0 notes on commit 06f5da3

Please sign in to comment.
Something went wrong with that request. Please try again.