File tree 2 files changed +36
-1
lines changed 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,9 @@ def _classmethod_is_defined_at_leaf(cls, method_name):
277
277
f = method .__func__
278
278
except AttributeError :
279
279
pytest .fail ('%s.%s should be a classmethod' % (cls , method_name ))
280
- if PY2 and not (inspect .ismethod (method ) and method .__self__ is cls ):
280
+ if PY2 and not (inspect .ismethod (method ) and
281
+ inspect .isclass (method .__self__ ) and
282
+ issubclass (cls , method .__self__ )):
281
283
pytest .fail ('%s.%s should be a classmethod' % (cls , method_name ))
282
284
return f is not super_method .__func__
283
285
Original file line number Diff line number Diff line change @@ -141,6 +141,39 @@ def test_pass(self):
141
141
])
142
142
assert result .ret == 1
143
143
144
+ def test_setUpClass_multiple_subclasses (self , django_testdir ):
145
+ django_testdir .create_test_module ('''
146
+ from django.test import SimpleTestCase
147
+
148
+
149
+ class TestFoo(SimpleTestCase):
150
+ @classmethod
151
+ def setUpClass(cls):
152
+ super(TestFoo, cls).setUpClass()
153
+
154
+ def test_shared_TestFoo(self):
155
+ pass
156
+
157
+
158
+ class TestBar(TestFoo):
159
+ def test_bar1(self):
160
+ pass
161
+
162
+
163
+ class TestBar2(TestFoo):
164
+ def test_bar21(self):
165
+ pass
166
+ ''' )
167
+
168
+ result = django_testdir .runpytest_subprocess ('-v' , '-s' )
169
+ result .stdout .fnmatch_lines ([
170
+ "TestBar::test_bar1 PASSED" ,
171
+ "TestBar::test_shared_TestFoo PASSED" ,
172
+ "TestBar2::test_bar21 PASSED" ,
173
+ "TestBar2::test_shared_TestFoo PASSED" ,
174
+ ])
175
+ assert result .ret == 1
176
+
144
177
def test_multi_inheritance_setUpClass (self , django_testdir ):
145
178
django_testdir .create_test_module ('''
146
179
from django.test import TestCase
You can’t perform that action at this time.
0 commit comments