Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Document different ways to specify Django settings

  • Loading branch information...
commit 8d18ec0e3fd551e718fb0955da157cfa4e278aab 1 parent 0b4b281
Andreas Pelme pelme authored
Showing with 51 additions and 0 deletions.
  1. +50 −0 docs/configuring_django.rst
  2. +1 −0  docs/index.rst
50 docs/configuring_django.rst
View
@@ -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  docs/index.rst
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.