fix another test that uses stdin

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
Jonathan Wren 2021-11-27 15:34:29 -08:00
parent 733aad07b9
commit 81bdf27d67
2 changed files with 8 additions and 4 deletions

View file

@ -3,9 +3,12 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys
Scenario: Override configured editor with built-in input === editor:'' Scenario: Override configured editor with built-in input === editor:''
Given we use the config "basic_encrypted.yaml" Given we use the config "basic_encrypted.yaml"
And we use the password "test" if prompted And we use the password "test" if prompted
When we run "jrnl --config-override editor ''" When we run "jrnl --config-override editor ''" and enter
This is a journal entry
Then the stdin prompt should have been called Then the stdin prompt should have been called
And the editor should not have been called And the editor should not have been called
When we run "jrnl -1"
Then the output should contain "This is a journal entry"
Scenario: Postconfig commands with overrides Scenario: Postconfig commands with overrides

View file

@ -224,11 +224,12 @@ def should_not():
def mock_user_input(request, is_tty): def mock_user_input(request, is_tty):
def _generator(target): def _generator(target):
def _mock_user_input(): def _mock_user_input():
user_input = get_fixture(request, "user_input", "") user_input = get_fixture(request, "user_input", None)
user_input = user_input.splitlines() if is_tty else [user_input]
if not user_input: if user_input is None:
user_input = Exception("Unexpected call for user input") user_input = Exception("Unexpected call for user input")
else:
user_input = user_input.splitlines() if is_tty else [user_input]
return patch(target, side_effect=user_input) return patch(target, side_effect=user_input)