Skip to content

Commit

Permalink
Skip test with Python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
not522 committed Oct 6, 2023
1 parent a5e102d commit df13fff
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python_tests/preferential/test_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import copy
import multiprocessing
import pickle
import sys
from typing import Callable
from unittest.mock import patch
import uuid

import pytest

from optuna import copy_study
from optuna import create_trial
from optuna import delete_study
Expand All @@ -22,6 +25,9 @@
from ..storage_supplier import StorageSupplier


pytest.mark.skipif(sys.version_info < (3, 8), "BoTorch dropped Python3.7 support", allow_module_level=True)


@parametrize_storages
def test_study_set_and_get_user_attrs(storage_supplier: Callable[[], StorageSupplier]) -> None:
with storage_supplier() as storage:
Expand Down
10 changes: 10 additions & 0 deletions python_tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from __future__ import annotations

import json
import sys
from unittest import TestCase

import pytest

import optuna
from optuna import get_all_study_summaries
from optuna.study import StudyDirection
Expand Down Expand Up @@ -105,6 +108,7 @@ def test_get_study_details_with_after_param_illegal(self) -> None:
)
self.assertEqual(status, 400)

@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
def test_get_best_trials_of_preferential_study(self) -> None:
storage = optuna.storages.InMemoryStorage()
study = create_study(n_generate=4, storage=storage)
Expand All @@ -128,6 +132,7 @@ def test_get_best_trials_of_preferential_study(self) -> None:
assert len(best_trials) == 1
assert best_trials[0]["number"] == 0

@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
def test_report_preference(self) -> None:
storage = optuna.storages.InMemoryStorage()
study = create_study(n_generate=4, storage=storage)
Expand Down Expand Up @@ -161,6 +166,7 @@ def test_report_preference(self) -> None:
assert better.number == 2
assert worse.number == 1

@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
def test_report_preference_when_typo_mode(self) -> None:
storage = optuna.storages.InMemoryStorage()
study = create_study(storage=storage, n_generate=3)
Expand All @@ -184,6 +190,7 @@ def test_report_preference_when_typo_mode(self) -> None:
)
self.assertEqual(status, 400)

@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
def test_change_component(self) -> None:
storage = optuna.storages.InMemoryStorage()
study = create_study(storage=storage, n_generate=3)
Expand Down Expand Up @@ -214,6 +221,7 @@ def test_change_component(self) -> None:
assert study_detail["feedback_component_type"]["output_type"] == "artifact"
assert study_detail["feedback_component_type"]["artifact_key"] == "image"

@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
def test_skip_trial(self) -> None:
storage = optuna.storages.InMemoryStorage()
study = create_study(n_generate=4, storage=storage)
Expand All @@ -238,6 +246,7 @@ def test_skip_trial(self) -> None:
assert len(best_trials) == 1
assert best_trials[0].number == 2

@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
def test_remove_history(self) -> None:
storage = optuna.storages.InMemoryStorage()
study = create_study(storage=storage, n_generate=3)
Expand Down Expand Up @@ -271,6 +280,7 @@ def test_remove_history(self) -> None:
assert histories[0]["is_removed"]
assert len(study.get_preferences()) == 0

@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
def test_restore_history(self) -> None:
storage = optuna.storages.InMemoryStorage()
study = create_study(storage=storage, n_generate=3)
Expand Down
6 changes: 6 additions & 0 deletions python_tests/test_preferential_history.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from __future__ import annotations

import json
import sys
from typing import Callable
from typing import TYPE_CHECKING

import pytest

from optuna.storages import BaseStorage
from optuna_dashboard._preferential_history import _SYSTEM_ATTR_PREFIX_HISTORY
from optuna_dashboard._preferential_history import NewHistory
Expand All @@ -22,6 +25,9 @@
from optuna_dashboard._preferential_history import History


pytest.mark.skipif(sys.version_info < (3, 8), "BoTorch dropped Python3.7 support", allow_module_level=True)


@parametrize_storages
def test_report_and_get_choices(storage_supplier: Callable[[], StorageSupplier]) -> None:
with storage_supplier() as storage:
Expand Down
6 changes: 6 additions & 0 deletions python_tests/test_serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from __future__ import annotations

import sys

import pytest

import optuna
from optuna_dashboard._serializer import serialize_attrs
from optuna_dashboard._serializer import serialize_study_detail
Expand All @@ -22,6 +26,7 @@ def test_serialize_dict() -> None:
assert len(serialized) <= 1


@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
def test_get_study_detail_is_preferential() -> None:
storage = optuna.storages.InMemoryStorage()
study = create_study(n_generate=4, storage=storage)
Expand All @@ -48,6 +53,7 @@ def test_get_study_detail_is_not_preferential() -> None:
assert not study_detail["is_preferential"]


@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
def test_get_study_summary_is_preferential() -> None:
storage = optuna.storages.InMemoryStorage()
create_study(n_generate=4, storage=storage)
Expand Down

0 comments on commit df13fff

Please sign in to comment.