Merge branch 'relax-editor-templating' of https://github.com/Olical/qutebrowser into Olical-relax-editor-templating

This commit is contained in:
Florian Bruhin 2016-02-02 06:49:57 +01:00
commit ad290e8702
4 changed files with 6 additions and 4 deletions

View File

@ -1094,7 +1094,7 @@ class ShellCommand(BaseType):
shlex.split(value)
except ValueError as e:
raise configexc.ValidationError(value, str(e))
if self.placeholder and '{}' not in self.transform(value):
if self.placeholder and '{}' not in value:
raise configexc.ValidationError(value, "needs to contain a "
"{}-placeholder.")

View File

@ -124,6 +124,6 @@ class ExternalEditor(QObject):
self._proc.error.connect(self.on_proc_error)
editor = config.get('general', 'editor')
executable = editor[0]
args = [self._filename if arg == '{}' else arg for arg in editor[1:]]
args = [arg.replace('{}', self._filename) for arg in editor[1:]]
log.procs.debug("Calling \"{}\" with args {}".format(executable, args))
self._proc.start(executable, args)

View File

@ -1580,14 +1580,16 @@ class TestShellCommand:
({'none_ok': True}, ''),
({}, 'foobar'),
({'placeholder': '{}'}, 'foo {} bar'),
({'placeholder': '{}'}, 'foo{}bar'),
({'placeholder': '{}'}, 'foo "bar {}"'),
])
def test_validate_valid(self, klass, kwargs, val):
klass(**kwargs).validate(val)
@pytest.mark.parametrize('kwargs, val', [
({}, ''),
({'placeholder': '{}'}, 'foo{} bar'),
({'placeholder': '{}'}, 'foo bar'),
({'placeholder': '{}'}, 'foo { } bar'),
({}, 'foo"'), # not splittable with shlex
])
def test_validate_invalid(self, klass, kwargs, val):

View File

@ -57,7 +57,7 @@ class TestArg:
editor: The ExternalEditor instance to test.
"""
@pytest.mark.parametrize('args', [[], ['foo', 'bar'], ['foo{}bar']])
@pytest.mark.parametrize('args', [[], ['foo'], ['foo', 'bar']])
def test_start_no_placeholder(self, config_stub, editor, args):
"""Test starting editor without arguments."""
config_stub.data['general']['editor'] = ['bin'] + args