Beispiel #1
0
    def test_flattening(self):
        f1 = _captured_failure('Wrap me')
        f2 = _captured_failure('Wrap me, too')
        f3 = _captured_failure('Woot!')
        try:
            raise failure.WrappedFailure([f1, f2])
        except Exception:
            fail_obj = failure.Failure.from_exc_info()

        wf = failure.WrappedFailure([fail_obj, f3])
        self.assertEqual([f1, f2, f3], list(wf))
Beispiel #2
0
 def test_two_failures(self):
     fls = [
         _captured_failure('Woot!'),
         _captured_failure('Oh, not again!')
     ]
     wf = failure.WrappedFailure(fls)
     self.assertEqual(2, len(wf))
     self.assertEqual(fls, list(wf))
Beispiel #3
0
 def test_wrapped_failure_non_ascii_unicode(self):
     hi_cn = u'嗨'
     fail = ValueError(hi_cn)
     self.assertEqual(hi_cn, encodeutils.exception_to_unicode(fail))
     fail = failure.Failure.from_exception(fail)
     wrapped_fail = failure.WrappedFailure([fail])
     expected_result = (u"WrappedFailure: "
                        "[Failure: %s.ValueError: %s]" % (EXCP_BASE, hi_cn))
     self.assertEqual(expected_result, six.text_type(wrapped_fail))
Beispiel #4
0
 def test_simple_check(self):
     fail_obj = _captured_failure('Woot!')
     wf = failure.WrappedFailure([fail_obj])
     self.assertEqual(RuntimeError, wf.check(RuntimeError))
     self.assertIsNone(wf.check(ValueError))
Beispiel #5
0
 def test_simple_iter(self):
     fail_obj = _captured_failure('Woot!')
     wf = failure.WrappedFailure([fail_obj])
     self.assertEqual(1, len(wf))
     self.assertEqual([fail_obj], list(wf))