Fix OS compatibility issues for editors with spaces, slashes, and quotes (#1153)

* Fix inverted POSIX check, refactor os_compat, and add tests for it
* Fix missing parentheses and remove skip_win on test that is passing in Windows now
* Fix expected quotes in quoted args
* Make  output clearer on failing test
* Bringing skip_win back to test whose failure is a bit more complicated than expected
This commit is contained in:
Micah Jerome Ellison 2021-01-16 15:19:11 -08:00 committed by GitHub
parent b6b6e7750e
commit 9e6cd8820f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 121 additions and 20 deletions

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
@ -23,7 +22,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
@ -88,10 +87,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:
@ -319,7 +314,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
@ -403,7 +398,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