Skip to content

Commit

Permalink
fix one windows test, disable one windows test
Browse files Browse the repository at this point in the history
  • Loading branch information
wren committed May 23, 2020
1 parent 2522582 commit 75cbc71
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
10 changes: 6 additions & 4 deletions features/core.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ 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"
Then the editor should have been called with 5 arguments
And the editor arguments should contain "vim"
And the editor arguments should contain "-f"
And the editor arguments should contain "-c"
And the editor arguments should contain "setf markdown"
And one editor argument should be "vim"
And one editor argument should be "-f"
And one editor argument should be "-c"
And one editor argument should match "'?setf markdown'?"

Scenario: Writing an empty entry from the command line
Given we use the config "basic.yaml"
Expand Down
19 changes: 16 additions & 3 deletions features/steps/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import defaultdict
import os
from pathlib import Path
import re
import shlex
import sys
import time
Expand Down Expand Up @@ -101,9 +102,21 @@ def count_editor_args(context, num):
assert len(context.editor_command) == int(num)


@then('the editor arguments should contain "{arg}"')
@then('one editor argument should be "{arg}"')
def contains_editor_arg(context, arg):
assert arg in context.editor_command
args = context.editor_command
assert (
arg in args and args.count(arg) == 1
), f"\narg not in args exactly 1 time:\n{arg}\n{str(args)}"


@then('one editor argument should match "{regex}"')
def matches_editor_arg(context, regex):
args = context.editor_command
matches = list(filter(lambda x: re.match(regex, x), args))
assert (
len(matches) == 1
), f"\nRegex didn't match exactly 1 time:\n{regex}\n{str(args)}"


def _mock_getpass(inputs):
Expand Down Expand Up @@ -169,7 +182,7 @@ def run(context, command, cache_dir=None):
args = ushlex(command)

try:
with patch('sys.argv', args):
with patch("sys.argv", args):
cli.run(args[1:])
context.exit_status = 0
except SystemExit as e:
Expand Down

0 comments on commit 75cbc71

Please sign in to comment.