From ece3f3a2e16eee8f3899fd39e74906576e789b77 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 26 Oct 2016 07:42:41 +0200 Subject: [PATCH] Update to pytest-qt 2.1.0 --- misc/requirements/requirements-tests.txt | 2 +- tests/end2end/fixtures/test_testprocess.py | 2 +- tests/helpers/fixtures.py | 4 ++-- tests/unit/browser/test_tab.py | 4 ++-- tests/unit/mainwindow/statusbar/test_textbase.py | 9 +++++---- tests/unit/mainwindow/test_messageview.py | 4 ++-- tests/unit/mainwindow/test_tabwidget.py | 5 +++-- tests/unit/misc/test_keyhints.py | 4 ++-- 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt index 91de5c0ca..2c11a4887 100644 --- a/misc/requirements/requirements-tests.txt +++ b/misc/requirements/requirements-tests.txt @@ -23,7 +23,7 @@ pytest-cov==2.4.0 pytest-faulthandler==1.3.0 pytest-instafail==0.3.0 pytest-mock==1.2 -pytest-qt==2.0.0 +pytest-qt==2.1.0 pytest-repeat==0.4.1 pytest-rerunfailures==2.0.1 pytest-travis-fold==1.2.0 diff --git a/tests/end2end/fixtures/test_testprocess.py b/tests/end2end/fixtures/test_testprocess.py index 91b45cfce..ef5b445ca 100644 --- a/tests/end2end/fixtures/test_testprocess.py +++ b/tests/end2end/fixtures/test_testprocess.py @@ -152,7 +152,7 @@ def test_process_never_started(qtbot, quit_pyproc): def test_wait_signal_raising(qtbot): """testprocess._wait_signal should raise by default.""" proc = testprocess.Process() - with pytest.raises(qtbot.SignalTimeoutError): + with pytest.raises(qtbot.TimeoutError): with proc._wait_signal(proc.proc.started, timeout=0): pass diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index b6ccb6e45..b1a6966e8 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -131,8 +131,8 @@ def fake_statusbar(qtbot): statusbar.container = container vbox.addWidget(statusbar) - container.show() - qtbot.waitForWindowShown(container) + with qtbot.waitExposed(container): + container.show() return statusbar diff --git a/tests/unit/browser/test_tab.py b/tests/unit/browser/test_tab.py index 9a8308c9e..ef35dfafa 100644 --- a/tests/unit/browser/test_tab.py +++ b/tests/unit/browser/test_tab.py @@ -121,5 +121,5 @@ def test_tab(qtbot, view, config_stub, tab_registry, mode_manager): assert tab_w.history._history is view.history() assert view.parent() is tab_w - tab_w.show() - qtbot.waitForWindowShown(tab_w) + with qtbot.waitExposed(tab_w): + tab_w.show() diff --git a/tests/unit/mainwindow/statusbar/test_textbase.py b/tests/unit/mainwindow/statusbar/test_textbase.py index 8a1b2db39..4b8ffb9f2 100644 --- a/tests/unit/mainwindow/statusbar/test_textbase.py +++ b/tests/unit/mainwindow/statusbar/test_textbase.py @@ -50,8 +50,9 @@ def test_elided_text(fake_statusbar, qtbot, elidemode, check): long_string = 'Hello world! ' * 100 label.setText(long_string) - label.show() - qtbot.waitForWindowShown(label) + + with qtbot.waitExposed(label): + label.show() assert check(label._elided_text) @@ -74,8 +75,8 @@ def test_resize(qtbot): long_string = 'Hello world! ' * 20 label.setText(long_string) - label.show() - qtbot.waitForWindowShown(label) + with qtbot.waitExposed(label): + label.show() text_1 = label._elided_text label.resize(20, 50) diff --git a/tests/unit/mainwindow/test_messageview.py b/tests/unit/mainwindow/test_messageview.py index 191d14eeb..310ea7180 100644 --- a/tests/unit/mainwindow/test_messageview.py +++ b/tests/unit/mainwindow/test_messageview.py @@ -55,8 +55,8 @@ def view(qtbot, config_stub): usertypes.MessageLevel.warning, usertypes.MessageLevel.error]) def test_single_message(qtbot, view, level): - view.show_message(level, 'test') - qtbot.waitForWindowShown(view) + with qtbot.waitExposed(view): + view.show_message(level, 'test') assert view._messages[0].isVisible() diff --git a/tests/unit/mainwindow/test_tabwidget.py b/tests/unit/mainwindow/test_tabwidget.py index bb84521d0..b9a95c810 100644 --- a/tests/unit/mainwindow/test_tabwidget.py +++ b/tests/unit/mainwindow/test_tabwidget.py @@ -72,5 +72,6 @@ class TestTabWidget: icon = QIcon(pixmap) tab = fake_web_tab() widget.addTab(tab, icon, 'foobar') - widget.show() - qtbot.waitForWindowShown(widget) + + with qtbot.waitExposed(widget): + widget.show() diff --git a/tests/unit/misc/test_keyhints.py b/tests/unit/misc/test_keyhints.py index aeef3bee5..005cce1a6 100644 --- a/tests/unit/misc/test_keyhints.py +++ b/tests/unit/misc/test_keyhints.py @@ -63,8 +63,8 @@ def keyhint(qtbot, config_stub, key_config_stub): def test_show_and_hide(qtbot, keyhint): with qtbot.waitSignal(keyhint.update_geometry): - keyhint.show() - qtbot.waitForWindowShown(keyhint) + with qtbot.waitExposed(keyhint): + keyhint.show() keyhint.update_keyhint('normal', '') assert not keyhint.isVisible()