Skip to content

Fix fragile test test_experimental#6211

Merged
c-bata merged 1 commit intooptuna:masterfrom
gen740:fix_test_experimental
Jul 23, 2025
Merged

Fix fragile test test_experimental#6211
c-bata merged 1 commit intooptuna:masterfrom
gen740:fix_test_experimental

Conversation

@gen740
Copy link
Copy Markdown
Member

@gen740 gen740 commented Jul 18, 2025

Motivation

Related to #6206

According to #6206, test_experimental occasionally fail.

_______________________ test_experimental_func_decorator _______________________
[gw0] linux -- Python 3.13.5 /opt/hostedtoolcache/Python/3.13.5/x64/bin/python

    def test_experimental_func_decorator() -> None:
        version = "1.1.0"
        decorator_experimental = _experimental.experimental_func(version)
        assert callable(decorator_experimental)
    
        decorated_func = decorator_experimental(_sample_func)
        assert decorated_func.__name__ == _sample_func.__name__
        assert decorated_func.__doc__ == _experimental._EXPERIMENTAL_NOTE_TEMPLATE.format(ver=version)
    
        with pytest.warns(ExperimentalWarning) as warnings:
            decorated_func()
    
>       (warning,) = warnings
        ^^^^^^^^^^
E       ValueError: too many values to unpack (expected 1)

tests/test_experimental.py:61: ValueError

However, this error appears to be deeply rooted in pytest-xdist, and it’s very hard to reproduce in a local environment. It seems the issue was a race condition with pytest.warns, since pytest is not thread-safe, but xdist is a multi-process plugin and does not create any additional threads.

I believe checking the warning message is excessive.

Description of the changes

  • Remove the logic that checks for ExperimentalWarning output.

@c-bata c-bata marked this pull request as ready for review July 22, 2025 04:50
Copy link
Copy Markdown
Contributor

@nabenabe0928 nabenabe0928 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!

@nabenabe0928 nabenabe0928 added the CI Continuous integration. label Jul 22, 2025
@nabenabe0928 nabenabe0928 added this to the v4.5.0 milestone Jul 22, 2025
Copy link
Copy Markdown
Member

@c-bata c-bata left a comment

Choose a reason for hiding this comment

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

LGTM.

@c-bata c-bata merged commit c44f263 into optuna:master Jul 23, 2025
15 checks passed
@gen740 gen740 deleted the fix_test_experimental branch October 3, 2025 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous integration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants