Add `PT016` documentation (#6005)

This commit is contained in:
Harutaka Kawamura 2023-07-24 10:52:48 +09:00 committed by GitHub
parent 2b9c22de0f
commit 110fa804ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 0 deletions

View File

@ -8,6 +8,44 @@ use crate::checkers::ast::Checker;
use super::helpers::{is_empty_or_null_string, is_pytest_fail}; 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] #[violation]
pub struct PytestFailWithoutMessage; pub struct PytestFailWithoutMessage;