Skip to content

Commit

Permalink
set return value = None when name passed for print
Browse files Browse the repository at this point in the history
  • Loading branch information
RhetTbull committed Aug 15, 2022
1 parent ccf5382 commit 508e800
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions questionary/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ def unsafe_prompt(
_kwargs.pop("input", None)

print_formatted_text(message, **_kwargs)
if name:
answers[name] = None
continue

choices = question_config.get("choices")
Expand Down
1 change: 1 addition & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def test_advanced_workflow_example():
result_dict = ask_with_patched_input(ask_dictstyle, text)

assert result_dict == {
"intro": None,
"conditional_step": True,
"next_question": "questionary",
"second_question": "Hello World",
Expand Down
7 changes: 7 additions & 0 deletions tests/test_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@ def test_print_no_name():
questions = [{"type": "print", "message": "Hello World"}]
result = patched_prompt(questions, "")
assert result == {}


def test_print_with_name():
"""'print' type should return {name: None} when name is provided"""
questions = [{"name": "hello", "type": "print", "message": "Hello World"}]
result = patched_prompt(questions, "")
assert result == {"hello": None}

0 comments on commit 508e800

Please sign in to comment.