-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
16 additions
and
6 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 |
---|---|---|
@@ -1,5 +1,17 @@ | ||
from pytest_django.fixtures import django_db_setup | ||
from django.db import transaction | ||
from django.core.management import call_command | ||
import pytest | ||
|
||
|
||
# Make sure we are using the default in-memory database setup for import tests. | ||
# The redundant assignment keeps PyCharm from optimizing the import away. | ||
django_db_setup = django_db_setup | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def django_db_setup(request, django_db_blocker): | ||
with django_db_blocker.unblock(): | ||
# atomic transaction lets us rollback the status of the database once done. | ||
with transaction.atomic(): | ||
# flush command empties the database for purposes of this module. | ||
call_command("flush", verbosity=0, interactive=False) | ||
yield | ||
transaction.set_rollback(True) |
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