You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the GitHub search to find a similar question and didn't find it.
I searched the Typer documentation, with the integrated search.
I already searched in Google "How to X in Typer" and didn't find any information.
I already read and followed all the tutorials in the docs and didn't find an answer.
I already checked if it is not related to Typer but to Click.
Commit to Help
I commit to help with one of those options 👆
Example Code
importosimportsysimportpytestfromtyper.testingimportCliRunnersys.path.append(os.path.join(os.path.dirname(__file__), "../scripts"))
frommainimportapprunner=CliRunner()
GROUP_NAME2="a-test-group"deftest_group_delete1() ->None:
"""Delete a test group which is a member of another group"""result=runner.invoke(app, ["group", "delete", GROUP_NAME2], input=["y", "y"])
assertresult.exit_code==0assert"SUCCESS"inresult.stdoutassert"Delete group"inresult.stdoutassert"Really delete"inresult.stdout
Description
I have a script which has a function for deleting a group: cli group delete <group_name>. Given delete actions are destructive, there is a need to require user input to verify the user does indeed wish to delete the group. However, groups can be a part of one or more other groups (nested groups) and can have more disruptive consequences if deleted without first addressing those relationships.
Rather than producing a different single message that the user is aware the group is a part of another group and to proceed with deletion, the CLI tool prompts the user a second time for input to ensure they really do want to delete the group (and by extension accept the consequents if they opt to move forward).
As a result of this, when attempting to write a valid typer test for this, I run into errors. It would be nice if the input variable within runner.invoke() could accept either a single string (as it is now) or an array of strings so that for other tools that have many user prompts in one command that these can be processed in sequence.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First Check
Commit to Help
Example Code
Description
I have a script which has a function for deleting a group:
cli group delete <group_name>
. Given delete actions are destructive, there is a need to require user input to verify the user does indeed wish to delete the group. However, groups can be a part of one or more other groups (nested groups) and can have more disruptive consequences if deleted without first addressing those relationships.Rather than producing a different single message that the user is aware the group is a part of another group and to proceed with deletion, the CLI tool prompts the user a second time for input to ensure they really do want to delete the group (and by extension accept the consequents if they opt to move forward).
As a result of this, when attempting to write a valid typer test for this, I run into errors. It would be nice if the
input
variable within runner.invoke() could accept either a single string (as it is now) or an array of strings so that for other tools that have many user prompts in one command that these can be processed in sequence.Thank you in advance for the consideration.
Operating System
macOS
Operating System Details
Sonoma 14.6
Typer Version
0.12.3
Python Version
Python 3.11.9
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions