def test_display_internal_error(capsys, execution_context, show_errors_tracebacks): execution_context.show_errors_tracebacks = show_errors_tracebacks try: 1 / 0 except ArithmeticError as exc: event = InternalError.from_exc(exc) display_internal_error(execution_context, event) out = capsys.readouterr().out.strip() assert ("Traceback (most recent call last):" in out) is show_errors_tracebacks assert "ZeroDivisionError: division by zero" in out
def test_serialize_internal_error(): try: 1 / 0 except ArithmeticError as exc: event = InternalError.from_exc(exc) assert serialize_event(event) == { "InternalError": { "message": "An internal error happened during a test run", "exception_type": "builtins.ZeroDivisionError", "exception_with_traceback": ANY, } }
def internal_error(): return InternalError(message="Internal error occurred.", exception_type="exception")