PY-TEST0001 · conftest_import
Detect an explicit import of a pytest conftest module.
This is a deterministic rule for python. Read its implementation.
Definition
Section titled “Definition”Inspect Python import statements for import conftest, from conftest import fixture,
package-qualified imports such as from tests.conftest import client, and relative forms such
as from . import conftest. The expected default is zero because pytest discovers fixtures and
local plugins from conftest.py according to directory scope.
Evidence
Section titled “Evidence”Each finding identifies the complete import statement and every conftest module it names. A statement is counted once even when it binds several names from the same module.
Exceptions
Section titled “Exceptions”allowed_modules can exempt an exact, uniquely packaged compatibility module when an external
integration requires a normal import. Pytest discovery remains preferred. Imports from ordinary
fixture plugin modules are accepted and are the supported way to share fixtures without
broadening a conftest boundary. Ruff’s pytest rules do not own conftest imports.
Examples
Section titled “Examples”from tests.conftest import authenticated_client
def test_account(authenticated_client): assert authenticated_client.get("/account").status_code == 200def test_account(authenticated_client): assert authenticated_client.get("/account").status_code == 200References
Section titled “References”- Cites “pytest documentation”, writing plugins and conftest.py plugins. Open reference
- Cites “pytest documentation”, fixture availability. Open reference