Skip to content

Commit

Permalink
Fix for hanging Windows tests on Travis (#969)
Browse files Browse the repository at this point in the history
  • Loading branch information
wren authored May 28, 2020
1 parent 9971167 commit 7c7e2fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 0 additions & 2 deletions features/core.feature
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ Feature: Basic reading and writing to a journal
When we run "jrnl -n 1"
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
Given we use the config "editor.yaml"
When we open the editor and enter nothing
Then we should see the message "[Nothing saved to file]"

@skip_win
Scenario: Sending an argument with spaces to the editor should work
Given we use the config "editor-args.yaml"
When we open the editor and enter "lorem ipsum"
Expand Down
19 changes: 13 additions & 6 deletions features/steps/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ def _mock_editor_function(command):

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"')
# fmt: on


@then("the editor should have been called with {num} arguments")
Expand Down Expand Up @@ -150,11 +156,12 @@ def run_with_input(context, command, inputs=""):
args = ushlex(command)[1:]

# fmt: off
# see: https://github.com/psf/black/issues/557
with patch("builtins.input", side_effect=_mock_input(text)) as mock_input, \
patch("getpass.getpass", side_effect=_mock_getpass(text)) as mock_getpass, \
patch("sys.stdin.read", side_effect=text) as mock_read:

# see: https://github.com/psf/black/issues/664
with \
patch("builtins.input", side_effect=_mock_input(text)) as mock_input, \
patch("getpass.getpass", side_effect=_mock_getpass(text)) as mock_getpass, \
patch("sys.stdin.read", side_effect=text) as mock_read \
:
try:
cli.run(args or [])
context.exit_status = 0
Expand Down

0 comments on commit 7c7e2fa

Please sign in to comment.