@@ -200,12 +200,13 @@ def _handleClassSetUp(self, test, result):
200
200
finally :
201
201
unittest .suite ._call_if_exists (result , '_restoreStdout' )
202
202
if currentClass ._classSetupFailed is True :
203
- currentClass .doClassCleanups ()
204
- if len (currentClass .tearDown_exceptions ) > 0 :
205
- for exc in currentClass .tearDown_exceptions :
206
- self ._createClassOrModuleLevelException (
207
- result , exc [1 ], 'setUpClass' , className ,
208
- info = exc )
203
+ if hasattr (currentClass , 'doClassCleanups' ):
204
+ currentClass .doClassCleanups ()
205
+ if len (currentClass .tearDown_exceptions ) > 0 :
206
+ for exc in currentClass .tearDown_exceptions :
207
+ self ._createClassOrModuleLevelException (
208
+ result , exc [1 ], 'setUpClass' , className ,
209
+ info = exc )
209
210
210
211
def _createClassOrModuleLevelException (self , result , exc , method_name , parent , info = None ):
211
212
errorName = '%s (%s)' % (method_name , parent )
@@ -248,14 +249,15 @@ def _tearDownPreviousClass(self, test, result):
248
249
className )
249
250
finally :
250
251
unittest .suite ._call_if_exists (result , '_restoreStdout' )
251
- previousClass .doClassCleanups ()
252
- if len (previousClass .tearDown_exceptions ) > 0 :
253
- for exc in previousClass .tearDown_exceptions :
254
- className = unittest .util .strclass (previousClass )
255
- self ._createClassOrModuleLevelException (result , exc [1 ],
256
- 'tearDownClass' ,
257
- className ,
258
- info = exc )
252
+ if hasattr (previousClass , 'doClassCleanups' ):
253
+ previousClass .doClassCleanups ()
254
+ if len (previousClass .tearDown_exceptions ) > 0 :
255
+ for exc in previousClass .tearDown_exceptions :
256
+ className = unittest .util .strclass (previousClass )
257
+ self ._createClassOrModuleLevelException (result , exc [1 ],
258
+ 'tearDownClass' ,
259
+ className ,
260
+ info = exc )
259
261
260
262
261
263
class TreeCase (unittest .TestCase ):
0 commit comments