Skip to content

Commit bc9cda3

Browse files
authored
bit more explicit use case for configure + settings fixture (#890)
1 parent e4ebc59 commit bc9cda3

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

docs/configuring_django.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ INI File Contents::
7676
Using ``django.conf.settings.configure()``
7777
------------------------------------------
7878

79-
Django settings can be set up by calling ``django.conf.settings.configure()``.
79+
In case there is no ``DJANGO_SETTINGS_MODULE``, the ``settings`` object can be
80+
created by calling ``django.conf.settings.configure()``.
8081

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

@@ -85,6 +86,22 @@ This can be done from your project's ``conftest.py`` file::
8586
def pytest_configure():
8687
settings.configure(DATABASES=...)
8788

89+
Overriding individual settings
90+
------------------------------
91+
92+
Settings can be overridden by using the :fixture:`settings` fixture::
93+
94+
@pytest.fixture(autouse=True)
95+
def use_dummy_cache_backend(settings):
96+
settings.CACHES = {
97+
"default": {
98+
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
99+
}
100+
}
101+
102+
Here `autouse=True` is used, meaning the fixture is automatically applied to all tests,
103+
but it can also be requested individually per-test.
104+
88105
Changing your app before Django gets set up
89106
-------------------------------------------
90107

0 commit comments

Comments
 (0)