Describe the bug
In the FixtureCollector, the variables fixtures and errors are defined as class variables, not as instance attributes, This means, if e.g. first a non-test file is checked, the errors set will get an entry, but (since it's not a test file) not pylint message is printed.
Now, when checking any other file, the error field is still filled, meaning that this will now fail.
To Reproduce
Package versions
pylint 2.9.6
pytest 6.2.4
pylint-pytest 1.1.2
Folder structure
- a.py
- test_b.py
File content a.py
import os
os.environ["NOT_HERE"]
File content test_b.py
def test_foo():
assert 1==1
Now, when executing pylint a.py test_b.py and these files are linted in that order, a "cannot-enumerate-pytest-fixtures" will occur.
************* Module x
a.py:2:0: C0304: Final newline missing (missing-final-newline)
a.py:1:0: C0114: Missing module docstring (missing-module-docstring)
a.py:2:0: W0104: Statement seems to have no effect (pointless-statement)
************* Module test_a
test_b.py:2:0: C0304: Final newline missing (missing-final-newline)
test_b.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test_b.py:1:0: F6401: pylint-pytest plugin cannot enumerate and collect pytest fixtures. Please run `pytest --fixtures --collect-only path/to/current/module.py` and resolve any potential syntax error or package dependency issues (cannot-enumerate-pytest-fixtures)
test_b.py:1:0: C0116: Missing function or method docstring (missing-function-docstring)
test_b.py:2:11: R0124: Redundant comparison - 1 == 1 (comparison-with-itself
Expected behavior
Init the variables in the constructor
Describe the bug In the
FixtureCollector
, the variablesfixtures
anderrors
are defined as class variables, not as instance attributes, This means, if e.g. first a non-test file is checked, theerrors
set will get an entry, but (since it's not a test file) not pylint message is printed. Now, when checking any other file, theerror
field is still filled, meaning that this will now fail.To Reproduce Package versions
Folder structure
File content a.py
File content test_b.py
Now, when executing
pylint a.py test_b.py
and these files are linted in that order, a "cannot-enumerate-pytest-fixtures" will occur.Expected behavior Init the variables in the constructor