def test_get_error_details_java(self): for exception, msg, expected in [ ('AssertionError', 'My Error', 'My Error'), ('AssertionError', None, 'AssertionError'), ('RuntimeException', 'Another Error', 'Another Error'), ('RuntimeException', None, 'RuntimeException'), ('ArithmeticException', 'foo', 'ArithmeticException: foo'), ('ArithmeticException', None, 'ArithmeticException'), ('AssertionError', 'Msg\nin 3\nlines', 'Msg\nin 3\nlines'), ('IOException', '1\n2', 'IOException: 1\n2'), ('RuntimeException', 'embedded', 'embedded'), ('IOException', 'IOException: emb', 'IOException: emb') ]: try: throw_method = getattr(java_exceptions, 'throw' + exception) throw_method(msg) except: message, details = get_error_details() assert_equals(message, get_error_message()) assert_equals(message, expected) lines = details.splitlines() assert_true(exception in lines[0]) for line in lines[1:]: line.strip().startswith('at ')
def test_get_error_details(self): for exception, args, exp_msg in [ (AssertionError, ['My Error'], 'My Error'), (AssertionError, [None], 'None'), (AssertionError, [], 'AssertionError'), (Exception, ['Another Error'], 'Another Error'), (ValueError, ['Something'], 'ValueError: Something'), (AssertionError, ['Msg\nin 3\nlines'], 'Msg\nin 3\nlines'), (ValueError, ['2\nlines'], 'ValueError: 2\nlines') ]: try: raise exception(*args) except: error1 = ErrorDetails() error2 = ErrorDetails(full_traceback=False) message1, tb1 = get_error_details() message2, tb2 = get_error_details(full_traceback=False) message3 = get_error_message() python_msg = format_message() python_tb = format_traceback() for msg in message1, message2, message3, error1.message, error2.message: assert_equal(msg, exp_msg) assert_true(tb1.startswith('Traceback (most recent call last):')) assert_true(tb1.endswith(exp_msg)) assert_true(tb2.startswith('Traceback (most recent call last):')) assert_true(exp_msg not in tb2) assert_equal(tb1, error1.traceback) assert_equal(tb2, error2.traceback) assert_equal(tb1, python_tb) assert_equal(tb1, f'{tb2}\n{python_msg}')
def test_get_error_details_python_class(self): for exception in [AssertionError, ValueError, ZeroDivisionError]: try: raise exception except: message, details = get_error_details() assert_equals(message, get_error_message()) exp_msg = exception.__name__ assert_equals(message, exception.__name__) assert_true(details.startswith('Traceback')) assert_true(exp_msg not in details)
def test_get_error_details_python_class(self): for exception in [AssertionError, ValueError, ZeroDivisionError]: try: raise exception except: message, details = get_error_details() assert_equal(message, get_error_message()) exp_msg = exception.__name__ assert_equal(message, exception.__name__) assert_true(details.startswith('Traceback')) assert_true(exp_msg not in details)
def test_get_error_details_python(self): for exception, msg, exp_msg in [ (AssertionError, 'My Error', 'My Error'), (AssertionError, None, 'None'), (Exception, 'Another Error', 'Another Error'), (ValueError, 'Something', 'ValueError: Something'), (AssertionError, 'Msg\nin 3\nlines', 'Msg\nin 3\nlines'), (ValueError, '2\nlines', 'ValueError: 2\nlines')]: try: raise exception(msg) except: message, details = get_error_details() assert_equal(message, get_error_message()) assert_equal(message, exp_msg) assert_true(details.startswith('Traceback')) assert_true(exp_msg not in details)
def test_get_error_details_java(self): for exception, msg, expected in [ ('AssertionError', 'My Error', 'My Error'), ('AssertionError', None, 'AssertionError'), ('RuntimeException', 'Another Error', 'Another Error'), ('RuntimeException', None, 'RuntimeException'), ('ArithmeticException', 'foo', 'ArithmeticException: foo'), ('ArithmeticException', None, 'ArithmeticException'), ('AssertionError', 'Msg\nin 3\nlines', 'Msg\nin 3\nlines'), ('IOException', '1\n2', 'IOException: 1\n2'), ('RuntimeException', 'embedded', 'embedded'), ('IOException', 'IOException: emb', 'IOException: emb')]: try: throw_method = getattr(java_exceptions, 'throw'+exception) throw_method(msg) except: message, details = get_error_details() assert_equals(message, get_error_message()) assert_equals(message, expected) lines = details.splitlines() assert_true(exception in lines[0]) for line in lines[1:]: line.strip().startswith('at ')
def _unrepresentable_object(item): from robot.utils.error import get_error_message return u"<Unrepresentable object '%s'. Error: %s>" % (item.__class__.__name__, get_error_message())
def _unrepresentable_object(item): from robot.utils.error import get_error_message return u"<Unrepresentable object '%s'. Error: %s>" \ % (item.__class__.__name__, get_error_message())
def _unrepresentable_object(item): from robot.utils.error import get_error_message return _unrepresentable_msg % (item.__class__.__name__, get_error_message())