Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.4.X] Fixed #16817 - Added a guide of code coverage to contributing…

… docs.

Thanks Pedro Lima for the draft patch.

Backport of 06f5da3 from master
  • Loading branch information...
commit 3ac70a5907e054c734ca26e435f1ec1215797b08 1 parent 1be0515
Tim Graham authored
2  .gitignore
@@ -2,3 +2,5 @@
2 2
 *.pot
3 3
 *.py[co]
4 4
 docs/_build/
  5
+tests/coverage_html/
  6
+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
@@ -165,6 +165,26 @@ associated tests will be skipped.
165 165
 .. _gettext: http://www.gnu.org/software/gettext/manual/gettext.html
166 166
 .. _selenium: http://pypi.python.org/pypi/selenium
167 167
 
  168
+Code coverage
  169
+~~~~~~~~~~~~~
  170
+
  171
+Contributors are encouraged to run coverage on the test suite to identify areas
  172
+that need additional tests. The coverage tool installation and use is described
  173
+in :ref:`testing code coverage<topics-testing-code-coverage>`.
  174
+
  175
+To run coverage on the Django test suite using the standard test settings::
  176
+
  177
+    coverage run ./runtests.py --settings=test_sqlite
  178
+
  179
+After running coverage, generate the html report by running::
  180
+
  181
+    coverage html
  182
+
  183
+When running coverage for the Django tests, the included ``.coveragerc``
  184
+settings file  defines ``coverage_html`` as the output directory for the report
  185
+and also excludes several directories not relevant to the results
  186
+(test code or external code included in Django).
  187
+
168 188
 .. _contrib-apps:
169 189
 
170 190
 Contrib apps
2  docs/topics/testing.txt
@@ -575,6 +575,8 @@ to a faster hashing algorithm::
575 575
 Don't forget to also include in :setting:`PASSWORD_HASHERS` any hashing
576 576
 algorithm used in fixtures, if any.
577 577
 
  578
+.. _topics-testing-code-coverage:
  579
+
578 580
 Integration with coverage.py
579 581
 ----------------------------
580 582
 
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 3ac70a5

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