@pytest.mark.parametrize('stream', ['stdout', 'stderr'])
def test_exit_unsuccessful_output(qtbot, proc, caplog, py_proc, stream):
 with caplog.at_level(logging.ERROR):
  with qtbot.waitSignal(proc.finished, timeout=10000):
   proc.start(*py_proc('\n                import sys\n                print("test", file=sys.{})\n                sys.exit(1)\n            '.format(stream)))
 assert (len(caplog.records) == 2)
 assert (caplog.records[1].msg == 'Process {}:\ntest'.format(stream))

@ pytest . mark . parametrize ( 'stream' , [ 'stdout' , 'stderr' ] ) def test_exit_unsuccessful_output ( qtbot , proc , caplog , py_proc , stream ) : with caplog . at_level ( logging . ERROR ) : with qtbot . waitSignal ( proc . finished , timeout = 10000 ) : proc . start ( * py_proc ( '\n                import sys\n                print("test", file=sys.{})\n                sys.exit(1)\n            ' . format ( stream ) ) ) assert ( len ( caplog . records ) == 2 ) assert ( caplog . records [ 1 ] . msg == 'Process {}:\ntest' . format ( stream ) )
when a process fails .