mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-25 22:29:02 +00:00
Add PT010 doc (#6010)
This commit is contained in:
parent
742f615792
commit
51ebff7e41
1 changed files with 29 additions and 0 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue