test_vars: mock ask function instead of sys.stdin

This commit is contained in:
Jörg Thalheim
2024-11-26 12:06:42 +01:00
committed by Mic92
parent dc168e6f74
commit 8eb37903e0
2 changed files with 12 additions and 4 deletions

View File

@@ -6,8 +6,13 @@ from clan_cli.errors import ClanError
log = logging.getLogger(__name__)
# This is for simulating user input in tests.
MOCK_PROMPT_RESPONSE = None
def ask(description: str, input_type: str) -> str:
if MOCK_PROMPT_RESPONSE:
return next(MOCK_PROMPT_RESPONSE)
if input_type == "line":
result = input(f"Enter the value for {description}: ")
elif input_type == "multiline":