Skip to content
Discussion options

You must be logged in to vote

You can pass multiple inputs in one string with \n separator:

    result = runner.invoke(app, ["group", "delete", GROUP_NAME2], input=("y\n" + "y\n"))

Full code:

import typer
from typer.testing import CliRunner

app = typer.Typer()


@app.command()
def delete(group: str):
    typer.confirm("Are you sure?", abort=True)
    if True:  # Group has sub-groups
        typer.confirm("This group has sub-groups. Are you really sure?", abort=True)
        typer.echo("Ok, deleted.")


@app.command()
def add(group: str):
    pass


if __name__ == "__main__":
    app()


def test_():
    runner = CliRunner()
    res = runner.invoke(app, ["delete", "GROUP_NAME2"], input=("y\n" + "y\n"))
    assert "Ok,…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants