Add `PT020` doc (#6011)

This commit is contained in:
Harutaka Kawamura 2023-07-24 10:37:03 +09:00 committed by GitHub
parent 5dbb4dd823
commit 95e6258d5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions

View File

@ -114,6 +114,38 @@ impl Violation for PytestFixtureParamWithoutValue {
}
}
/// ## What it does
/// Checks for `pytest.yield_fixture` usage.
///
/// ## Why is this bad?
/// `pytest.yield_fixture` is deprecated. `pytest.fixture` should be used instead.
///
/// ## Example
/// ```python
/// import pytest
///
///
/// @pytest.yield_fixture()
/// def my_fixture():
/// obj = SomeClass()
/// yield obj
/// obj.cleanup()
/// ```
///
/// Use instead:
/// ```python
/// import pytest
///
///
/// @pytest.fixture()
/// def my_fixture():
/// obj = SomeClass()
/// yield obj
/// obj.cleanup()
/// ```
///
/// ## References
/// - [`yield_fixture` functions](https://docs.pytest.org/en/latest/yieldfixture.html)
#[violation]
pub struct PytestDeprecatedYieldFixture;