Skip to content

Commit

Permalink
Added documentation for the new "coverage" option
Browse files Browse the repository at this point in the history
  • Loading branch information
reinout committed Jun 29, 2016
1 parent bf8ab1b commit ce5e84f
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ buildout users. For example:
- ``bin/django`` to run django instead of ``bin/python manage.py``.

- ``bin/test`` to run tests instead of ``bin/python manage.py test yourproject``.
(Including running coverage "around" your test).

- ``bin/django`` automatically uses the right django settings. So you can have
a ``development.cfg`` buildout config and a ``production.cfg``, each telling
Expand Down Expand Up @@ -112,6 +113,11 @@ eggs
you want to be available here. Often you'll have a list in the
``[buildout]`` part and re-use it here by saying ``${buildout:eggs}``.

coverage
If you set ``coverage = true``, ``bin/test`` will start coverage recording
before django starts. The ``coverage`` library must be importable. See the
extra coverage notes further below.

The options below are for older projects or special cases mostly:

dotted-settings-path
Expand Down Expand Up @@ -157,6 +163,49 @@ testrunner
defaults to `test`.



Coverage notes
--------------

Starting in django 1.7, you cannot use a custom test runner (like django-nose)
anymore to automatically run your tests with coverage enabled. The new app
initialization mechanism already loads your ``models.py``, for instance,
before the test runner gets called. So your ``models.py`` shows up as largely
untested.

With ``coverage = true``, ``bin/test`` starts coverage recording before django
gets called. It also prints out a report and export xml results (for recording
test results in Jenkins, for instance) and html results.

Behind the scenes, ``true`` is translated to a default of ``report xml_report
html_report``. These space-separated function names are called in turn on the
coverage instance. See the `coverage API docs
<http://coverage.readthedocs.io/en/latest/api.html>`_ for the available
functions. If you only want a quick report and xml output, you can set
``coverage = report xml_report`` instead.

Note that you cannot pass options to these functions, like html output
location. For that, add a ``.coveragerc`` next to your ``buildout.cfg``. See
the `coverage configuration file docs
<http://coverage.readthedocs.io/en/latest/config.html>`_. Here is an example::

[run]
omit =
*/migrations/*
*settings.py
source = your_app
[report]
show_missing = true

[html]
directory = htmlcov

[xml]
output = coverage.xml



Example configuration for mod_wsgi
---------------------------------------------------

Expand Down

0 comments on commit ce5e84f

Please sign in to comment.