Rule request
Description
It's actually very close to PT019, except the fixture returns something.
@pytest.fixture()
def my_document(db):
"""pretend its fetched from a database"""
return db.get_document(1)
# All good, the fixture is accessed
def test_check_something(my_document):
assert my_document == {"name": "My Document"}
# Controversial, as my_document parameter is not accessed
def test_another_thing(my_document):
"""this test expect my_document to exist, even if it's not accessed."""
assert len(db.get_documents()) == 1
I would like a rule that would recommend this construction for the second test.
@pytest.mark.usefixtures("my_document")
def test_another_thing():
"""this test expect my_document to exist, even if it's not accessed."""
assert len(db.get_documents()) == 1
Rationale
Because my editor would not complain a parameter is not used. And would make explicit that a fixture is loaded only for its side effects.
Not sure it's desirable though. Happy to hear other thoughts on this