def test_catch_exceptions():

    class CustomError(Exception):
        pass

    @click.command()
    def cli():
        raise CustomError(1)
    runner = CliRunner()
    result = runner.invoke(cli)
    assert isinstance(result.exception, CustomError)
    assert (type(result.exc_info) is tuple)
    assert (len(result.exc_info) == 3)
    with pytest.raises(CustomError):
        runner.invoke(cli, catch_exceptions=False)
    CustomError = SystemExit
    result = runner.invoke(cli)
    assert (result.exit_code == 1)
def test_catch_exceptions():

    class CustomError(Exception):
        pass

    @click.command()
    def cli():
        raise CustomError(1)
    runner = CliRunner()
    result = runner.invoke(cli)
    assert isinstance(result.exception, CustomError)
    assert (type(result.exc_info) is tuple)
    assert (len(result.exc_info) == 3)
    with pytest.raises(CustomError):
        runner.invoke(cli, catch_exceptions=False)
    CustomError = SystemExit
    result = runner.invoke(cli)
    assert (result.exit_code == 1)