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