def test_fatal_error_ignore_IOError(trace_print):
    trace_print.side_effect = IOError('some error')
    try:
        raise ValueError('some exception')
    except:
        _fatalerror()
    assert trace_print.called
def test_fatal_error_ignore_IOError(trace_print):
    trace_print.side_effect = IOError('some error')
    try:
        raise ValueError('some exception')
    except:
        _fatalerror()
    assert trace_print.called
def test_fatal_error_sentry_with_mock_ignore_errors(sentry_dsn):
    raven_stub = type('raven', (object, ), {})
    raven_stub.Client = mock.Mock()
    sentry_client = raven_stub.Client.return_value
    sentry_client.captureException.side_effect = IOError('error')
    try:
        sys.modules['raven'] = raven_stub
        raise ValueError('some exception')
    except:
        _fatalerror()
    finally:
        del sys.modules['raven']
def test_fatal_error_sentry_with_mock_ignore_errors(sentry_dsn):
    raven_stub = type('raven', (object, ), {})
    raven_stub.Client = mock.Mock()
    sentry_client = raven_stub.Client.return_value
    sentry_client.captureException.side_effect = IOError('error')
    try:
        sys.modules['raven'] = raven_stub
        raise ValueError('some exception')
    except:
        _fatalerror()
    finally:
        del sys.modules['raven']
def test_fatal_error_sentry_with_mock(sentry_dsn):
    raven_stub = type('raven', (object, ), {})
    raven_stub.Client = mock.Mock()
    try:
        sys.modules['raven'] = raven_stub
        raise ValueError('some exception')
    except:
        _fatalerror()
    finally:
        del sys.modules['raven']
    assert raven_stub.Client.called
    assert raven_stub.Client.call_args[0] == (sentry_dsn, )
    sentry_client = raven_stub.Client.return_value
    assert sentry_client.captureException.called
def test_fatal_error_sentry_with_mock(sentry_dsn):
    raven_stub = type('raven', (object, ), {})
    raven_stub.Client = mock.Mock()
    try:
        sys.modules['raven'] = raven_stub
        raise ValueError('some exception')
    except:
        _fatalerror()
    finally:
        del sys.modules['raven']
    assert raven_stub.Client.called
    assert raven_stub.Client.call_args[0] == (sentry_dsn,)
    sentry_client = raven_stub.Client.return_value
    assert sentry_client.captureException.called
def test_fatal_error(trace_print):
    exception = ValueError('some exception')
    traceback = None
    try:
        raise exception
    except:
        # get traceback before we cleaned it with fatalerror
        traceback = sys.exc_info()[2]
        _fatalerror()
    assert trace_print.called
    trace_args = trace_print.call_args_list[0]
    assert trace_args[0][0] == ValueError
    assert trace_args[0][1] == exception
    assert trace_args[0][2] == traceback
    assert trace_args[0][3] is None
    assert trace_args[0][4] == sys.stderr
def test_fatal_error(trace_print):
    exception = ValueError('some exception')
    traceback = None
    try:
        raise exception
    except:
        # get traceback before we cleaned it with fatalerror
        traceback = sys.exc_info()[2]
        _fatalerror()
    assert trace_print.called
    trace_args = trace_print.call_args_list[0]
    assert trace_args[0][0] == ValueError
    assert trace_args[0][1] == exception
    assert trace_args[0][2] == traceback
    assert trace_args[0][3] is None
    assert trace_args[0][4] == sys.stderr
def test_fatal_error_sentry_import_error(sentry_dsn):
    try:
        raise ValueError('some exception')
    except:
        _fatalerror()
def test_fatal_error_sentry_import_error(sentry_dsn):
    try:
        raise ValueError('some exception')
    except:
        _fatalerror()