Add PT010 doc (#6010)

This commit is contained in:
Harutaka Kawamura 2023-07-24 10:43:18 +09:00 committed by GitHub
parent 742f615792
commit 51ebff7e41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,6 +38,35 @@ impl Violation for PytestRaisesTooBroad {
}
}
/// ## What it does
/// Checks for `pytest.raises` calls without an expected exception.
///
/// ## Why is this bad?
/// `pytest.raises` expects to receive an expected exception as its first
/// argument. If omitted, the `pytest.raises` call will fail at runtime.
///
/// ## Example
/// ```python
/// import pytest
///
///
/// def test_foo():
/// with pytest.raises():
/// do_something()
/// ```
///
/// Use instead:
/// ```python
/// import pytest
///
///
/// def test_foo():
/// with pytest.raises(SomeException):
/// do_something()
/// ```
///
/// ## References
/// - [API Reference: `pytest.raises`](https://docs.pytest.org/en/latest/reference/reference.html#pytest-raises)
#[violation]
pub struct PytestRaisesWithoutException;