You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's actually very close to PT019, except the fixture returns something.
@pytest.fixture()defmy_document(db):
"""pretend its fetched from a database"""returndb.get_document(1)
# All good, the fixture is accesseddeftest_check_something(my_document):
assertmy_document== {"name": "My Document"}
# Controversial, as my_document parameter is not accesseddeftest_another_thing(my_document):
"""this test expect my_document to exist, even if it's not accessed."""assertlen(db.get_documents()) ==1
I would like a rule that would recommend this construction for the second test.
@pytest.mark.usefixtures("my_document")deftest_another_thing():
"""this test expect my_document to exist, even if it's not accessed."""assertlen(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
The text was updated successfully, but these errors were encountered:
Rule request
Description
It's actually very close to
PT019
, except the fixture returns something.I would like a rule that would recommend this construction for the second test.
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
The text was updated successfully, but these errors were encountered: