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 #4501 - Documented how to use coverage.py with Django t…

…ests.

Thanks krzysiumed for the draft patch.

Backport of 7ef2781 from master.
  • Loading branch information...
commit 1be0515fe9940a7a727680a775395fe5f0c12b1d 1 parent c06b724
Tim Graham authored October 10, 2012

Showing 1 changed file with 43 additions and 0 deletions. Show diff stats Hide diff stats

  1. 43  docs/topics/testing.txt
43  docs/topics/testing.txt
@@ -560,6 +560,49 @@ failed and erroneous tests. If all the tests pass, the return code is 0. This
560 560
 feature is useful if you're using the test-runner script in a shell script and
561 561
 need to test for success or failure at that level.
562 562
 
  563
+Speeding up the tests
  564
+---------------------
  565
+
  566
+In recent versions of Django, the default password hasher is rather slow by
  567
+design. If during your tests you are authenticating many users, you may want
  568
+to use a custom settings file and set the :setting:`PASSWORD_HASHERS` setting
  569
+to a faster hashing algorithm::
  570
+
  571
+    PASSWORD_HASHERS = (
  572
+        'django.contrib.auth.hashers.MD5PasswordHasher',
  573
+    )
  574
+
  575
+Don't forget to also include in :setting:`PASSWORD_HASHERS` any hashing
  576
+algorithm used in fixtures, if any.
  577
+
  578
+Integration with coverage.py
  579
+----------------------------
  580
+
  581
+Code coverage describes how much source code has been tested. It shows which
  582
+parts of your code are being exercised by tests and which are not. It's an
  583
+important part of testing applications, so it's strongly recommended to check
  584
+the coverage of your tests.
  585
+
  586
+Django can be easily integrated with `coverage.py`_, a tool for measuring code
  587
+coverage of Python programs. First, `install coverage.py`_. Next, run the
  588
+following from your project folder containing ``manage.py``::
  589
+
  590
+   coverage run --source='.' manage.py test myapp
  591
+
  592
+This runs your tests and collects coverage data of the executed files in your
  593
+project. You can see a report of this data by typing following command::
  594
+
  595
+   coverage report
  596
+
  597
+Note that some Django code was executed while running tests, but it is not
  598
+listed here because of the ``source`` flag passed to the previous command.
  599
+
  600
+For more options like annotated HTML listings detailing missed lines, see the
  601
+`coverage.py`_ docs.
  602
+
  603
+.. _coverage.py: http://nedbatchelder.com/code/coverage/
  604
+.. _install coverage.py: http://pypi.python.org/pypi/coverage
  605
+
563 606
 Testing tools
564 607
 =============
565 608
 

0 notes on commit 1be0515

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