From 9b0ebb7d847535603f0e631154e79391cd6d847f Mon Sep 17 00:00:00 2001 From: Aaron Lichtman Date: Sat, 16 Nov 2019 13:42:30 +0100 Subject: [PATCH] Add _mock_editor_function --- features/steps/core.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/features/steps/core.py b/features/steps/core.py index d4bf1b47..66fa1e11 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -71,7 +71,15 @@ def set_config(context, config_file): @when('we open the editor and enter {text}') def open_editor_and_enter(context, text=""): text = (text or context.text) - with patch('subprocess.call', return_value=text): + print("open_editor_and_enter called") + def _mock_editor_function(command): + print("_mock_editor_function called") + tmpfile = command.split()[-1] + print("TMPFILE:", tmpfile) + with open(tmpfile, "w+") as f: + f.write(text) + + with patch('subprocess.call', side_effect=_mock_editor_function): run(context, "jrnl")