'Errors raised in cleanup functions should be treated like errors in
C{tearDown}. They should be added as errors and fail the test. Skips,
todos and failures are all treated as errors.'

def test_errorInCleanupIsCaptured(self):

    self.test.addCleanup(self.test.fail, 'foo')
    self.test.run(self.result)
    self.assertFalse(self.result.wasSuccessful())
    self.assertEqual(1, len(self.result.errors))
    [(test, error)] = self.result.errors
    self.assertEqual(test, self.test)
    self.assertEqual(error.getErrorMessage(), 'foo')
