Skip to content

Commit

Permalink
Document different ways to specify Django settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pelme committed Dec 9, 2012
1 parent 0b4b281 commit 8d18ec0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
50 changes: 50 additions & 0 deletions docs/configuring_django.rst
@@ -0,0 +1,50 @@
Configuring the Django Settings
===============================

There are a couple of different ways Django settings can be provided for
the tests.

The environment variable ``DJANGO_SETTINGS_MODULE``
---------------------------------------------------

Running the tests with DJANGO_SETTINGS_MODULE defined will find the
Django settings the same way Django does by default.

Example::

$ export DJANGO_SETTINGS_MODULE=test_settings
$ py.test

or::

$ DJANGO_SETTINGS_MODULE=test_settings py.test


Command line option ``--ds=SETTINGS``
-------------------------------------

Example::

$ py.test --ds=test_settings


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

Example contents of pytest.ini::

[pytest]
DJANGO_SETTINGS_MODULE = test_settings

Using ``django.conf.settings.configure()``
------------------------------------------

Django settings can be set up by calling ``django.conf.settings.configure()``.

This can be done from your project's ``conftest.py`` file::

from django.conf import settings

def pytest_configure():
settings.configure(DATABASES=...)

1 change: 1 addition & 0 deletions docs/index.rst
Expand Up @@ -7,6 +7,7 @@ pytest-django is a plugin for `py.test <http://pytest.org/>`_ that provides a se
:maxdepth: 3

tutorial
configuring_django
database
helpers
faq
Expand Down

0 comments on commit 8d18ec0

Please sign in to comment.