bdd: Add a "qutebrowser should quit" step.

This commit is contained in:
Florian Bruhin 2016-01-17 20:59:39 +01:00
parent 6e390bdc01
commit 9c5974c054
3 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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()

View File

@ -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."""