Skip to content

Improve 'configuring' docs #642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions docs/configuring_django.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Example::
$ pytest --ds=test_settings


pytest.ini settings
-------------------
``pytest.ini`` settings
-----------------------

Example contents of pytest.ini::

Expand All @@ -41,20 +41,23 @@ Example contents of pytest.ini::
Order of choosing settings
--------------------------

When the command option `--ds`, the environment variable and the pytest.ini
configuration is used at the same time, pytest-django will prefer using
settings from the command line option `--ds`, then the environment variable and
last the pytest.ini.
You can use `addopts = --ds=yourtestsettings` in your pytest configuration
to automatically add the `--ds` option.
The order of precedence is, from highest to lowest:

* The command line option ``--ds``
* The environment variable ``DJANGO_SETTINGS_MODULE``
* The ``DJANGO_SETTINGS_MODULE`` option in the configuration file -
``pytest.ini``, or other file that Pytest finds such as ``tox.ini``

If you want to use the highest precedence in the configuration file, you can
use ``addopts = --ds=yourtestsettings``.

Using django-configurations
---------------------------

There is support for using `django-configurations <https://pypi.python.org/pypi/django-configurations/>`_.

To do so configure the settings class using an environment variable, the --dc
flag, or pytest.ini DJANGO_CONFIGURATION.
To do so configure the settings class using an environment variable, the
``--dc`` flag, or ``pytest.ini`` option ``DJANGO_CONFIGURATION``.

Environment Variable::

Expand All @@ -65,7 +68,6 @@ Command Line Option::

$ pytest --dc=MySettings


INI File Contents::

[pytest]
Expand Down