This rule raises an issue when a pytest test or fixture parameter declares a default value.
A default on a pytest test or fixture parameter is always used. Pytest does not inject a fixture of the same name when a default is present:
@pytest.fixture
def value():
return 42
def test_positive(value=1): # Always gets 1; fixture is ignored
assert value > 0
That hides missing fixtures and makes the test run with a hard-coded value instead of the intended fixture. Remove the default so pytest can inject the parameter, or stop treating the name as a fixture dependency.
Defaults on test or fixture parameters silently block fixture injection, so tests can pass with hard-coded values while the real fixture is never applied.
Remove default values from pytest test and fixture parameters so fixtures can be injected by name.
import pytest
@pytest.fixture
def value():
return 42
def test_with_default(value=1): # Noncompliant
assert value > 0
import pytest
@pytest.fixture
def value():
return 42
def test_with_default(value):
assert value > 0