Skip to content

Commit a8d6833

Browse files
committed
Docs example on how to use the same database for all xdist processes.
Refs pytest-dev#98.
1 parent c35b0c2 commit a8d6833

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Diff for: docs/database.rst

+18-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ pytest-django fixture is used to create the test database. When
349349
``call_command`` is invoked, the test database is already prepared and
350350
configured.
351351

352-
Put this in conftest.py::
352+
Put this in ``conftest.py``::
353353

354354
import pytest
355355

@@ -359,3 +359,20 @@ Put this in conftest.py::
359359
def django_db_setup(django_db_setup, django_db_blocker):
360360
with django_db_blocker:
361361
call_command('loaddata', 'your_data_fixture.json')
362+
363+
Use the same database for all xdist processes
364+
"""""""""""""""""""""""""""""""""""""""""""""
365+
366+
By default, each xdist process gets its own database to run tests on. This is
367+
needed to have transactional tests that does not interfere with eachother.
368+
369+
If you instead want your tests to use the same database, override the
370+
:fixture:`django_db_modify_db_settings` to not do anything. Put this in
371+
``conftest.py``::
372+
373+
import pytest
374+
375+
376+
@pytest.fixture(scope='session')
377+
def django_db_modify_db_settings():
378+
pass

0 commit comments

Comments
 (0)