@@ -116,10 +116,10 @@ def visit_module(self, node):
116116 is_test_module = True
117117 break
118118
119+ stdout , stderr = sys .stdout , sys .stderr
119120 try :
120121 with open (os .devnull , "w" ) as devnull :
121122 # suppress any future output from pytest
122- stdout , stderr = sys .stdout , sys .stderr
123123 sys .stderr = sys .stdout = devnull
124124
125125 # run pytest session with customized plugin to collect fixtures
@@ -210,7 +210,7 @@ def visit_functiondef(self, node):
210210 for arg in node .args .args :
211211 self ._invoked_with_func_args .add (arg .name )
212212
213- # pylint: disable=bad-staticmethod-argument
213+ # pylint: disable=bad-staticmethod-argument,too-many-branches # The function itself is an if-return logic.
214214 @staticmethod
215215 def patch_add_message (
216216 self , msgid , line = None , node = None , args = None , confidence = None , col_offset = None
@@ -267,9 +267,18 @@ def patch_add_message(
267267 msgid == "unused-argument"
268268 and _can_use_fixture (node .parent .parent )
269269 and isinstance (node .parent , astroid .Arguments )
270- and node .name in FixtureChecker ._pytest_fixtures
271270 ):
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
273282
274283 # check W0621 redefined-outer-name
275284 if (
0 commit comments