Receive filtered warnings

Hello all, I recently opened a feature request for pytest (https://github.com/pytest-dev/pytest/issues/8768) to find out if a warnings filter capture anything. Basic use-case: In big project with a lot of dependencies, the warnings filter list can grow a lot. Currently the only safe way to find out if a filter is still needed, is to remove it and then to run your code. Therefore it would be nice to have a more automatic approach. Suggestion for the warnings module: A new method wich returns all filtered warnings as well as the filter which caused the filtering. The "capturing" could even be placed inside a context generator to avoid a unnecessary collection and a global state. Afterwards it would be possible for tools like pytest to take a look at all applied filters and then to report, which filters were not applied. Additional benefits: A user can e.g. see if a previous general written filter (e.g. without a module) can be more specific.
participants (1)
-
kasium