Hopefully stabilize test_version

When using QuteProcess here, we fight with it over who can read the output.
Just use a raw QProcess instead.
This commit is contained in:
Florian Bruhin 2017-05-02 09:12:06 +02:00
parent 7b4ab901e9
commit d5c5d09b18

View File

@ -162,23 +162,24 @@ def test_optimize(request, quteproc_new, capfd, level):
quteproc_new.wait_for_quit() quteproc_new.wait_for_quit()
@pytest.mark.not_frozen
def test_version(request): def test_version(request):
"""Test invocation with --version argument.""" """Test invocation with --version argument."""
args = ['--version'] + _base_args(request.config) args = ['-m', 'qutebrowser', '--version'] + _base_args(request.config)
# can't use quteproc_new here because it's confused by # can't use quteproc_new here because it's confused by
# early process termination # early process termination
proc = quteprocess.QuteProc(request) proc = QProcess()
proc.proc.setProcessChannelMode(QProcess.SeparateChannels) proc.setProcessChannelMode(QProcess.SeparateChannels)
try: proc.start(sys.executable, args)
proc.start(args) ok = proc.waitForStarted(2000)
proc.wait_for_quit() assert ok
except testprocess.ProcessExited: ok = proc.waitForFinished(2000)
assert proc.proc.exitStatus() == QProcess.NormalExit assert ok
else: assert proc.exitStatus() == QProcess.NormalExit
pytest.fail("Process did not exit!")
output = bytes(proc.proc.readAllStandardOutput()).decode('utf-8') output = bytes(proc.readAllStandardOutput()).decode('utf-8')
print(output)
assert re.search(r'^qutebrowser\s+v\d+(\.\d+)', output) is not None assert re.search(r'^qutebrowser\s+v\d+(\.\d+)', output) is not None