Dispose SQLAlchemy's engine in storage_tests/test_with_server.py#6330
Merged
Alnusjaponica merged 12 commits intooptuna:masterfrom Nov 21, 2025
Merged
Conversation
Member
|
@Alnusjaponica @sawa3030 Could you review this PR? |
This was referenced Nov 12, 2025
sawa3030
reviewed
Nov 13, 2025
Co-authored-by: Eri Sawada <125344906+sawa3030@users.noreply.github.com>
Collaborator
Author
|
Thank you for the comment. I’ve updated the code accordingly. |
sawa3030
approved these changes
Nov 20, 2025
Alnusjaponica
approved these changes
Nov 21, 2025
Contributor
Alnusjaponica
left a comment
There was a problem hiding this comment.
Thanks for your contribution. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This PR is the follow-up on:
Engine#6303,and runs in parallel with::
storage_tests/test_cached_storage.py#6337, andstorage_tests/rdb_tests/test_storage.py#6338.The original PR did not cover all test cases. This PR addresses the remaining ones in
storage_tests/test_with_server.py.Important
With these PRs and this PR, all the tests creating
RDBStorageintest_storageshas been addressed.The remaining tests creating
RDBStorageis onlystudy_tests/test_study_summary.py, which creates theRDBStorageinstance for only two times and considered to be less likely to encounter the SQLAlchemy's issue.Description of the changes
get_storagefunciton contextmanager and use it for all tests instorage_tests/test_with_server.py.Note
To ensure that
dispose()is always called even when an assert fails, it should be invoked inside__exit__rather than at the end of the test function.Important
Most of the diff comes from increased indentation after introducing the context manager.