示例#1
0
def test_excpethook():
    """
    Ensure the custom excepthook logs the error and calls sys.exit.
    """
    ex = Exception('BANG!')
    exc_args = (type(ex), ex, ex.__traceback__)

    with mock.patch('securedrop_client.app.logging.error') as error, \
            mock.patch('securedrop_client.app.sys.exit') as exit:
        excepthook(*exc_args)
        error.assert_called_once_with('Unrecoverable error', exc_info=exc_args)
        exit.assert_called_once_with(1)
示例#2
0
def test_excepthook(mocker):
    """
    Ensure the custom excepthook logs the error and calls sys.exit.
    """
    ex = Exception("BANG!")
    exc_args = (type(ex), ex, ex.__traceback__)

    mock_error = mocker.patch("securedrop_client.app.logging.error")
    mock_exit = mocker.patch("securedrop_client.app.sys.exit")
    excepthook(*exc_args)
    mock_error.assert_called_once_with("Unrecoverable error", exc_info=exc_args)
    mock_exit.assert_called_once_with(1)