From 7c7e2fae82aeb582bb0990ffd74e41d6f7a38598 Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Wed, 27 May 2020 18:22:09 -0700 Subject: [PATCH] Fix for hanging Windows tests on Travis (#969) --- features/core.feature | 2 -- features/steps/core.py | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/features/core.feature b/features/core.feature index e6549f83..3008cfce 100644 --- a/features/core.feature +++ b/features/core.feature @@ -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" diff --git a/features/steps/core.py b/features/steps/core.py index 99ac9859..79591f57 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -93,8 +93,14 @@ def open_editor_and_enter(context, text=""): 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") @@ -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