Change FakeQProcess stub to a function with spec.
This commit is contained in:
parent
d3b727d0c7
commit
fc5349e1dc
@ -43,7 +43,7 @@ class TestArg:
|
|||||||
@pytest.yield_fixture(autouse=True)
|
@pytest.yield_fixture(autouse=True)
|
||||||
def setup(self, monkeypatch, stubs):
|
def setup(self, monkeypatch, stubs):
|
||||||
monkeypatch.setattr('qutebrowser.misc.editor.guiprocess.QProcess',
|
monkeypatch.setattr('qutebrowser.misc.editor.guiprocess.QProcess',
|
||||||
stubs.FakeQProcess())
|
stubs.fake_qprocess())
|
||||||
self.editor = editor.ExternalEditor(0)
|
self.editor = editor.ExternalEditor(0)
|
||||||
yield
|
yield
|
||||||
self.editor._cleanup() # pylint: disable=protected-access
|
self.editor._cleanup() # pylint: disable=protected-access
|
||||||
@ -102,7 +102,7 @@ class TestFileHandling:
|
|||||||
monkeypatch.setattr('qutebrowser.misc.editor.message',
|
monkeypatch.setattr('qutebrowser.misc.editor.message',
|
||||||
stubs.MessageModule())
|
stubs.MessageModule())
|
||||||
monkeypatch.setattr('qutebrowser.misc.editor.guiprocess.QProcess',
|
monkeypatch.setattr('qutebrowser.misc.editor.guiprocess.QProcess',
|
||||||
stubs.FakeQProcess())
|
stubs.fake_qprocess())
|
||||||
config_stub.data = {'general': {'editor': [''],
|
config_stub.data = {'general': {'editor': [''],
|
||||||
'editor-encoding': 'utf-8'}}
|
'editor-encoding': 'utf-8'}}
|
||||||
monkeypatch.setattr('qutebrowser.misc.editor.config', config_stub)
|
monkeypatch.setattr('qutebrowser.misc.editor.config', config_stub)
|
||||||
@ -149,7 +149,7 @@ class TestModifyTests:
|
|||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def setup(self, monkeypatch, stubs, config_stub):
|
def setup(self, monkeypatch, stubs, config_stub):
|
||||||
monkeypatch.setattr('qutebrowser.misc.editor.guiprocess.QProcess',
|
monkeypatch.setattr('qutebrowser.misc.editor.guiprocess.QProcess',
|
||||||
stubs.FakeQProcess())
|
stubs.fake_qprocess())
|
||||||
config_stub.data = {'general': {'editor': [''],
|
config_stub.data = {'general': {'editor': [''],
|
||||||
'editor-encoding': 'utf-8'}}
|
'editor-encoding': 'utf-8'}}
|
||||||
monkeypatch.setattr('qutebrowser.misc.editor.config', config_stub)
|
monkeypatch.setattr('qutebrowser.misc.editor.config', config_stub)
|
||||||
@ -221,7 +221,7 @@ class TestErrorMessage:
|
|||||||
@pytest.yield_fixture(autouse=True)
|
@pytest.yield_fixture(autouse=True)
|
||||||
def setup(self, monkeypatch, stubs, config_stub):
|
def setup(self, monkeypatch, stubs, config_stub):
|
||||||
monkeypatch.setattr('qutebrowser.misc.editor.guiprocess.QProcess',
|
monkeypatch.setattr('qutebrowser.misc.editor.guiprocess.QProcess',
|
||||||
stubs.FakeQProcess())
|
stubs.fake_qprocess())
|
||||||
monkeypatch.setattr('qutebrowser.misc.editor.message',
|
monkeypatch.setattr('qutebrowser.misc.editor.message',
|
||||||
stubs.MessageModule())
|
stubs.MessageModule())
|
||||||
config_stub.data = {'general': {'editor': [''],
|
config_stub.data = {'general': {'editor': [''],
|
||||||
|
@ -147,22 +147,13 @@ class FakeNetworkReply:
|
|||||||
self.headers[key] = value
|
self.headers[key] = value
|
||||||
|
|
||||||
|
|
||||||
class FakeQProcess(mock.Mock):
|
def fake_qprocess():
|
||||||
|
"""Factory for a QProcess mock which has the QProcess enum values."""
|
||||||
"""QProcess stub.
|
m = mock.Mock(spec=QProcess)
|
||||||
|
for attr in ['NormalExit', 'CrashExit', 'FailedToStart', 'Crashed',
|
||||||
Gets some enum values from the real QProcess.
|
'Timedout', 'WriteError', 'ReadError', 'UnknownError']:
|
||||||
"""
|
setattr(m, attr, getattr(QProcess, attr))
|
||||||
|
return m
|
||||||
NormalExit = QProcess.NormalExit
|
|
||||||
CrashExit = QProcess.CrashExit
|
|
||||||
|
|
||||||
FailedToStart = QProcess.FailedToStart
|
|
||||||
Crashed = QProcess.Crashed
|
|
||||||
Timedout = QProcess.Timedout
|
|
||||||
WriteError = QProcess.WriteError
|
|
||||||
ReadError = QProcess.ReadError
|
|
||||||
UnknownError = QProcess.UnknownError
|
|
||||||
|
|
||||||
|
|
||||||
class FakeSignal:
|
class FakeSignal:
|
||||||
|
Loading…
Reference in New Issue
Block a user