| 555 | Integration with coverage.py module |
| 556 | ----------------------------------- |
| 557 | |
| 558 | Code coverage describes how much source code have been tested. It indicates |
| 559 | quality of your tests - the better code coverage is, the more lines are covered |
| 560 | by tests and the better tests are. It's important part of testing applications, |
| 561 | so it's strongly recommended to check coverage. |
| 562 | |
| 563 | Django can be easily integrated with `coverage.py module`_. First, you have to |
| 564 | `install coverage.py`_. Now you are ready to use coverage module. |
| 565 | When you are in your project folder, type in your shell: |
| 566 | |
| 567 | .. _coverage.py module: http://nedbatchelder.com/code/coverage/ |
| 568 | .. _install coverage.py: http://pypi.python.org/pypi/coverage |
| 569 | |
| 570 | .. code-block:: bash |
| 571 | |
| 572 | coverage run --source='.' manage.py test myapp |
| 573 | |
| 574 | Now tests were launched and coverage data of all executed files in your project |
| 575 | folder was collected. You can see a report by typing following command: |
| 576 | |
| 577 | .. code-block:: bash |
| 578 | |
| 579 | coverage report |
| 580 | |
| 581 | Note that some of django code was executed during running tests, but |
| 582 | it was not listed here because of flag ``source`` given to previous command. |
| 583 | |
| 584 | After this all don't forget to delete all collected data by typing: |
| 585 | |
| 586 | .. code-block:: bash |
| 587 | |
| 588 | coverage erase |
| 589 | |
| 590 | Note that if you don't run last command, coverage data from next launching |
| 591 | will be append to existing data. |
| 592 | |