Skip to content

Commit

Permalink
Flushed caches to pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Oct 17, 2024
1 parent 139e1bb commit ad69be7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/CreeDictionary/API/search/affix.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,16 @@ def preload(self):
self.source_language_affix_searcher
self.target_language_affix_searcher

def flush(self):
"""Flush caches"""
try:
del self.source_language_affix_searcher
except AttributeError:
pass
try:
del self.target_language_affix_searcher
except AttributeError:
pass


cache = _Cache()
5 changes: 4 additions & 1 deletion src/morphodict/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import pytest
from django.conf import settings
from CreeDictionary.API.search.affix import cache as affix_cache

# See “`conftest.py`: sharing fixtures across multiple files”
# https://docs.pytest.org/en/stable/fixture.html#conftest-py-sharing-fixtures-across-multiple-files
from django.core.management import call_command


@pytest.fixture(scope="module")
@pytest.fixture(scope="session")
def django_db_setup(request, django_db_blocker):
"""
Normally pytest-django creates a new, empty in-memory database and runs
Expand Down Expand Up @@ -50,3 +51,5 @@ def django_db_setup(request, django_db_blocker):
with django_db_blocker.unblock():
print("\nSyncing test database")
call_command("ensuretestdb", verbosity=0)
affix_cache.flush()
affix_cache.preload()

0 comments on commit ad69be7

Please sign in to comment.