Skip to content

pytest 4.2.0 vs unittest.skip and setUpClass inheritance #4700

@sduthil

Description

@sduthil
  • Include a detailed description of the bug or suggestion

With pytest 4.2.0, there is a change of behaviour regarding unittest classes using unittest.skip decorator. Classes that were completely skipped before now run inherited setUpClass before skipping the test class.
This only happens with inherited setUpClass, not with setUpClass defined directly in the test class.

  • pip list of the virtual environment you are using
Package        Version
-------------- -------
atomicwrites   1.2.1
attrs          18.2.0
more-itertools 5.0.0
pathlib2       2.3.3
pip            19.0.1
pluggy         0.8.1
py             1.7.0
pytest         4.2.0
setuptools     40.7.1
six            1.12.0
wheel          0.32.3
  • pytest and operating system versions
    platform linux -- Python 3.5.3, pytest-4.2.0, py-1.7.0, pluggy-0.8.1
  • Minimal example if possible
    This example test is skipped with pytest 4.1.1 and raises an error with pytest 4.2.0:
import unittest


class ClassPrinter(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        print(cls.name)


@unittest.skip('this class fails')
class TestClassFailed(ClassPrinter):

    name = 'failure'

    def test_failure(self):
        raise Exception('this test fails')

Metadata

Metadata

Assignees

Labels

topic: fixturesanything involving fixtures directly or indirectlytype: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions