This rule raises an issue when a @pytest.fixture decorator includes both autouse=True and a params argument with values.

Why is this an issue?

Test fixtures serve two important purposes: setting up test prerequisites and providing test data through parametrization. Pytest allows combining automatic fixture usage (autouse=True) with fixture parametrization (params=), but the result is discouraged for most test suites.

When you mark a fixture to run automatically, pytest uses it in every test function within its scope, without requiring the test to explicitly request it. This is useful for setup tasks that should always run, like initializing a database connection or configuring logging.

Parametrized fixtures use the params argument to provide multiple values. Each test that requests the fixture is executed once for each parameter value.

When both options are combined, pytest parametrizes every test in scope, even tests that do not reference the fixture, because the autouse fixture is injected implicitly. A single test function can therefore run once per parameter value without any visible parametrization on the test itself, leading to readability and maintainability issues such as:

This pattern is valid pytest syntax, but it makes test behavior harder to understand and maintain. This discouraged combination should never be suppressed. Hidden test multiplication from autouse parametrization is always a genuine issue, not an accepted trade-off.

What is the potential impact?

As test suites grow, hidden autouse parametrization increases CI runtime and makes failures harder to diagnose for developers who are not familiar with the fixture graph.

How to fix it

Remove the params argument if the fixture needs to be automatically used. Use a single, default configuration instead of multiple parameter values.

If you need multiple setup variants for every test, parametrize the tests themselves with @pytest.mark.parametrize instead of parametrizing an autouse fixture. If only some tests need the fixture, drop autouse=True and declare the fixture as a test parameter so each test opts in explicitly.

Fixtures that use params without autouse=True are valid. This rule flags only the discouraged combination of both options.

Code examples

Noncompliant code example

@pytest.fixture(autouse=True, params=[1, 2, 3])  # Noncompliant
def my_fixture():
    return 'value'

Compliant solution

@pytest.fixture(autouse=True)
def my_fixture():
    return 'value'

Resources

Documentation