Fix for hanging Windows tests on Travis (#969)

This commit is contained in:
Jonathan Wren 2020-05-27 18:22:09 -07:00 committed by GitHub
parent 99711675d4
commit 7c7e2fae82
2 changed files with 13 additions and 8 deletions

View file

@ -45,13 +45,11 @@ Feature: Basic reading and writing to a journal
When we run "jrnl -n 1" When we run "jrnl -n 1"
Then the output should contain "2013-07-23 09:00 A cold and stormy day." Then the output should contain "2013-07-23 09:00 A cold and stormy day."
@skip_win
Scenario: Writing an empty entry from the editor Scenario: Writing an empty entry from the editor
Given we use the config "editor.yaml" Given we use the config "editor.yaml"
When we open the editor and enter nothing When we open the editor and enter nothing
Then we should see the message "[Nothing saved to file]" Then we should see the message "[Nothing saved to file]"
@skip_win
Scenario: Sending an argument with spaces to the editor should work Scenario: Sending an argument with spaces to the editor should work
Given we use the config "editor-args.yaml" Given we use the config "editor-args.yaml"
When we open the editor and enter "lorem ipsum" When we open the editor and enter "lorem ipsum"

View file

@ -93,8 +93,14 @@ def open_editor_and_enter(context, text=""):
return tmpfile return tmpfile
with patch("subprocess.call", side_effect=_mock_editor_function): # fmt: off
# see: https://github.com/psf/black/issues/664
with \
patch("subprocess.call", side_effect=_mock_editor_function), \
patch("sys.stdin.isatty", return_value=True) \
:
context.execute_steps('when we run "jrnl"') context.execute_steps('when we run "jrnl"')
# fmt: on
@then("the editor should have been called with {num} arguments") @then("the editor should have been called with {num} arguments")
@ -150,11 +156,12 @@ def run_with_input(context, command, inputs=""):
args = ushlex(command)[1:] args = ushlex(command)[1:]
# fmt: off # fmt: off
# see: https://github.com/psf/black/issues/557 # see: https://github.com/psf/black/issues/664
with patch("builtins.input", side_effect=_mock_input(text)) as mock_input, \ with \
patch("builtins.input", side_effect=_mock_input(text)) as mock_input, \
patch("getpass.getpass", side_effect=_mock_getpass(text)) as mock_getpass, \ patch("getpass.getpass", side_effect=_mock_getpass(text)) as mock_getpass, \
patch("sys.stdin.read", side_effect=text) as mock_read: patch("sys.stdin.read", side_effect=text) as mock_read \
:
try: try:
cli.run(args or []) cli.run(args or [])
context.exit_status = 0 context.exit_status = 0