@@ -141,6 +141,76 @@ 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 TestCase
147
+
148
+
149
+ class TestFoo(TestCase):
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
+ "TestFoo::test_shared PASSED" ,
171
+ "TestBar::test_bar1 PASSED" ,
172
+ "TestBar::test_shared PASSED" ,
173
+ "TestBar2::test_bar21 PASSED" ,
174
+ "TestBar2::test_shared PASSED" ,
175
+ ])
176
+ assert result .ret == 1
177
+
178
+ def test_setUpClass_skip (self , django_testdir ):
179
+ django_testdir .create_test_module ('''
180
+ from django.test import TestCase
181
+
182
+
183
+ class TestFoo(TestCase):
184
+ @classmethod
185
+ def setUpClass(cls):
186
+ if cls is TestFoo:
187
+ raise pytest.skip("Skip base class")
188
+ super(TestFoo, cls).setUpClass()
189
+
190
+ def test_shared(self):
191
+ pass
192
+
193
+
194
+ class TestBar(TestFoo):
195
+ def test_bar1(self):
196
+ pass
197
+
198
+
199
+ class TestBar2(TestFoo):
200
+ def test_bar21(self):
201
+ pass
202
+ ''' )
203
+
204
+ result = django_testdir .runpytest_subprocess ('-v' , '-s' )
205
+ result .stdout .fnmatch_lines ([
206
+ "TestFoo::test_shared SKIPPED" ,
207
+ "TestBar::test_bar1 PASSED" ,
208
+ "TestBar::test_shared PASSED" ,
209
+ "TestBar2::test_bar21 PASSED" ,
210
+ "TestBar2::test_shared PASSED" ,
211
+ ])
212
+ assert result .ret == 1
213
+
144
214
def test_multi_inheritance_setUpClass (self , django_testdir ):
145
215
django_testdir .create_test_module ('''
146
216
from django.test import TestCase
0 commit comments