Description
I am looking at #1014 and related bugs, there are few on the subject.
It is still unclear to me what do to when a fixture uses another fixture, but it does not refer to it in the code.
From 2013 (the older but on the subject I found), when the ticket was raised, things have changed and now we have really strong type checking and linters.
An example of the code which would raise linters concerns is:
@fixture
def bar(monkeypatch):
with monkeypatch() as mp:
mp.setenv('MYVAR', 1):
yield
@fixture
def foo(monkeypatch, bar):
do_something_depening_on_MYVAR()
foo
does not know what bar
do, and does not care what bar
return value is. the code is unaware.
foo
depends on the behaviours of bar
, but does not refer to it. so any modern linter would raise it as a problem: unused-arguement
This is solved in test cases with usefixtures()
which injects them without putting them in the scope fo the test code.
how is it supposed to work with fixtures?
a valid solution to this ticket to me would be:
- document it in the fixture page
- and/or add a programmatic way to solve the problem, equivalent to
usefixtures()