From 1893a33708152fb0c30bc273e5f41a5a705f4543 Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Tue, 13 Feb 2018 20:51:18 +0000 Subject: [PATCH] Monkeypatch qapp.launch_time too --- tests/unit/utils/test_version.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py index f6e7efb16..eff67dcd8 100644 --- a/tests/unit/utils/test_version.py +++ b/tests/unit/utils/test_version.py @@ -996,7 +996,7 @@ def test_pastebin_version_twice(pbclient, monkeypatch): version.pastebin_url = None -def test_pastebin_version_error(pbclient, caplog, monkeypatch): +def test_pastebin_version_error(pbclient, caplog, message_mock, monkeypatch): """Test version.pastebin_version() with errors.""" monkeypatch.setattr('qutebrowser.utils.version.version', lambda: "dummy") @@ -1005,14 +1005,17 @@ def test_pastebin_version_error(pbclient, caplog, monkeypatch): with caplog.at_level(logging.ERROR): version.pastebin_version(pbclient) pbclient._client.error.emit("test") + assert version.pastebin_url is None - assert caplog.records[0].message == "Failed to pastebin version info: test" + + msg = message_mock.getmsg(usertypes.MessageLevel.error) + assert msg.text == "Failed to pastebin version info: test" def test_uptime(monkeypatch, qapp): """Test _uptime runs and check if microseconds are dropped.""" launch_time = datetime.datetime(1, 1, 1, 1, 1, 1, 1) - qapp.launch_time = launch_time + monkeypatch.setattr(qapp, "launch_time", launch_time, raising=False) class FakeDateTime(datetime.datetime): now = lambda x=datetime.datetime(1, 1, 1, 1, 1, 1, 2): x