[TIP] addCleanup for setUpClass()?
Prasanna Santhanam
tsp at apache.org
Thu Aug 1 02:23:51 PDT 2013
In unittest with the fix for [1] unittest.addCleanups can perform
cleanup for objects in the LIFO structure if setUp fails midway during
an expensive test. Is there something similar for setUpClass() as well
that was introduced with unittest2?
If not - would something like the following work?
MyTestClass(TestCase):
@classmethod
def setUpClass(cls)
try:
setUpClass()
except:
cls.tearDownClass()
A lot of our tests share resources created within setUpClass and it
would be useful to override addCleanup to perform such garbage
collection when setUpClass fails.
[1] http://bugs.python.org/issue5679
--
Prasanna.,
------------------------
Powered by BigRock.com
More information about the testing-in-python
mailing list