Skip to content

PyTest FixtureRequest #74

Open
Open
@dylan-at-na

Description

@dylan-at-na

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions