bdd: Make quteproc.set_setting work with quotes

This hopefully fixes editor BDD tests on Windows as the editor path is
now correctly quoted.
This commit is contained in:
Florian Bruhin 2016-04-06 08:13:43 +02:00
parent 14eb63d9e9
commit d02d99e53e
2 changed files with 12 additions and 0 deletions

View File

@ -340,6 +340,8 @@ class QuteProc(testprocess.Process):
return msg.message.split(' = ')[1]
def set_setting(self, sect, opt, value):
# " in a value should be treated literally, so escape it
value = value.replace('"', '\\"')
self.send_cmd(':set "{}" "{}" "{}"'.format(sect, opt, value))
self.wait_for(category='config', message='Config option changed: *')

View File

@ -195,3 +195,13 @@ class TestClickElement:
])
def test_xpath_escape(string, expected):
assert quteprocess._xpath_escape(string) == expected
@pytest.mark.parametrize('value', [
'foo',
'foo"bar', # Make sure a " is preserved
])
def test_set(quteproc, value):
quteproc.set_setting('network', 'accept-language', value)
read_back = quteproc.get_setting('network', 'accept-language')
assert read_back == value