Skip to content

Add StorageTestCase class in optuna.testing package#6369

Merged
kAIto47802 merged 3 commits intooptuna:masterfrom
c-bata:storage-test-case
Dec 18, 2025
Merged

Add StorageTestCase class in optuna.testing package#6369
kAIto47802 merged 3 commits intooptuna:masterfrom
c-bata:storage-test-case

Conversation

@c-bata
Copy link
Copy Markdown
Member

@c-bata c-bata commented Dec 5, 2025

Motivation

Third-party storage implementations currently have to copy Optuna’s storage tests (which is written in tests/storage_tests/test_storage.py). By exposing the shared StorageTestCase in optuna.testing, third-party Optuna storages can run the same test suites, improving consistency and fixing compatibility issues without duplicating test logic.

Description of the changes

This PR suggests to exposing StorageTestCase, so that third-party Optuna storages can write tests like below:

import pytest
from optuna.testing.pytest_storages import StorageTestCase
from optuna_integration.dask import DaskStorage


@pytest.fixture
def storage() -> BaseStorage:
    return DaskStorage(...)

class TestDaskStorageCase(StorageTestCase):
     @pytest.mark.skip("DaskStorage does not support this feature")
     def test_pickle(self, storage: BaseStorage) -> None:
        ...

@c-bata c-bata force-pushed the storage-test-case branch from 62e6591 to 316732f Compare December 5, 2025 07:32
@c-bata c-bata added the code-fix Change that does not change the behavior, such as code refactoring. label Dec 5, 2025
@c-bata c-bata changed the title Add StorageTesstCase class in optuna.testing package Add StorageTestCase class in optuna.testing package Dec 5, 2025
@c-bata c-bata marked this pull request as ready for review December 10, 2025 04:33
Copy link
Copy Markdown
Member

@y0z y0z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I confirmed that all tests work.

test_storages.py .................................................................................................................................................................................................. [ 49%]
...........................................................................................................................................................................................ssss....s.....           [100%]

@y0z y0z added this to the v4.7.0 milestone Dec 15, 2025
@y0z y0z removed their assignment Dec 15, 2025
Copy link
Copy Markdown
Collaborator

@kAIto47802 kAIto47802 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR. LGTM
I've checked the all lines and confirmed that there are no missing tests and all tests are identical.

@kAIto47802 kAIto47802 merged commit a8f7033 into optuna:master Dec 18, 2025
13 of 14 checks passed
@c-bata c-bata deleted the storage-test-case branch December 18, 2025 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-fix Change that does not change the behavior, such as code refactoring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants