Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use warnings.catch_warnings() instead of pytest.warns(None) #741

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

hiohiohio
Copy link
Contributor

@hiohiohio hiohiohio commented Jan 8, 2024


    def test_no_resource_warning_with_context_manager():
>       with pytest.warns(None) as record:  # ensure no warnings are raised

tests/test_rest.py:1175: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = WarningsChecker(record=True), expected_warning = None, match_expr = None

    def __init__(
        self,
        expected_warning: Optional[
            Union[Type[Warning], Tuple[Type[Warning], ...]]
        ] = Warning,
        match_expr: Optional[Union[str, Pattern[str]]] = None,
        *,
        _ispytest: bool = False,
    ) -> None:
        check_ispytest(_ispytest)
        super().__init__(_ispytest=True)
    
        msg = "exceptions must be derived from Warning, not %s"
        if expected_warning is None:
>           warnings.warn(WARNS_NONE_ARG, stacklevel=4)
E           pytest.PytestRemovedIn8Warning: Passing None has been deprecated.
E           See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

.eggs/pytest-8.0.0rc1-py3.10.egg/_pytest/recwarn.py:279: PytestRemovedIn8Warning
FAILED tests/test_rest.py::test_no_resource_warning_with_context_manager - pytest.PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.

Copy link
Contributor

@gnvk gnvk left a comment

Choose a reason for hiding this comment

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

LGTM

@gnvk gnvk merged commit 32bb2a4 into master Jan 9, 2024
3 checks passed
@gnvk gnvk deleted the use-warnings-instead-of-pytest-warns branch January 9, 2024 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants