pylint
pylint copied to clipboard
PyTest FixtureRequest
Bug description
# Given some PyTest class with a setup_teardown
class TestFile:
@pytest.fixture(scope="class")
def setup_teardown_environment(self, request: pytest.FixtureRequest):
# The following line assigns a value to `temp1` which can be accessed throughout
# the test class via `self`
request.cls.temp1 = 54321
print(self.temp1) # This executes via PyTest successfully
# PyLint check throws this error: Instance of 'TestFile' has no 'temp1' member
# PylintE1101:no-member
Command used
pylint ${file}
Pylint output
Instance of 'TestFile' has no 'temp1' member PylintE1101:no-member
Expected behavior
PyLint should not identify this as a problem at all, as request.cls and self are intrinsically linked when operating within the same test class.
Pylint version
pylint 3.2.3
astroid 3.2.2
Python 3.11.4 (main, May 8 2024, 12:11:54) [GCC 9.4.0]
OS / Environment
Ubuntu 20