Clear cache for other tests as well

This commit is contained in:
nabenabe0928
2023-12-07 08:55:15 +01:00
parent a5e2be25b5
commit aa0fccc65e
4 changed files with 14 additions and 9 deletions
@@ -9,6 +9,7 @@ from playwright.sync_api import Page
import pytest
from ...test_server import make_test_server
from ...utils import clear_inmemory_cache
def make_test_storage() -> optuna.storages.InMemoryStorage:
@@ -43,6 +44,7 @@ def make_test_storage() -> optuna.storages.InMemoryStorage:
@pytest.fixture
def storage() -> optuna.storages.InMemoryStorage:
clear_inmemory_cache()
storage = make_test_storage()
return storage
@@ -3,6 +3,7 @@ from playwright.sync_api import Page
import pytest
from ...test_server import make_test_server
from ...utils import clear_inmemory_cache
def make_test_storage() -> optuna.storages.InMemoryStorage:
@@ -23,6 +24,7 @@ def make_test_storage() -> optuna.storages.InMemoryStorage:
@pytest.fixture
def storage() -> optuna.storages.InMemoryStorage:
clear_inmemory_cache()
storage = make_test_storage()
return storage
@@ -1,19 +1,11 @@
from typing import Callable
import optuna
from optuna_dashboard._storage import trials_cache
from optuna_dashboard._storage import trials_cache_lock
from optuna_dashboard._storage import trials_last_fetched_at
from playwright.sync_api import Page
import pytest
from ..test_server import make_test_server
def clear_inmemory_cache() -> None:
with trials_cache_lock:
trials_cache.clear()
trials_last_fetched_at.clear()
from ..utils import clear_inmemory_cache
@pytest.fixture
+9
View File
@@ -0,0 +1,9 @@
from optuna_dashboard._storage import trials_cache
from optuna_dashboard._storage import trials_cache_lock
from optuna_dashboard._storage import trials_last_fetched_at
def clear_inmemory_cache() -> None:
with trials_cache_lock:
trials_cache.clear()
trials_last_fetched_at.clear()