Update tests to work with the earlier consumption of stdin etc.

Note: this adds an element to vulture's whitelist that vulture
mistakenly identified as unused.
This commit is contained in:
George Edward Bulmer 2017-12-10 23:46:35 +00:00
parent d32a4ea99e
commit 3b10584749
2 changed files with 24 additions and 7 deletions

View File

@ -82,6 +82,7 @@ def whitelist_generator(): # noqa
yield 'qutebrowser.utils.jinja.Loader.get_source'
yield 'qutebrowser.utils.log.QtWarningFilter.filter'
yield 'qutebrowser.browser.pdfjs.is_available'
yield 'qutebrowser.misc.guiprocess.spawn_output'
yield 'QEvent.posted'
yield 'log_stack' # from message.py
yield 'propagate' # logging.getLogger('...).propagate = False

View File

@ -19,7 +19,6 @@
"""Tests for qutebrowser.misc.guiprocess."""
import json
import logging
import pytest
@ -27,6 +26,7 @@ from PyQt5.QtCore import QProcess, QIODevice
from qutebrowser.misc import guiprocess
from qutebrowser.utils import usertypes
from qutebrowser.browser import qutescheme
@pytest.fixture()
@ -60,7 +60,7 @@ def test_start(proc, qtbot, message_mock, py_proc):
proc.start(*argv)
assert not message_mock.messages
assert bytes(proc._proc.readAll()).rstrip() == b'test'
assert qutescheme.spawn_output == proc.spawn_format(0, 0, stdout="test")
def test_start_verbose(proc, qtbot, message_mock, py_proc):
@ -77,7 +77,24 @@ def test_start_verbose(proc, qtbot, message_mock, py_proc):
assert msgs[1].level == usertypes.MessageLevel.info
assert msgs[0].text.startswith("Executing:")
assert msgs[1].text == "Testprocess exited successfully."
assert bytes(proc._proc.readAll()).rstrip() == b'test'
assert qutescheme.spawn_output == proc.spawn_format(0, 0, stdout="test")
def test_start_output(proc, qtbot, message_mock, py_proc):
"""Test starting a process verbosely."""
proc.verbose = True
with qtbot.waitSignals([proc.started, proc.finished], timeout=10000,
order='strict'):
argv = py_proc("import sys; print('test'); sys.exit(0)")
proc.start(*argv)
msgs = message_mock.messages
assert msgs[0].level == usertypes.MessageLevel.info
assert msgs[1].level == usertypes.MessageLevel.info
assert msgs[0].text.startswith("Executing:")
assert msgs[1].text == "Testprocess exited successfully."
assert qutescheme.spawn_output == proc.spawn_format(0, 0, stdout="test")
def test_start_env(monkeypatch, qtbot, py_proc):
@ -99,10 +116,9 @@ def test_start_env(monkeypatch, qtbot, py_proc):
order='strict'):
proc.start(*argv)
data = bytes(proc._proc.readAll()).decode('utf-8')
ret_env = json.loads(data)
assert 'QUTEBROWSER_TEST_1' in ret_env
assert 'QUTEBROWSER_TEST_2' in ret_env
data = qutescheme.spawn_output
assert 'QUTEBROWSER_TEST_1' in data
assert 'QUTEBROWSER_TEST_2' in data
@pytest.mark.qt_log_ignore('QIODevice::read.*: WriteOnly device')