Merge branch 'Olical-relax-editor-templating'
This commit is contained in:
commit
74a9f730da
@ -162,6 +162,7 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* John ShaggyTwoDope Jenkins
|
* John ShaggyTwoDope Jenkins
|
||||||
* Peter Vilim
|
* Peter Vilim
|
||||||
* Tarcisio Fedrizzi
|
* Tarcisio Fedrizzi
|
||||||
|
* Oliver Caldwell
|
||||||
* Jonas Schürmann
|
* Jonas Schürmann
|
||||||
* Panagiotis Ktistakis
|
* Panagiotis Ktistakis
|
||||||
* Jimmy
|
* Jimmy
|
||||||
|
@ -1094,7 +1094,7 @@ class ShellCommand(BaseType):
|
|||||||
shlex.split(value)
|
shlex.split(value)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise configexc.ValidationError(value, str(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 "
|
raise configexc.ValidationError(value, "needs to contain a "
|
||||||
"{}-placeholder.")
|
"{}-placeholder.")
|
||||||
|
|
||||||
|
@ -124,6 +124,6 @@ class ExternalEditor(QObject):
|
|||||||
self._proc.error.connect(self.on_proc_error)
|
self._proc.error.connect(self.on_proc_error)
|
||||||
editor = config.get('general', 'editor')
|
editor = config.get('general', 'editor')
|
||||||
executable = editor[0]
|
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))
|
log.procs.debug("Calling \"{}\" with args {}".format(executable, args))
|
||||||
self._proc.start(executable, args)
|
self._proc.start(executable, args)
|
||||||
|
@ -1580,14 +1580,16 @@ class TestShellCommand:
|
|||||||
({'none_ok': True}, ''),
|
({'none_ok': True}, ''),
|
||||||
({}, 'foobar'),
|
({}, 'foobar'),
|
||||||
({'placeholder': '{}'}, 'foo {} bar'),
|
({'placeholder': '{}'}, 'foo {} bar'),
|
||||||
|
({'placeholder': '{}'}, 'foo{}bar'),
|
||||||
|
({'placeholder': '{}'}, 'foo "bar {}"'),
|
||||||
])
|
])
|
||||||
def test_validate_valid(self, klass, kwargs, val):
|
def test_validate_valid(self, klass, kwargs, val):
|
||||||
klass(**kwargs).validate(val)
|
klass(**kwargs).validate(val)
|
||||||
|
|
||||||
@pytest.mark.parametrize('kwargs, val', [
|
@pytest.mark.parametrize('kwargs, val', [
|
||||||
({}, ''),
|
({}, ''),
|
||||||
({'placeholder': '{}'}, 'foo{} bar'),
|
|
||||||
({'placeholder': '{}'}, 'foo bar'),
|
({'placeholder': '{}'}, 'foo bar'),
|
||||||
|
({'placeholder': '{}'}, 'foo { } bar'),
|
||||||
({}, 'foo"'), # not splittable with shlex
|
({}, 'foo"'), # not splittable with shlex
|
||||||
])
|
])
|
||||||
def test_validate_invalid(self, klass, kwargs, val):
|
def test_validate_invalid(self, klass, kwargs, val):
|
||||||
|
@ -57,7 +57,7 @@ class TestArg:
|
|||||||
editor: The ExternalEditor instance to test.
|
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):
|
def test_start_no_placeholder(self, config_stub, editor, args):
|
||||||
"""Test starting editor without arguments."""
|
"""Test starting editor without arguments."""
|
||||||
config_stub.data['general']['editor'] = ['bin'] + args
|
config_stub.data['general']['editor'] = ['bin'] + args
|
||||||
@ -71,6 +71,13 @@ class TestArg:
|
|||||||
editor._proc._proc.start.assert_called_with(
|
editor._proc._proc.start.assert_called_with(
|
||||||
"bin", ["foo", editor._filename, "bar"])
|
"bin", ["foo", editor._filename, "bar"])
|
||||||
|
|
||||||
|
def test_placeholder_inline(self, config_stub, editor):
|
||||||
|
"""Test starting editor with placeholder arg inside of another arg."""
|
||||||
|
config_stub.data['general']['editor'] = ['bin', 'foo{}', 'bar']
|
||||||
|
editor.edit("")
|
||||||
|
editor._proc._proc.start.assert_called_with(
|
||||||
|
"bin", ["foo" + editor._filename, "bar"])
|
||||||
|
|
||||||
|
|
||||||
class TestFileHandling:
|
class TestFileHandling:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user