bdd: Allow to run invalid commands via quteproc

This commit is contained in:
Florian Bruhin 2016-06-06 16:10:01 +02:00
parent 4a7a2e61d3
commit 2f60073cdf
2 changed files with 19 additions and 5 deletions

View File

@ -123,10 +123,18 @@ def run_command(quteproc, httpbin, command):
count = int(count) count = int(count)
else: else:
count = None count = None
invalid_tag = ' (invalid command)'
if command.endswith(invalid_tag):
command = command[:-len(invalid_tag)]
invalid = True
else:
invalid = False
command = command.replace('(port)', str(httpbin.port)) command = command.replace('(port)', str(httpbin.port))
command = command.replace('(testdata)', utils.abs_datapath()) command = command.replace('(testdata)', utils.abs_datapath())
quteproc.send_cmd(command, count=count) quteproc.send_cmd(command, count=count, invalid=invalid)
@bdd.when(bdd.parsers.parse("I reload")) @bdd.when(bdd.parsers.parse("I reload"))

View File

@ -330,8 +330,13 @@ class QuteProc(testprocess.Process):
finally: finally:
super().after_test() super().after_test()
def send_cmd(self, command, count=None): def send_cmd(self, command, count=None, invalid=False):
"""Send a command to the running qutebrowser instance.""" """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
"""
summary = command summary = command
if count is not None: if count is not None:
summary += ' (count {})'.format(count) summary += ' (count {})'.format(count)
@ -346,8 +351,9 @@ class QuteProc(testprocess.Process):
ipc.send_to_running_instance(self._ipc_socket, [command], ipc.send_to_running_instance(self._ipc_socket, [command],
target_arg='') target_arg='')
self.wait_for(category='commands', module='command', function='run', if not invalid:
message='command called: *') self.wait_for(category='commands', module='command',
function='run', message='command called: *')
def get_setting(self, sect, opt): def get_setting(self, sect, opt):
"""Get the value of a qutebrowser setting.""" """Get the value of a qutebrowser setting."""