Skip to content

Remove the use of assert_warns and assert_warns_message from the tests #19414

@glemaitre

Description

@glemaitre

(Saving this for the upcoming sprints, ideally)

Let's remove the use of assert_warns, assert_warns_message

These should be replaced with the pytest context manager:

https://doc.pytest.org/en/reorganize-docs/recwarn.html

with pytest.warns(TheWarning, match="the expected message"):
   function_call_here()

For contributors: pick one of the modules, and please comment on this issue saying e.g. "I'm working on cluster/tests", to avoid other contributors choosing the same modules.

You can see all the occurrences of the entries that need to be removed with e.g. git grep "assert_warns" sklearn/ensemble/tests/.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions