unittest setUp fails to cleanup resources (from tearDown) if setUp fails - knockon effect looks like testresources issue as testresources does not use addCleanup
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
testresources |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
If I inherit from ResourcedTestCase and something goes wrong in my setUp, the resources won't get cleaned up, since tearDown() won't be called. This can cause the next tests to fail, since the environment isn't cleaned (for example the db might not have been reset, thus containing unexpected data)
From IRC:
< BjornT> lifeless: no, the issue is that when something goes wrong in
setUp(), TestCase.tearDown() doesn't get called, which makes
all following tests fail with a db error (since it doesn't
start with a clean db)
< lifeless> ah
< lifeless> cleanups addressed this, by running always (IIRC)
< lifeless> I'm not sure if we fixed tearDown in that matter for
< lifeless> we might want to do a cleanup based variant of
For clarity, tearDown not running isn't due to anything in unittest2/ testtools)
testresources, its the test framework (unittest/
doing that.
This however is obviously affecting whether resourceteardown is occuring.