Skip to content

pytest.mark on TestCase affects base classes #1464

@qwiglydee

Description

@qwiglydee

When pytest.mark.skipif applied to a class with bases (mixins) the tests from base clases are disabled for all other testcases.

platform linux -- Python 3.4.3, pytest-2.9.0, py-1.4.30, pluggy-0.3.1

from unittest import TestCase
import pytest


class BaseMixin():
    def test_foo(self):
        True


@pytest.mark.skipif(True, reason="disabled")
class TestBar(BaseMixin, TestCase):
    def test_bar(self):
        True


class TestBaz(BaseMixin, TestCase):
    def test_baz(self):
        True

output:

collected 4 items 

tests.py::TestBar::test_bar SKIPPED
tests.py::TestBar::test_foo SKIPPED
tests.py::TestBaz::test_baz PASSED
tests.py::TestBaz::test_foo SKIPPED
=============================== 1 passed, 3 skipped in 0.04 seconds

The tests.py::TestBaz::test_foo was skipped because of mark at TestBar

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