From 2f60073cdf6a6c3f5cca22c4dbf0027ddde4644e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 6 Jun 2016 16:10:01 +0200 Subject: [PATCH] bdd: Allow to run invalid commands via quteproc --- tests/end2end/features/conftest.py | 10 +++++++++- tests/end2end/fixtures/quteprocess.py | 14 ++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index e9125d809..74b76833b 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -123,10 +123,18 @@ def run_command(quteproc, httpbin, command): count = int(count) else: 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('(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")) diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 9ee758775..8d462e6ea 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -330,8 +330,13 @@ class QuteProc(testprocess.Process): finally: super().after_test() - def send_cmd(self, command, count=None): - """Send a command to the running qutebrowser instance.""" + def send_cmd(self, command, count=None, invalid=False): + """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 if count is not None: summary += ' (count {})'.format(count) @@ -346,8 +351,9 @@ class QuteProc(testprocess.Process): ipc.send_to_running_instance(self._ipc_socket, [command], target_arg='') - self.wait_for(category='commands', module='command', function='run', - message='command called: *') + if not invalid: + self.wait_for(category='commands', module='command', + function='run', message='command called: *') def get_setting(self, sect, opt): """Get the value of a qutebrowser setting."""