pylint icon indicating copy to clipboard operation
pylint copied to clipboard

PyTest FixtureRequest

Open dylan-at-na opened this issue 3 weeks ago • 0 comments

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

dylan-at-na avatar Jun 13 '24 14:06 dylan-at-na