Closed
Description
Recently some magic was added that tries wrap the setUpClass methods for some reason. Not sure why. In any case, it breaks our testsuite. I've attached a test file to reproduce.
The basic issue is that the the setUpClass raises a skip exception sometimes to cause the methods defined in that class to be skipped. This causes the wrapping code to skip restoring the classmethod, leading to errors later on.
The error is in this code:
pytest-django/pytest_django/plugin.py
Lines 417 to 419 in a67ab3b
If the setUpClass() throws an exception (in this case Skip), the restore is skipped and chaos ensues.
This is a test file that reproduces it:
import pytest
from django.test import SimpleTestCase
class foo(SimpleTestCase):
@classmethod
def setUpClass(cls):
if cls is foo:
raise pytest.skip("Skip base class")
super(foo, cls).setUpClass()
def test_shared_foo(self):
pass
class bar(foo):
def test_bar1(self):
pass
class bar2(foo):
def test_bar21(self):
pass