pytest-ruff is a pytest plugin designed to integrate Ruff's powerful linting and formatting checks directly into your test suite. It automatically runs `ruff format --check` and `ruff check` as part of your `pytest` execution, failing tests if any Ruff requirements are not met. The current version is 0.5, and it maintains a consistent release cadence with updates addressing bug fixes and new features.
pip install pytest-ruffVerified import paths — ran on the pinned version, not inferred.
To quickly verify `pytest-ruff` is working, create a `pyproject.toml` to configure Ruff and a `test_example.py` file with a deliberate Ruff violation. Then, run pytest with the `--ruff` flag. The test suite should report a failure originating from the Ruff check.
Update your pytest command or configuration to use `--output-format` instead of `--show-source`. For example, `pytest --ruff --output-format=full`.
Upgrade to `pytest-ruff v0.2.1` or newer to ensure `--ruff` and `--ruff-format` operate as distinct checks as intended.
Be aware that `-k` might not skip Ruff checks. If this is a significant performance bottleneck, consider running Ruff separately via `ruff check .` and `ruff format --check .` outside of your `pytest` invocation for focused test runs.
You can add `# noqa: F401` to the line importing the fixture if you're sure it's being used implicitly by pytest. Alternatively, consider using `conftest.py` for shared fixtures or `pytest.mark.usefixtures()` for fixtures whose return value isn't directly consumed to make the dependency explicit and potentially avoid the `F401` warning.