Skip to content

pytest does not run tests in test classes where abstract methods are not implemented #14003

@levsa

Description

@levsa

Minimal example:

from abc import abstractmethod, ABC

import pytest


class FixturesClass(ABC):
    @pytest.fixture
    def name_fixture(self) -> str:
        return self.name + "_fixture"

    @property
    @abstractmethod
    def name(self) -> str:
        pass


class TestFixtures1(FixturesClass):
    @property
    def name(self) -> str:
        return "test1"

    def test_name_fixture(self, name_fixture: str):
        assert name_fixture == "test1_fixture"


class TestFixtures2(FixturesClass):
    def test_name_fixture(self, name_fixture: str):
        assert name_fixture == "test2_fixture"

This was introduced in #12318

Sorry, duplicate of: #13546

Metadata

Metadata

Assignees

No one assigned

    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