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:
parent
d32a4ea99e
commit
3b10584749
@ -82,6 +82,7 @@ def whitelist_generator(): # noqa
|
|||||||
yield 'qutebrowser.utils.jinja.Loader.get_source'
|
yield 'qutebrowser.utils.jinja.Loader.get_source'
|
||||||
yield 'qutebrowser.utils.log.QtWarningFilter.filter'
|
yield 'qutebrowser.utils.log.QtWarningFilter.filter'
|
||||||
yield 'qutebrowser.browser.pdfjs.is_available'
|
yield 'qutebrowser.browser.pdfjs.is_available'
|
||||||
|
yield 'qutebrowser.misc.guiprocess.spawn_output'
|
||||||
yield 'QEvent.posted'
|
yield 'QEvent.posted'
|
||||||
yield 'log_stack' # from message.py
|
yield 'log_stack' # from message.py
|
||||||
yield 'propagate' # logging.getLogger('...).propagate = False
|
yield 'propagate' # logging.getLogger('...).propagate = False
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
"""Tests for qutebrowser.misc.guiprocess."""
|
"""Tests for qutebrowser.misc.guiprocess."""
|
||||||
|
|
||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -27,6 +26,7 @@ from PyQt5.QtCore import QProcess, QIODevice
|
|||||||
|
|
||||||
from qutebrowser.misc import guiprocess
|
from qutebrowser.misc import guiprocess
|
||||||
from qutebrowser.utils import usertypes
|
from qutebrowser.utils import usertypes
|
||||||
|
from qutebrowser.browser import qutescheme
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
@ -60,7 +60,7 @@ def test_start(proc, qtbot, message_mock, py_proc):
|
|||||||
proc.start(*argv)
|
proc.start(*argv)
|
||||||
|
|
||||||
assert not message_mock.messages
|
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):
|
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[1].level == usertypes.MessageLevel.info
|
||||||
assert msgs[0].text.startswith("Executing:")
|
assert msgs[0].text.startswith("Executing:")
|
||||||
assert msgs[1].text == "Testprocess exited successfully."
|
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):
|
def test_start_env(monkeypatch, qtbot, py_proc):
|
||||||
@ -99,10 +116,9 @@ def test_start_env(monkeypatch, qtbot, py_proc):
|
|||||||
order='strict'):
|
order='strict'):
|
||||||
proc.start(*argv)
|
proc.start(*argv)
|
||||||
|
|
||||||
data = bytes(proc._proc.readAll()).decode('utf-8')
|
data = qutescheme.spawn_output
|
||||||
ret_env = json.loads(data)
|
assert 'QUTEBROWSER_TEST_1' in data
|
||||||
assert 'QUTEBROWSER_TEST_1' in ret_env
|
assert 'QUTEBROWSER_TEST_2' in data
|
||||||
assert 'QUTEBROWSER_TEST_2' in ret_env
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.qt_log_ignore('QIODevice::read.*: WriteOnly device')
|
@pytest.mark.qt_log_ignore('QIODevice::read.*: WriteOnly device')
|
||||||
|
Loading…
Reference in New Issue
Block a user