@@ -116,10 +116,10 @@ def visit_module(self, node):
116
116
is_test_module = True
117
117
break
118
118
119
+ stdout , stderr = sys .stdout , sys .stderr
119
120
try :
120
121
with open (os .devnull , "w" ) as devnull :
121
122
# suppress any future output from pytest
122
- stdout , stderr = sys .stdout , sys .stderr
123
123
sys .stderr = sys .stdout = devnull
124
124
125
125
# run pytest session with customized plugin to collect fixtures
@@ -210,7 +210,7 @@ def visit_functiondef(self, node):
210
210
for arg in node .args .args :
211
211
self ._invoked_with_func_args .add (arg .name )
212
212
213
- # pylint: disable=bad-staticmethod-argument
213
+ # pylint: disable=bad-staticmethod-argument,too-many-branches # The function itself is an if-return logic.
214
214
@staticmethod
215
215
def patch_add_message (
216
216
self , msgid , line = None , node = None , args = None , confidence = None , col_offset = None
@@ -267,9 +267,18 @@ def patch_add_message(
267
267
msgid == "unused-argument"
268
268
and _can_use_fixture (node .parent .parent )
269
269
and isinstance (node .parent , astroid .Arguments )
270
- and node .name in FixtureChecker ._pytest_fixtures
271
270
):
272
- return
271
+ if node .name in FixtureChecker ._pytest_fixtures :
272
+ # argument is used as a fixture
273
+ return
274
+
275
+ fixnames = (
276
+ arg .name for arg in node .parent .args if arg .name in FixtureChecker ._pytest_fixtures
277
+ )
278
+ for fixname in fixnames :
279
+ if node .name in FixtureChecker ._pytest_fixtures [fixname ][0 ].argnames :
280
+ # argument is used by a fixture
281
+ return
273
282
274
283
# check W0621 redefined-outer-name
275
284
if (
0 commit comments