mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Add PT025
and PT026
docs (#6264)
This commit is contained in:
parent
ec8fad5b02
commit
c362ea7fd4
2 changed files with 60 additions and 2 deletions
|
@ -22,7 +22,7 @@ use super::helpers::{
|
|||
};
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for parameter-free `@pytest.fixture()` decorators with or without
|
||||
/// Checks for argument-free `@pytest.fixture()` decorators with or without
|
||||
/// parentheses, depending on the `flake8-pytest-style.fixture-parentheses`
|
||||
/// setting.
|
||||
///
|
||||
|
@ -328,6 +328,40 @@ impl AlwaysAutofixableViolation for PytestUselessYieldFixture {
|
|||
}
|
||||
}
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for `pytest.mark.usefixtures` decorators applied to `pytest`
|
||||
/// fixtures.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// The `pytest.mark.usefixtures` decorator has no effect on `pytest` fixtures.
|
||||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// @pytest.fixture()
|
||||
/// def a():
|
||||
/// pass
|
||||
///
|
||||
///
|
||||
/// @pytest.mark.usefixtures("a")
|
||||
/// @pytest.fixture()
|
||||
/// def b(a):
|
||||
/// pass
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// @pytest.fixture()
|
||||
/// def a():
|
||||
/// pass
|
||||
///
|
||||
///
|
||||
/// @pytest.fixture()
|
||||
/// def b(a):
|
||||
/// pass
|
||||
/// ```
|
||||
///
|
||||
/// ## References
|
||||
/// - [`pytest` documentation: `pytest.mark.usefixtures`](https://docs.pytest.org/en/latest/reference/reference.html#pytest-mark-usefixtures)
|
||||
#[violation]
|
||||
pub struct PytestErroneousUseFixturesOnFixture;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::registry::{AsRule, Rule};
|
|||
use super::helpers::get_mark_decorators;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for parameter-free `@pytest.mark.<marker>()` decorators with or
|
||||
/// Checks for argument-free `@pytest.mark.<marker>()` decorators with or
|
||||
/// without parentheses, depending on the `flake8-pytest-style.mark-parentheses`
|
||||
/// setting.
|
||||
///
|
||||
|
@ -66,6 +66,30 @@ impl AlwaysAutofixableViolation for PytestIncorrectMarkParenthesesStyle {
|
|||
}
|
||||
}
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for `@pytest.mark.usefixtures()` decorators that aren't passed any
|
||||
/// arguments.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// A `@pytest.mark.usefixtures()` decorator that isn't passed any arguments is
|
||||
/// useless and should be removed.
|
||||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// @pytest.mark.usefixtures()
|
||||
/// def test_something():
|
||||
/// ...
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// def test_something():
|
||||
/// ...
|
||||
/// ```
|
||||
///
|
||||
/// ## References
|
||||
/// - [`pytest` documentation: `pytest.mark.usefixtures`](https://docs.pytest.org/en/latest/reference/reference.html#pytest-mark-usefixtures)
|
||||
|
||||
#[violation]
|
||||
pub struct PytestUseFixturesWithoutParameters;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue