pytest-warns-without-warning (PT029)
Preview (since 0.9.2) · Category: pedantic · Related issues · View source
Derived from the flake8-pytest-style linter.
This rule is unstable and in preview. The --preview flag is required for use.
What it does
Checks for pytest.warns calls without an expected warning.
Why is this bad?
When called without arguments, pytest.warns defaults to Warning, accepting any warning type.
Specifying the expected warning type makes the test more precise and prevents unrelated warnings
from causing it to pass unexpectedly.
Example
Use instead: