@@ -114,10 +114,10 @@ def visit_module(self, node):
114114 is_test_module = True
115115 break
116116
117+ stdout , stderr = sys .stdout , sys .stderr
117118 try :
118119 with open (os .devnull , "w" ) as devnull :
119120 # suppress any future output from pytest
120- stdout , stderr = sys .stdout , sys .stderr
121121 sys .stderr = sys .stdout = devnull
122122
123123 # run pytest session with customized plugin to collect fixtures
@@ -208,7 +208,7 @@ def visit_functiondef(self, node):
208208 for arg in node .args .args :
209209 self ._invoked_with_func_args .add (arg .name )
210210
211- # pylint: disable=bad-staticmethod-argument
211+ # pylint: disable=bad-staticmethod-argument,too-many-branches # The function itself is an if-return logic.
212212 @staticmethod
213213 def patch_add_message (
214214 self , msgid , line = None , node = None , args = None , confidence = None , col_offset = None
@@ -265,9 +265,18 @@ def patch_add_message(
265265 msgid == "unused-argument"
266266 and _can_use_fixture (node .parent .parent )
267267 and isinstance (node .parent , astroid .Arguments )
268- and node .name in FixtureChecker ._pytest_fixtures
269268 ):
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
271280
272281 # check W0621 redefined-outer-name
273282 if (
0 commit comments