Skip to content

Extend self deprecation to module/package/session scoped fixtures inside classes #14765

Description

@The-Compiler

#14071 added a deprecation warning for:

import pytest

class TestFixture:

    @pytest.fixture(scope="class")
    # without @classmethod
    def fixt(self):
        self.x = 23

    def test_fixt(self, fixt):
        print(self.x)

because that doesn't work which might be surprising to people.

However, the same issue exists with scopes module, package and session as well. We should extend the deprecation to those, and require that those are @staticmethod.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions