def testHandleException(self): xlog.setDebug('4') try: do_raise() except Error as e: error.handle_exception(self.logger, e, "Error handler:") self.assertEqual(1, len(self.keeper.errors)) self.assertEqual(2, len(self.keeper.errors[0][1])) traceback = self.keeper.errors[0][1][1] self.assertIn( 'feat/test/test_common_error.py', traceback)
def testHandleFailure(self): xlog.setDebug('4') d = defer.succeed(None) d.addCallback(do_raise) d.addErrback(self._errback) yield d self.assertEqual(1, len(self.keeper.errors)) self.assertEqual(2, len(self.keeper.errors[0][1])) traceback = self.keeper.errors[0][1][1] self.assertIn( 'feat/test/test_common_error.py', traceback)
def testExceptionInGateway(self): xlog.setDebug('4') root = Root(None) gate = gateway.Gateway(root, (5000, 10000), log_keeper=self.keeper, label='Test gateway') yield gate.initiate() self.addCleanup(gate.cleanup) d = request('/_post', gate.port) self.assertFailure(d, WebError) yield d self.assertEqual(1, len(self.keeper.errors)) self.assertEqual(2, len(self.keeper.errors[0][1])) traceback = self.keeper.errors[0][1][1] self.assertIn( "do_raise() #fail with 500 Internal Server Error", traceback)
def set_debug(self, string): global flulog flulog.setDebug(string)