diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs index 7c840db2a1..979bc61bea 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs @@ -8,6 +8,44 @@ use crate::checkers::ast::Checker; use super::helpers::{is_empty_or_null_string, is_pytest_fail}; +/// ## What it does +/// Checks for `pytest.fail` calls without a message. +/// +/// ## Why is this bad? +/// `pytest.fail` calls without a message make it harder to understand and debug test failures. +/// +/// ## Example +/// ```python +/// import pytest +/// +/// +/// def test_foo(): +/// pytest.fail() +/// +/// +/// def test_bar(): +/// pytest.fail("") +/// +/// +/// def test_baz(): +/// pytest.fail(reason="") +/// ``` +/// +/// Use instead: +/// ```python +/// import pytest +/// +/// +/// def test_foo(): +/// pytest.fail("...") +/// +/// +/// def test_bar(): +/// pytest.fail(reason="...") +/// ``` +/// +/// ## References +/// - [API Reference: `pytest.fail`](https://docs.pytest.org/en/latest/reference/reference.html#pytest-fail) #[violation] pub struct PytestFailWithoutMessage;