Skip to content

Commit

Permalink
Merge pull request #746 from keisuke-umezawa/feature/clear-cache-when…
Browse files Browse the repository at this point in the history
…-terminating

Clear in-memory cache when terminating test
  • Loading branch information
keisuke-umezawa authored Jan 16, 2024
2 parents 7c4f673 + be2c334 commit 2903945
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import pytest

from ...test_server import make_test_server
from ...utils import clear_inmemory_cache


def make_test_storage() -> optuna.storages.InMemoryStorage:
Expand Down Expand Up @@ -44,7 +43,6 @@ def make_test_storage() -> optuna.storages.InMemoryStorage:

@pytest.fixture
def storage() -> optuna.storages.InMemoryStorage:
clear_inmemory_cache()
storage = make_test_storage()
return storage

Expand Down
2 changes: 0 additions & 2 deletions e2e_tests/test_dashboard/test_usecases/test_study_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest

from ...test_server import make_test_server
from ...utils import clear_inmemory_cache


def make_test_storage() -> optuna.storages.InMemoryStorage:
Expand All @@ -24,7 +23,6 @@ def objective_single(trial: optuna.Trial) -> float:

@pytest.fixture
def storage() -> optuna.storages.InMemoryStorage:
clear_inmemory_cache()
storage = make_test_storage()
return storage

Expand Down
2 changes: 0 additions & 2 deletions e2e_tests/test_dashboard/visual_regression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import pytest

from ..test_server import make_test_server
from ..utils import clear_inmemory_cache


@pytest.fixture
def storage() -> optuna.storages.InMemoryStorage:
clear_inmemory_cache()
storage = optuna.storages.InMemoryStorage()
return storage

Expand Down
3 changes: 3 additions & 0 deletions e2e_tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from optuna_dashboard import wsgi
import pytest

from .utils import clear_inmemory_cache


def get_free_port() -> int:
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expand All @@ -28,6 +30,7 @@ def make_test_server(
thread.start()

def stop_server() -> None:
clear_inmemory_cache()
httpd.shutdown()
httpd.server_close()
thread.join()
Expand Down

0 comments on commit 2903945

Please sign in to comment.