Skip to content

Improve pytest.warns() docs to clarify difference with catch_warnings() #9002

Closed
@nicoddemus

Description

@nicoddemus

We should add some stdlib links to the relevant docs:

  • If you want to get a list of warnings, but no error if no warnings were emitted, use warnings.catch_warnings()
  • To say "any warning here is unexpected / an error", use with catch_warnings(): simplefilter("error"); ...

I didn't intend to break anything, but nor did I consider that people might be using pytest.warns() like warnings.catch_warnings(). My apologies for the inconvenience!

Originally posted by @Zac-HD in #8677 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: warningsrelated to the warnings builtin plugintype: docsdocumentation improvement, missing or needing clarification

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions