From b2ebb808785d8e52eea3cb9316c394259ff285d9 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 2 Aug 2013 00:02:28 +0200 Subject: [PATCH] fix issue322: tearDownClass is not run if setUpClass failed. Thanks Mathieu Agopian for fixing. The patch moves handling setUpClass into a new autofixture. (XXX impl-decide if rather adding addfinalizer() API to node's would have a similar effect) --- CHANGELOG | 5 +++++ _pytest/unittest.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 6c6f8ecf5..dd2fcac51 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,11 @@ Changes between 2.3.5 and 2.4.DEV ----------------------------------- +- fix issue322: tearDownClass is not run if setUpClass failed. Thanks + Mathieu Agopian for fixing. The patch moves handling setUpClass + into a new autofixture. (XXX impl-decide if rather adding addfinalizer() + API to node's would have a similar effect) + - fix issue336: autouse fixture in plugins should work again. - change to use hyphen-separated long options but keep the old spelling diff --git a/_pytest/unittest.py b/_pytest/unittest.py index 8a0244f5d..bec3386b0 100644 --- a/_pytest/unittest.py +++ b/_pytest/unittest.py @@ -28,7 +28,8 @@ def _xunit_setUpClass(request): return # skipped setup = getattr(request.cls, 'setUpClass', None) teardown = getattr(request.cls, 'tearDownClass', None) - setup() + if setup is not None: + setup() if teardown is not None: request.addfinalizer(teardown)