Permalink
Browse files

Escape backslashes in end2end test commands

Let's hope this fixes stuff on Windows where \ is used as path
separator...
  • Loading branch information...
The-Compiler committed Jul 12, 2016
1 parent 1c86669 commit e5cab1197963cde7ff165de0273aacd35ca64fed
Showing with 10 additions and 4 deletions.
  1. +10 −4 tests/end2end/fixtures/quteprocess.py
@@ -358,13 +358,14 @@ def after_test(self, did_fail):
finally:
super().after_test()
def send_cmd(self, command, count=None, invalid=False):
def send_cmd(self, command, count=None, invalid=False, *, escape=True):
"""Send a command to the running qutebrowser instance.
Args:
count: The count to pass to the command.
invalid: If True, we don't wait for "command called: ..." in the
log
escape: Escape backslashes in the command
"""
summary = command
if count is not None:
@@ -375,6 +376,9 @@ def send_cmd(self, command, count=None, invalid=False):
time.sleep(self._delay / 1000)
if escape:
command = command.replace('\\', r'\\')
if count is not None:
command = ':{}:{}'.format(count, command.lstrip(':'))
@@ -392,9 +396,11 @@ def get_setting(self, sect, opt):
return msg.message.split(' = ')[1]
def set_setting(self, sect, opt, value):
# " in a value should be treated literally, so escape it
# \ and " in a value should be treated literally, so escape them
value = value.replace('\\', r'\\')
value = value.replace('"', '\\"')
self.send_cmd(':set "{}" "{}" "{}"'.format(sect, opt, value))
self.send_cmd(':set "{}" "{}" "{}"'.format(sect, opt, value),
escape=False)
self.wait_for(category='config', message='Config option changed: *')
@contextlib.contextmanager
@@ -517,7 +523,7 @@ def click_element(self, text):
'elems") }} '
'else {{ console.log("qute:okay"); _es.snapshotItem(0).click() }}'
).format(text=webelem.javascript_escape(_xpath_escape(text)))
self.send_cmd(':jseval ' + script)
self.send_cmd(':jseval ' + script, escape=False)
message = self.wait_for_js('qute:*').message
if message.endswith('qute:no elems'):
raise ValueError('No element with {!r} found'.format(text))

0 comments on commit e5cab11

Please sign in to comment.