@@ -61,7 +61,7 @@ class FixtureChecker(BasePytestChecker):
6161 'F6401' : (
6262 (
6363 'pylint-pytest plugin cannot enumerate and collect pytest fixtures. '
64- 'Please run `pytest --fixtures --collect-only path/to/current/module.py ` and resolve any potential syntax error or package dependency issues'
64+ 'Please run `pytest --fixtures --collect-only %s ` and resolve any potential syntax error or package dependency issues'
6565 ),
6666 'cannot-enumerate-pytest-fixtures' ,
6767 'Used when pylint-pytest has been unable to enumerate and collect pytest fixtures.' ,
@@ -135,8 +135,22 @@ def visit_module(self, node):
135135
136136 FixtureChecker ._pytest_fixtures = fixture_collector .fixtures
137137
138- if (ret != pytest .ExitCode .OK or fixture_collector .errors ) and is_test_module :
139- self .add_message ('cannot-enumerate-pytest-fixtures' , node = node )
138+ legitimate_failure_paths = set (
139+ collection_report .nodeid
140+ for collection_report in fixture_collector .errors
141+ if any (
142+ fnmatch .fnmatch (
143+ Path (collection_report .nodeid ).name , pattern ,
144+ )
145+ for pattern in FILE_NAME_PATTERNS
146+ )
147+ )
148+ if (ret != pytest .ExitCode .OK or legitimate_failure_paths ) and is_test_module :
149+ self .add_message (
150+ 'cannot-enumerate-pytest-fixtures' ,
151+ args = ' ' .join (legitimate_failure_paths | {node .file }),
152+ node = node ,
153+ )
140154 finally :
141155 # restore output devices
142156 sys .stdout , sys .stderr = stdout , stderr
0 commit comments