diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 2cc87ca33..d54a00cad 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -460,3 +460,10 @@ def clipboard_contains_multiline(qtbot, qapp, content): expected = textwrap.dedent(content) _wait_for_clipboard(qtbot, qapp.clipboard(), QClipboard.Clipboard, expected) + + +@bdd.then("qutebrowser should quit") +def should_quit(qtbot, quteproc): + quteproc.exit_expected = True + with qtbot.waitSignal(quteproc.proc.finished): + pass diff --git a/tests/integration/test_testprocess.py b/tests/integration/test_testprocess.py index b9c91c199..4c9a259d3 100644 --- a/tests/integration/test_testprocess.py +++ b/tests/integration/test_testprocess.py @@ -118,6 +118,13 @@ def test_quitting_process(qtbot, quit_pyproc): quit_pyproc.after_test() +def test_quitting_process_expected(qtbot, quit_pyproc): + quit_pyproc.exit_expected = True + with qtbot.waitSignal(quit_pyproc.proc.finished): + quit_pyproc.start() + quit_pyproc.after_test() + + def test_wait_signal_raising(qtbot): """testprocess._wait_signal should raise by default.""" proc = testprocess.Process() diff --git a/tests/integration/testprocess.py b/tests/integration/testprocess.py index f5a0b6fa3..75972ab3f 100644 --- a/tests/integration/testprocess.py +++ b/tests/integration/testprocess.py @@ -123,6 +123,7 @@ class Process(QObject): _invalid: A list of lines which could not be parsed. _data: A list of parsed lines. proc: The QProcess for the underlying process. + exit_expected: Whether the process is expected to quit. Signals: ready: Emitted when the server finished starting up. @@ -140,6 +141,7 @@ class Process(QObject): self._data = [] self.proc = QProcess() self.proc.setReadChannel(QProcess.StandardError) + self.exit_expected = False def _log(self, line): """Add the given line to the captured log output.""" @@ -242,8 +244,9 @@ class Process(QObject): raise InvalidLine(self._invalid) self.clear_data() - if not self.is_running(): + if not self.is_running() and not self.exit_expected: raise ProcessExited + self.exit_expected = False def clear_data(self): """Clear the collected data."""