Fix test?

This commit is contained in:
Aaron Lichtman 2019-11-18 14:51:41 +01:00
parent e4012426ca
commit 9701401946
No known key found for this signature in database
GPG key ID: 22368077DE9F9903

View file

@ -101,12 +101,18 @@ def _mock_input(inputs):
@when('we run "{command}" and enter') @when('we run "{command}" and enter')
@when('we run "{command}" and enter ""')
@when('we run "{command}" and enter "{inputs1}"') @when('we run "{command}" and enter "{inputs1}"')
@when('we run "{command}" and enter "{inputs1}" and "{inputs2}"') @when('we run "{command}" and enter "{inputs1}" and "{inputs2}"')
def run_with_input(context, command, inputs1="", inputs2=""): def run_with_input(context, command, inputs1="", inputs2=""):
# create an iterator through all inputs. These inputs will be fed one by one # create an iterator through all inputs. These inputs will be fed one by one
# to the mocked calls for 'input()', 'util.getpass()' and 'sys.stdin.read()' # to the mocked calls for 'input()', 'util.getpass()' and 'sys.stdin.read()'
text = iter((inputs1, inputs2)) if inputs1 else iter(context.text.split("\n")) if inputs1:
text = iter((inputs1, inputs2))
elif context.text:
text = iter(context.text.split("\n"))
else:
text = ""
args = ushlex(command)[1:] args = ushlex(command)[1:]
with patch("builtins.input", side_effect=_mock_input(text)) as mock_input: with patch("builtins.input", side_effect=_mock_input(text)) as mock_input:
with patch("jrnl.util.getpass", side_effect=_mock_getpass(text)) as mock_getpass: with patch("jrnl.util.getpass", side_effect=_mock_getpass(text)) as mock_getpass: