コード例 #1
0
    def testInit(self):
        f1 = ce.Failure()
        self.assertTrue(isinstance(f1, Exception))
        self.assertEqual(f1.status, ce.EVENT_STATUS_FAIL)

        f2_msg = "This is the message for the failure"
        f2 = ce.Failure(f2_msg)
        self.assertEqual(f2.status, ce.EVENT_STATUS_FAIL)
        self.assertEqual(f2.message, f2_msg)
コード例 #2
0
    def testInit(self):
        f1 = cros_event.Failure()
        self.assertTrue(isinstance(f1, Exception))
        self.assertEqual(f1.status, cros_event.EVENT_STATUS_FAIL)

        f2_msg = 'This is the message for the failure'
        f2 = cros_event.Failure(f2_msg)
        self.assertEqual(f2.status, cros_event.EVENT_STATUS_FAIL)
        self.assertEqual(f2.msg, f2_msg)
コード例 #3
0
    def testWithFailure(self):
        """test with raising failure exception"""
        failMsg = "failed, as it should correctly"

        with self.event1:
            raise ce.Failure(failMsg)

        self.assertEqual(self.emitEvent[ce.EVENT_STATUS], ce.EVENT_STATUS_FAIL)
        self.assertEqual(self.emitEvent[ce.EVENT_FAIL_MSG], failMsg)
コード例 #4
0
    def testEventFail(self):
        with self.log.Event():
            raise ce.Failure("always fail")

        self.assertDictEqual(self.emitEvent, self.get_event_from_file())