diff --git a/tests/integration/test_testprocess.py b/tests/integration/test_testprocess.py index 4f4bbea94..b9c91c199 100644 --- a/tests/integration/test_testprocess.py +++ b/tests/integration/test_testprocess.py @@ -74,6 +74,29 @@ class PythonProcess(testprocess.Process): return (sys.executable, ['-c', ';'.join(code)]) +class QuitPythonProcess(testprocess.Process): + + """A testprocess which quits immediately.""" + + def __init__(self): + super().__init__() + self.proc.setReadChannel(QProcess.StandardOutput) + + def _parse_line(self, line): + print("LINE: {}".format(line)) + if line.strip() == 'ready': + self.ready.emit() + return testprocess.Line(line) + + def _executable_args(self): + code = [ + 'import sys', + 'print("ready")', + 'sys.exit(0)', + ] + return (sys.executable, ['-c', ';'.join(code)]) + + @pytest.yield_fixture def pyproc(): proc = PythonProcess() @@ -81,6 +104,20 @@ def pyproc(): proc.terminate() +@pytest.yield_fixture +def quit_pyproc(): + proc = QuitPythonProcess() + yield proc + proc.terminate() + + +def test_quitting_process(qtbot, quit_pyproc): + with qtbot.waitSignal(quit_pyproc.proc.finished): + quit_pyproc.start() + with pytest.raises(testprocess.ProcessExited): + quit_pyproc.after_test() + + def test_wait_signal_raising(qtbot): """testprocess._wait_signal should raise by default.""" proc = testprocess.Process()