Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Oct 17, 2024
1 parent 939edf3 commit 6eb7fa8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 15 additions & 3 deletions src/morphodict/lexicon/importer/conftest.py
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)
4 changes: 1 addition & 3 deletions src/morphodict/lexicon/importer/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ def class_scoped_db(request: pytest.FixtureRequest, django_db_blocker: DjangoDbB
with multiple tests in which the same DB transaction is used for all tests
in the class.
"""
_django_db_helper(
request=request, django_db_setup=None, django_db_blocker=django_db_blocker
)
pass


# Tests
Expand Down

0 comments on commit 6eb7fa8

Please sign in to comment.