From 81bdf27d671b532f9207618558d5eff8ab104599 Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 27 Nov 2021 15:34:29 -0800 Subject: [PATCH] fix another test that uses stdin Co-authored-by: Micah Jerome Ellison --- tests/bdd/features/override.feature | 5 ++++- tests/lib/fixtures.py | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/bdd/features/override.feature b/tests/bdd/features/override.feature index 723e74cc..fb3c279e 100644 --- a/tests/bdd/features/override.feature +++ b/tests/bdd/features/override.feature @@ -3,9 +3,12 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys Scenario: Override configured editor with built-in input === editor:'' Given we use the config "basic_encrypted.yaml" 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 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 diff --git a/tests/lib/fixtures.py b/tests/lib/fixtures.py index 51e6106b..8d820db6 100644 --- a/tests/lib/fixtures.py +++ b/tests/lib/fixtures.py @@ -224,11 +224,12 @@ def should_not(): def mock_user_input(request, is_tty): def _generator(target): def _mock_user_input(): - user_input = get_fixture(request, "user_input", "") - user_input = user_input.splitlines() if is_tty else [user_input] + user_input = get_fixture(request, "user_input", None) - if not user_input: + if user_input is None: 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)