def test_status(self): """ Ensure that L{statust.fromFailure} works as expected """ f = self.buildFailure(TestRuntimeError, 'foo bar') s = status.fromFailure(f) self.assertTrue(status.IStatus.providedBy(s)) self.assertEqual(s.level, 'error') self.assertEqual(s.code, None) self.assertEqual(s.description, 'foo bar')
def test_default_code(self): """ L{status.fromFailure} looks for a C{code} attribute on the exception instance contained in the failure. If one is not present, supplying a default code is allowed. """ f = self.buildFailure(RuntimeError, 'spam eggs') self.assertFalse(hasattr(f.value, 'code')) s = status.fromFailure(f, 'default code') self.assertTrue(status.IStatus.providedBy(s)) self.assertEqual(s.level, 'error') self.assertEqual(s.code, 'default code') self.assertEqual(s.description, 'spam eggs')