def test_tb_is_rendered(self): sys.stderr = StringIO.StringIO() errors = iter([[get_tb(), ]]) std = StdOutput(mock.sentinel.test_result, mock.sentinel.args) std._print_tb(errors) sys.stderr.seek(0) out = sys.stderr.read() self.assertTrue('Exception' in out) self.assertTrue('Error message' in out)
def test_add_error(self): exc = get_tb() self.relay.addError(mock.sentinel.test, exc, mock.sentinel.loads_status) self.relay.push.assert_called_with( 'addError', test='sentinel.test', exc_info=("<type 'exceptions.Exception'>", '', ''), loads_status=mock.sentinel.loads_status)
def test_add_error(self): exc = get_tb() __, __, tb = exc string_tb = StringIO() traceback.print_tb(tb, file=string_tb) string_tb.seek(0) self.relay.addError(mock.sentinel.test, exc, mock.sentinel.loads_status) self.relay.push.assert_called_with( 'addError', test='sentinel.test', exc_info=("<type 'exceptions.Exception'>", '', string_tb.read()), loads_status=mock.sentinel.loads_status)
def test_add_error(self): exc = get_tb() __, __, tb = exc string_tb = StringIO() traceback.print_tb(tb, file=string_tb) string_tb.seek(0) self.relay.addError(mock.sentinel.test, exc, mock.sentinel.loads_status) self.relay.push.assert_called_with( 'addError', test='sentinel.test', exc_info=("<type 'exceptions.Exception'>", 'Error message', string_tb.read()), loads_status=mock.sentinel.loads_status)
def test_add_error(self): exc = get_tb() __, __, tb = exc string_tb = StringIO() traceback.print_tb(tb, file=string_tb) string_tb.seek(0) self.relay.addError(mock.sentinel.test, exc, str(mock.sentinel.loads_status)) recv = json.loads(self._pull.recv()) self.assertEqual(recv["loads_status"], str(mock.sentinel.loads_status)) self.assertEqual(recv["test"], str(mock.sentinel.test)) exc_info = ["<type 'exceptions.Exception'>", "Error message", string_tb.read()] self.assertEqual(recv["exc_info"], exc_info)
def test_add_error(self): exc = get_tb() __, __, tb = exc string_tb = StringIO() traceback.print_tb(tb, file=string_tb) string_tb.seek(0) self.relay.addError(mock.sentinel.test, exc, str(mock.sentinel.loads_status)) recv = json.loads(self._pull.recv()) self.assertEqual(recv['loads_status'], str(mock.sentinel.loads_status)) self.assertEqual(recv['test'], str(mock.sentinel.test)) exc_info = [ "<type 'exceptions.Exception'>", 'Error message', string_tb.read() ] self.assertEqual(recv['exc_info'], exc_info)