File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ INI File Contents::
76
76
Using ``django.conf.settings.configure() ``
77
77
------------------------------------------
78
78
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() ``.
80
81
81
82
This can be done from your project's ``conftest.py `` file::
82
83
@@ -85,6 +86,22 @@ This can be done from your project's ``conftest.py`` file::
85
86
def pytest_configure():
86
87
settings.configure(DATABASES=...)
87
88
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
+
88
105
Changing your app before Django gets set up
89
106
-------------------------------------------
90
107
You can’t perform that action at this time.
0 commit comments