def test_construction(self): exc = errors.MarionetteException(message=message, status=status, cause=cause, stacktrace=stacktrace) self.assertEquals(exc.msg, message) self.assertEquals(exc.status, status) self.assertEquals(exc.cause, cause) self.assertEquals(exc.stacktrace, stacktrace)
def test_str(self): exc = errors.MarionetteException(message=message, status=status, cause=cause, stacktrace=stacktrace) r = str(exc) self.assertIn(message, r) self.assertIn(", caused by %r" % cause[0], r) self.assertIn("\nstacktrace:\n\tfirst\n\tsecond\n", r) self.assertIn("MarionetteException:", r)
def test_cause_tuple(self): exc = errors.MarionetteException(cause=cause) self.assertEqual(exc.cause, cause) r = str(exc) self.assertIn(", caused by %r" % cause[0], r)
def test_cause_string(self): exc = errors.MarionetteException(cause="foo") self.assertEqual(exc.cause, "foo") r = str(exc) self.assertIn(", caused by foo", r)
def test_defaults(self): exc = errors.MarionetteException() self.assertIsNone(exc.msg) self.assertEquals(exc.status, ErrorCodes.MARIONETTE_ERROR) self.assertIsNone(exc.cause) self.assertIsNone(exc.stacktrace)