Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document different ways to specify Django settings
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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=...) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters