Skip to content

ENH: mechanism for failing when warnings are issued without conversion to exceptions? #11518

Open
@tylerjereddy

Description

@tylerjereddy

Maybe this is rather niche, or more of a usage query, but I think it has confused us a little bit. One conundrum we occasionally face in SciPy is that the heavily-used NumPy library sometimes decides to issue warnings for some function calls, but the same code paths can also have try/except guards for various reasons.

So, when we try to proactively turn warnings into errors in filterwarnings in our pytest.ini, what we end up with is a case where a warning becomes invisible to our testsuite/CI testing, and we miss out on i.e., deprecation warnings by the very mechanism we are trying to use to discover them, because the try/except block is triggered via pytest and then handled gracefully by NumPy to end up in a warning-free scenario!

Do you think there's a valid feature request in here? Or should we just resign ourselves to i.e., a CI job that runs the testsuite with the "warnings->errors" disabled and then greps on the pytest summary and errors out on non-zero warnings accounting?

Related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: warningsrelated to the warnings builtin plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions