This rule raises an issue when a pytest mark is applied where it has no effect: any @pytest.mark.* on a @pytest.fixture, or @pytest.mark.usefixtures() with no fixture names.

Why is this an issue?

Pytest applies marks to tests, classes, and modules. Marks on fixtures are ignored, and an empty @pytest.mark.usefixtures() does nothing.

Marks on fixtures

Decorating a fixture with @pytest.mark.asyncio, @pytest.mark.usefixtures(…​), or any other @pytest.mark.* does not change how the fixture runs or which tests use it:

@pytest.mark.asyncio  # Ignored: fixtures are not tests
@pytest.fixture
async def db():
    return await connect()

@pytest.mark.usefixtures("db")  # Ignored on fixtures
@pytest.fixture
def client(db):
    return Client(db)

@pytest.mark.slow  # Ignored on fixtures
@pytest.fixture
def cache():
    return {}

Maintainers may assume the mark selects the fixture, runs it asynchronously, or injects other fixtures. None of that happens.

To depend on another fixture, declare it as a parameter. For async fixtures, use an async fixture function; pytest-asyncio does not require @pytest.mark.asyncio on the fixture itself.

Empty usefixtures

@pytest.mark.usefixtures() with no names is a no-op:

@pytest.mark.usefixtures()  # No fixtures requested
def test_ping():
    assert ping() == "pong"

Either pass the fixture names that should be activated, or remove the decorator.

What is the potential impact?

Useless marks look intentional but change nothing. Teams may believe fixtures are skipped, marked slow, run under asyncio, or wired via usefixtures, while the suite behaves differently than expected.

How to fix it

Remove marks from fixtures. Request other fixtures as parameters instead of @pytest.mark.usefixtures on the fixture. For empty @pytest.mark.usefixtures(), either supply fixture names or delete the decorator.

Code examples

Noncompliant code example

import pytest

@pytest.mark.asyncio  # Noncompliant
@pytest.fixture
async def db():
    return await connect()

@pytest.mark.usefixtures("db")  # Noncompliant
@pytest.fixture
def client(db):
    return Client(db)

@pytest.mark.slow  # Noncompliant
@pytest.fixture
def cache():
    return {}

Compliant solution

import pytest

@pytest.fixture
async def db():
    return await connect()

@pytest.fixture
def client(db):
    return Client(db)

@pytest.fixture
def cache():
    return {}

Noncompliant code example

import pytest

@pytest.mark.usefixtures()  # Noncompliant
def test_ping():
    assert ping() == "pong"

Compliant solution

def test_ping():
    assert ping() == "pong"

Resources

Documentation