Fix inverted POSIX check, refactor os_compat, and add tests for it

This commit is contained in:
Micah Jerome Ellison 2021-01-16 12:28:34 -08:00
parent 61f8406412
commit 3c4dc79e8a
6 changed files with 109 additions and 15 deletions

View file

@ -42,7 +42,7 @@ def before_feature(context, feature):
feature.skip()
return
if "skip_win" in feature.tags and on_windows:
if "skip_win" in feature.tags and on_windows():
feature.skip("Skipping on Windows")
return
@ -69,7 +69,7 @@ def before_scenario(context, scenario):
scenario.skip()
return
if "skip_win" in scenario.effective_tags and on_windows:
if "skip_win" in scenario.effective_tags and on_windows():
scenario.skip("Skipping on Windows")
return

View file

@ -6,7 +6,6 @@ from collections import defaultdict
import os
from pathlib import Path
import re
import shlex
import time
from unittest.mock import patch
@ -22,7 +21,7 @@ from jrnl import __version__
from jrnl import plugins
from jrnl.cli import cli
from jrnl.config import load_config
from jrnl.os_compat import on_windows
from jrnl.os_compat import split_args
try:
import parsedatetime.parsedatetime_consts as pdt
@ -87,10 +86,6 @@ class FailedKeyring(keyring.backend.KeyringBackend):
keyring.set_keyring(TestKeyring())
def ushlex(command):
return shlex.split(command, posix=not on_windows)
def read_journal(context, journal_name="default"):
configuration = load_config(context.config_path)
with open(configuration["journals"][journal_name]) as journal_file:
@ -300,7 +295,7 @@ def run_with_input(context, command, inputs=""):
else:
text = iter([inputs])
args = ushlex(command)[1:]
args = split_args(command)[1:]
def _mock_editor(command):
context.editor_command = command
@ -383,7 +378,7 @@ def run(context, command, text=""):
cache_dir = os.path.join("features", "cache", context.cache_dir)
command = command.format(cache_dir=cache_dir)
args = ushlex(command)
args = split_args(command)
def _mock_editor(command):
context.editor_command = command