diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-03-01 21:18:35 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-03-01 21:18:35 +0100 |
commit | 3d5c028d9231d3d436788adcaa56785dd3c5e3b6 (patch) | |
tree | 927de7889f4937af963806c5a9121bfcfc1da30d | |
parent | 83bc7c09317c426a2a8fafc32af730930de3123b (diff) | |
parent | 1ee39297cb511a64a1979bc3204e89b13757c7c0 (diff) | |
download | qutebrowser-3d5c028d9231d3d436788adcaa56785dd3c5e3b6.tar.gz qutebrowser-3d5c028d9231d3d436788adcaa56785dd3c5e3b6.zip |
Merge remote-tracking branch 'origin/pr/6216'
36 files changed, 153 insertions, 132 deletions
diff --git a/scripts/dev/misc_checks.py b/scripts/dev/misc_checks.py index f66081dbf..98947719b 100644 --- a/scripts/dev/misc_checks.py +++ b/scripts/dev/misc_checks.py @@ -175,10 +175,27 @@ def check_spelling(args: argparse.Namespace) -> Optional[bool]: "Common misspelling or non-US spelling" ) for w in words ] + + qtbot_methods = { + 'keyPress', + 'keyRelease', + 'keyClick', + 'keyClicks', + 'keyEvent', + 'mousePress', + 'mouseRelease', + 'mouseClick', + 'mouseMove', + 'mouseDClick', + 'keySequence', + } + + qtbot_excludes = '|'.join(qtbot_methods) + patterns += [ ( re.compile(r'(?i)# noqa(?!: )'), - "Don't use a blanket 'noqa', use something like 'noqa: X123' instead.", + "Don't use a blanket 'noqa', use something like 'noqa: X123' instead." ), ( re.compile(r'# type: ignore[^\[]'), @@ -226,6 +243,10 @@ def check_spelling(args: argparse.Namespace) -> Optional[bool]: re.compile(r'IOError'), "use OSError", ), + ( + re.compile(fr'qtbot\.(?!{qtbot_excludes})[a-z]+[A-Z].*'), + "use snake-case instead", + ) ] # Files which should be ignored, e.g. because they come from another diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index a65c8b507..ce5fc3a01 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -294,7 +294,7 @@ def run_command(quteproc, server, tmpdir, command): @bdd.when(bdd.parsers.parse("I reload")) def reload(qtbot, server, quteproc, command): """Reload and wait until a new request is received.""" - with qtbot.waitSignal(server.new_request): + with qtbot.wait_signal(server.new_request): quteproc.send_cmd(':reload') diff --git a/tests/end2end/fixtures/test_quteprocess.py b/tests/end2end/fixtures/test_quteprocess.py index 81dd1d13b..c4b226972 100644 --- a/tests/end2end/fixtures/test_quteprocess.py +++ b/tests/end2end/fixtures/test_quteprocess.py @@ -104,7 +104,7 @@ def request_mock(quteproc, monkeypatch, server): ]) def test_quteproc_error_message(qtbot, quteproc, cmd, request_mock): """Make sure the test fails with an unexpected error message.""" - with qtbot.waitSignal(quteproc.got_error): + with qtbot.wait_signal(quteproc.got_error): quteproc.send_cmd(cmd) # Usually we wouldn't call this from inside a test, but here we force the # error to occur during the test rather than at teardown time. @@ -115,7 +115,7 @@ def test_quteproc_error_message(qtbot, quteproc, cmd, request_mock): def test_quteproc_error_message_did_fail(qtbot, quteproc, request_mock): """Make sure the test does not fail on teardown if the main test failed.""" request_mock.node.rep_call.failed = True - with qtbot.waitSignal(quteproc.got_error): + with qtbot.wait_signal(quteproc.got_error): quteproc.send_cmd(':message-error test') # Usually we wouldn't call this from inside a test, but here we force the # error to occur during the test rather than at teardown time. @@ -142,13 +142,13 @@ def test_quteproc_skip_and_wait_for(qtbot, quteproc): def test_qt_log_ignore(qtbot, quteproc): """Make sure the test passes when logging a qt_log_ignore message.""" - with qtbot.waitSignal(quteproc.got_error): + with qtbot.wait_signal(quteproc.got_error): quteproc.send_cmd(':message-error "SpellCheck: test"') def test_quteprocess_quitting(qtbot, quteproc_process): """When qutebrowser quits, after_test should fail.""" - with qtbot.waitSignal(quteproc_process.proc.finished, timeout=15000): + with qtbot.wait_signal(quteproc_process.proc.finished, timeout=15000): quteproc_process.send_cmd(':quit') with pytest.raises(testprocess.ProcessExited): quteproc_process.after_test() diff --git a/tests/end2end/fixtures/test_testprocess.py b/tests/end2end/fixtures/test_testprocess.py index 73fcf8b05..aa6f19c67 100644 --- a/tests/end2end/fixtures/test_testprocess.py +++ b/tests/end2end/fixtures/test_testprocess.py @@ -131,7 +131,7 @@ def test_no_ready_python_process(noready_pyproc): def test_quitting_process(qtbot, quit_pyproc): - with qtbot.waitSignal(quit_pyproc.proc.finished): + with qtbot.wait_signal(quit_pyproc.proc.finished): quit_pyproc.start() with pytest.raises(testprocess.ProcessExited): quit_pyproc.after_test() @@ -139,7 +139,7 @@ def test_quitting_process(qtbot, quit_pyproc): def test_quitting_process_expected(qtbot, quit_pyproc): quit_pyproc.exit_expected = True - with qtbot.waitSignal(quit_pyproc.proc.finished): + with qtbot.wait_signal(quit_pyproc.proc.finished): quit_pyproc.start() quit_pyproc.after_test() diff --git a/tests/end2end/fixtures/test_webserver.py b/tests/end2end/fixtures/test_webserver.py index 4ad9108ca..3c825e5bc 100644 --- a/tests/end2end/fixtures/test_webserver.py +++ b/tests/end2end/fixtures/test_webserver.py @@ -34,7 +34,7 @@ import pytest ('/data/hello.txt', 'Hello World!', True), ]) def test_server(server, qtbot, path, content, expected): - with qtbot.waitSignal(server.new_request, timeout=100): + with qtbot.wait_signal(server.new_request, timeout=100): url = 'http://localhost:{}{}'.format(server.port, path) try: response = urllib.request.urlopen(url) diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index e145255c8..4e0204741 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -73,7 +73,7 @@ class WidgetContainer(QWidget): self._widget = widget def expose(self): - with self._qtbot.waitExposed(self): + with self._qtbot.wait_exposed(self): self.show() self._widget.setFocus() @@ -407,7 +407,7 @@ def status_command_stub(stubs, qtbot, win_registry): """Fixture which provides a fake status-command object.""" cmd = stubs.StatusBarCommandStub() objreg.register('status-command', cmd, scope='window', window=0) - qtbot.addWidget(cmd) + qtbot.add_widget(cmd) yield cmd objreg.delete('status-command', scope='window', window=0) diff --git a/tests/unit/browser/test_caret.py b/tests/unit/browser/test_caret.py index ad5425b8e..288471ea0 100644 --- a/tests/unit/browser/test_caret.py +++ b/tests/unit/browser/test_caret.py @@ -107,7 +107,7 @@ def test_selection_callback_wrong_mode(qtbot, caplog, async callback was happening, so we don't want to mess with the status bar. """ assert mode_manager.mode == usertypes.KeyMode.normal - with qtbot.assertNotEmitted(webengine_tab.caret.selection_toggled): + with qtbot.assert_not_emitted(webengine_tab.caret.selection_toggled): webengine_tab.caret._toggle_sel_translate('normal') msg = 'Ignoring caret selection callback in KeyMode.normal' diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py index c032f6265..9b08de30d 100644 --- a/tests/unit/browser/test_history.py +++ b/tests/unit/browser/test_history.py @@ -290,7 +290,7 @@ class TestHistoryInterface: def test_history_interface(self, qtbot, webview, hist_interface): html = b"<a href='about:blank'>foo</a>" url = urlutils.data_url('text/html', html) - with qtbot.waitSignal(webview.loadFinished): + with qtbot.wait_signal(webview.loadFinished): webview.load(url) diff --git a/tests/unit/browser/test_inspector.py b/tests/unit/browser/test_inspector.py index cb76a18a6..f7f532050 100644 --- a/tests/unit/browser/test_inspector.py +++ b/tests/unit/browser/test_inspector.py @@ -146,9 +146,9 @@ def test_detach_after_toggling(hidden_again, needs_recreate, if needs_recreate: fake_inspector.needs_recreate = True - with qtbot.waitSignal(fake_inspector.recreate): + with qtbot.wait_signal(fake_inspector.recreate): fake_inspector.set_position(inspector.Position.window) else: - with qtbot.assertNotEmitted(fake_inspector.recreate): + with qtbot.assert_not_emitted(fake_inspector.recreate): fake_inspector.set_position(inspector.Position.window) assert fake_inspector.isVisible() and fake_inspector.isWindow() diff --git a/tests/unit/browser/webengine/test_webenginedownloads.py b/tests/unit/browser/webengine/test_webenginedownloads.py index 37c52e98c..877af3c9a 100644 --- a/tests/unit/browser/webengine/test_webenginedownloads.py +++ b/tests/unit/browser/webengine/test_webenginedownloads.py @@ -120,7 +120,7 @@ class TestDataUrlWorkaround: def test_workaround(self, webengine_tab, message_mock, qtbot, pdf_url, download_manager, expected_names): """Verify our workaround works properly.""" - with qtbot.waitSignal(message_mock.got_question): + with qtbot.wait_signal(message_mock.got_question): webengine_tab.load_url(pdf_url) question = message_mock.get_question() @@ -132,10 +132,10 @@ class TestDataUrlWorkaround: pdf_url_str = pdf_url.toDisplayString() html = f'<a href="{pdf_url_str}" download="filename.pdf" id="link">' - with qtbot.waitSignal(webengine_tab.load_finished): + with qtbot.wait_signal(webengine_tab.load_finished): webengine_tab.set_html(html) - with qtbot.waitSignal(message_mock.got_question): + with qtbot.wait_signal(message_mock.got_question): webengine_tab.elements.find_id( "link", lambda elem: elem.click(usertypes.ClickTarget.normal), @@ -157,6 +157,6 @@ class TestDataUrlWorkaround: assert os.path.basename(item.path()) == expected_names.before return True - with qtbot.waitSignal(webengine_profile.downloadRequested, + with qtbot.wait_signal(webengine_profile.downloadRequested, check_params_cb=check_item): webengineview.load(pdf_url) diff --git a/tests/unit/browser/webkit/network/test_networkreply.py b/tests/unit/browser/webkit/network/test_networkreply.py index b01fe6c5b..3cffb2fd7 100644 --- a/tests/unit/browser/webkit/network/test_networkreply.py +++ b/tests/unit/browser/webkit/network/test_networkreply.py @@ -52,7 +52,7 @@ class TestFixedDataNetworkReply: b'Hello World! This is a test.']) def test_data(self, qtbot, req, data): reply = networkreply.FixedDataNetworkReply(req, data, 'test/foo') - with qtbot.waitSignals([reply.metaDataChanged, reply.readyRead, + with qtbot.wait_signals([reply.metaDataChanged, reply.readyRead, reply.finished], order='strict'): pass @@ -78,7 +78,7 @@ def test_error_network_reply(qtbot, req): reply = networkreply.ErrorNetworkReply( req, "This is an error", QNetworkReply.UnknownNetworkError) - with qtbot.waitSignals([reply.error, reply.finished], order='strict'): + with qtbot.wait_signals([reply.error, reply.finished], order='strict'): pass reply.abort() # shouldn't do anything diff --git a/tests/unit/browser/webkit/test_cookies.py b/tests/unit/browser/webkit/test_cookies.py index 0c30c44df..81da561ce 100644 --- a/tests/unit/browser/webkit/test_cookies.py +++ b/tests/unit/browser/webkit/test_cookies.py @@ -85,7 +85,7 @@ class TestSetCookies: """Test setCookiesFromUrl with cookies enabled.""" config_stub.val.content.cookies.accept = 'all' - with qtbot.waitSignal(ram_jar.changed): + with qtbot.wait_signal(ram_jar.changed): assert ram_jar.setCookiesFromUrl([cookie], url) # assert the cookies are added correctly @@ -100,7 +100,7 @@ class TestSetCookies: """Test setCookiesFromUrl when cookies are not accepted.""" config_stub.val.content.cookies.accept = 'never' - with qtbot.assertNotEmitted(ram_jar.changed): + with qtbot.assert_not_emitted(ram_jar.changed): assert not ram_jar.setCookiesFromUrl([cookie], url) assert not ram_jar.cookiesForUrl(url) @@ -112,11 +112,11 @@ class TestSetCookies: org_url = QUrl('http://example.org/') - with qtbot.waitSignal(ram_jar.changed): + with qtbot.wait_signal(ram_jar.changed): assert ram_jar.setCookiesFromUrl([cookie], org_url) assert ram_jar.cookiesForUrl(org_url) - with qtbot.assertNotEmitted(ram_jar.changed): + with qtbot.assert_not_emitted(ram_jar.changed): assert not ram_jar.setCookiesFromUrl([cookie], url) assert not ram_jar.cookiesForUrl(url) @@ -175,7 +175,7 @@ def test_cookies_changed_emit(config_stub, fake_save_manager, monkeypatch.setattr(lineparser, 'LineParser', LineparserSaveStub) jar = cookies.CookieJar() - with qtbot.waitSignal(jar.changed): + with qtbot.wait_signal(jar.changed): config_stub.val.content.cookies.store = False diff --git a/tests/unit/commands/test_userscripts.py b/tests/unit/commands/test_userscripts.py index 6758bdd08..48bc31c32 100644 --- a/tests/unit/commands/test_userscripts.py +++ b/tests/unit/commands/test_userscripts.py @@ -44,7 +44,7 @@ class TestQtFIFOReader: def test_single_line(self, reader, qtbot): """Test QSocketNotifier with a single line of data.""" - with qtbot.waitSignal(reader.got_line) as blocker: + with qtbot.wait_signal(reader.got_line) as blocker: with open(reader._filepath, 'w', encoding='utf-8') as f: f.write('foobar\n') @@ -74,8 +74,8 @@ def test_command(qtbot, py_proc, runner): with open(os.environ['QUTE_FIFO'], 'w') as f: f.write('foo\n') """) - with qtbot.waitSignal(runner.finished, timeout=10000): - with qtbot.waitSignal(runner.got_cmd, timeout=10000) as blocker: + with qtbot.wait_signal(runner.finished, timeout=10000): + with qtbot.wait_signal(runner.got_cmd, timeout=10000) as blocker: runner.prepare_run(cmd, *args) runner.store_html('') runner.store_text('') @@ -97,8 +97,8 @@ def test_custom_env(qtbot, monkeypatch, py_proc, runner): f.write('\n') """) - with qtbot.waitSignal(runner.finished, timeout=10000): - with qtbot.waitSignal(runner.got_cmd, timeout=10000) as blocker: + with qtbot.wait_signal(runner.finished, timeout=10000): + with qtbot.wait_signal(runner.got_cmd, timeout=10000) as blocker: runner.prepare_run(cmd, *args, env=env) runner.store_html('') runner.store_text('') @@ -131,8 +131,8 @@ def test_source(qtbot, py_proc, runner): f.write('\n') """) - with qtbot.waitSignal(runner.finished, timeout=10000): - with qtbot.waitSignal(runner.got_cmd, timeout=10000) as blocker: + with qtbot.wait_signal(runner.finished, timeout=10000): + with qtbot.wait_signal(runner.got_cmd, timeout=10000) as blocker: runner.prepare_run(cmd, *args) runner.store_html('This is HTML') runner.store_text('This is text') @@ -158,8 +158,8 @@ def test_command_with_error(qtbot, py_proc, runner, caplog): """) with caplog.at_level(logging.ERROR): - with qtbot.waitSignal(runner.finished, timeout=10000): - with qtbot.waitSignal(runner.got_cmd, timeout=10000) as blocker: + with qtbot.wait_signal(runner.finished, timeout=10000): + with qtbot.wait_signal(runner.got_cmd, timeout=10000) as blocker: runner.prepare_run(cmd, *args) runner.store_text('Hello World') runner.store_html('') @@ -195,7 +195,7 @@ def test_killed_command(qtbot, tmpdir, py_proc, runner, caplog): """) args.append(str(data_file)) - with qtbot.waitSignal(watcher.directoryChanged, timeout=10000): + with qtbot.wait_signal(watcher.directoryChanged, timeout=10000): runner.prepare_run(cmd, *args) runner.store_text('Hello World') runner.store_html('') @@ -206,7 +206,7 @@ def test_killed_command(qtbot, tmpdir, py_proc, runner, caplog): data = json.load(data_file) with caplog.at_level(logging.ERROR): - with qtbot.waitSignal(runner.finished): + with qtbot.wait_signal(runner.finished): os.kill(int(data['pid']), signal.SIGTERM) assert not os.path.exists(data['text_file']) @@ -220,7 +220,7 @@ def test_temporary_files_failed_cleanup(caplog, qtbot, py_proc, runner): """) with caplog.at_level(logging.ERROR): - with qtbot.waitSignal(runner.finished, timeout=10000): + with qtbot.wait_signal(runner.finished, timeout=10000): runner.prepare_run(cmd, *args) runner.store_text('') runner.store_html('') @@ -237,7 +237,7 @@ def test_unicode_error(caplog, qtbot, py_proc, runner): f.write(b'\x80') """) with caplog.at_level(logging.ERROR): - with qtbot.waitSignal(runner.finished, timeout=10000): + with qtbot.wait_signal(runner.finished, timeout=10000): runner.prepare_run(cmd, *args) runner.store_text('') runner.store_html('') diff --git a/tests/unit/completion/test_completiondelegate.py b/tests/unit/completion/test_completiondelegate.py index 5b2e519ea..ad081ccbf 100644 --- a/tests/unit/completion/test_completiondelegate.py +++ b/tests/unit/completion/test_completiondelegate.py @@ -92,7 +92,7 @@ def test_highlighted(qtbot): # Needed so the highlighting actually works. edit = QTextEdit() - qtbot.addWidget(edit) + qtbot.add_widget(edit) edit.setDocument(doc) colors = [f.foreground().color() for f in doc.allFormats()] diff --git a/tests/unit/completion/test_completionmodel.py b/tests/unit/completion/test_completionmodel.py index e2d55082e..2130f1f1c 100644 --- a/tests/unit/completion/test_completionmodel.py +++ b/tests/unit/completion/test_completionmodel.py @@ -77,7 +77,7 @@ def test_set_pattern(pat, qtbot): for c in cats: c.set_pattern = mock.Mock(spec=[]) model.add_category(c) - with qtbot.waitSignals([model.layoutAboutToBeChanged, model.layoutChanged], + with qtbot.wait_signals([model.layoutAboutToBeChanged, model.layoutChanged], order='strict'): model.set_pattern(pat) for c in cats: diff --git a/tests/unit/completion/test_completionwidget.py b/tests/unit/completion/test_completionwidget.py index 494531ff4..89390cbf1 100644 --- a/tests/unit/completion/test_completionwidget.py +++ b/tests/unit/completion/test_completionwidget.py @@ -39,7 +39,7 @@ def completionview(qtbot, status_command_stub, config_stub, win_registry, 'qutebrowser.completion.completiondelegate.CompletionItemDelegate', new=lambda *_: None) view = completionwidget.CompletionView(cmd=status_command_stub, win_id=0) - qtbot.addWidget(view) + qtbot.add_widget(view) return view @@ -73,10 +73,10 @@ def test_set_pattern_no_model(completionview): def test_maybe_update_geometry(completionview, config_stub, qtbot): """Ensure completion is resized only if shrink is True.""" - with qtbot.assertNotEmitted(completionview.update_geometry): + with qtbot.assert_not_emitted(completionview.update_geometry): completionview._maybe_update_geometry() config_stub.val.completion.shrink = True - with qtbot.waitSignal(completionview.update_geometry): + with qtbot.wait_signal(completionview.update_geometry): completionview._maybe_update_geometry() @@ -137,10 +137,10 @@ def test_completion_item_focus(which, tree, expected, completionview, model, qtb completionview.set_model(model) for entry in expected: if entry is None: - with qtbot.assertNotEmitted(completionview.selection_changed): + with qtbot.assert_not_emitted(completionview.selection_changed): completionview.completion_item_focus(which) else: - with qtbot.waitSignal(completionview.selection_changed) as sig: + with qtbot.wait_signal(completionview.selection_changed) as sig: completionview.completion_item_focus(which) assert sig.args == [entry] @@ -153,11 +153,11 @@ def test_completion_item_focus_no_model(which, completionview, model, qtbot): Validates #1812: help completion repeatedly completes """ - with qtbot.assertNotEmitted(completionview.selection_changed): + with qtbot.assert_not_emitted(completionview.selection_changed): completionview.completion_item_focus(which) completionview.set_model(model) completionview.set_model(None) - with qtbot.assertNotEmitted(completionview.selection_changed): + with qtbot.assert_not_emitted(completionview.selection_changed): completionview.completion_item_focus(which) @@ -214,7 +214,7 @@ class TestCompletionItemFocusPage: cat = listcategory.ListCategory('Test', items) model.add_category(cat) completionview.set_model(model) - with qtbot.waitSignal(completionview.selection_changed) as blocker: + with qtbot.wait_signal(completionview.selection_changed) as blocker: completionview.completion_item_focus(which) assert blocker.args == [expected] @@ -259,7 +259,7 @@ class TestCompletionItemFocusPage: for move, item in steps: print('{:9} -> expecting {}'.format(move, item)) - with qtbot.waitSignal(completionview.selection_changed) as blocker: + with qtbot.wait_signal(completionview.selection_changed) as blocker: completionview.completion_item_focus(move) assert blocker.args == [item] @@ -273,7 +273,7 @@ class TestCompletionItemFocusPage: completionview.set_model(model) for move, item in [('next', 'Item 1'), ('next-page', 'Target item')]: - with qtbot.waitSignal(completionview.selection_changed) as blocker: + with qtbot.wait_signal(completionview.selection_changed) as blocker: completionview.completion_item_focus(move) assert blocker.args == [item] diff --git a/tests/unit/components/test_blockutils.py b/tests/unit/components/test_blockutils.py index 205dd7fc1..f206f3b6a 100644 --- a/tests/unit/components/test_blockutils.py +++ b/tests/unit/components/test_blockutils.py @@ -76,7 +76,7 @@ def test_blocklist_dl(qtbot, pretend_blocklists): dl = blockutils.BlocklistDownloads(list_qurls) dl.single_download_finished.connect(on_single_download) - with qtbot.waitSignal(dl.all_downloads_finished) as blocker: + with qtbot.wait_signal(dl.all_downloads_finished) as blocker: dl.initiate() assert blocker.args == [total_expected] diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index 7f35af024..8a9d8154d 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -432,7 +432,7 @@ class TestConfig: assert conf.get_obj(name1) == 'never' assert conf.get_obj(name2) is True - with qtbot.waitSignals([conf.changed, conf.changed]) as blocker: + with qtbot.wait_signals([conf.changed, conf.changed]) as blocker: conf.clear(save_yaml=save_yaml) options = {e.args[0] for e in blocker.all_signals_and_args} diff --git a/tests/unit/config/test_configutils.py b/tests/unit/config/test_configutils.py index 4a14df5ff..4d3082a92 100644 --- a/tests/unit/config/test_configutils.py +++ b/tests/unit/config/test_configutils.py @@ -382,7 +382,7 @@ class TestFontFamilies: print(stylesheet) label.setStyleSheet(stylesheet) - with qtbot.waitExposed(label): + with qtbot.wait_exposed(label): # Needed so the font gets calculated label.show() info = label.fontInfo() @@ -396,7 +396,7 @@ class TestFontFamilies: qtbot.add_widget(label) fallback_label.setText("fallback") - with qtbot.waitExposed(fallback_label): + with qtbot.wait_exposed(fallback_label): # Needed so the font gets calculated fallback_label.show() diff --git a/tests/unit/config/test_stylesheet.py b/tests/unit/config/test_stylesheet.py index 96a3b2b6e..4ffa107ed 100644 --- a/tests/unit/config/test_stylesheet.py +++ b/tests/unit/config/test_stylesheet.py @@ -64,7 +64,7 @@ def test_set_register_stylesheet(delete, stylesheet_param, update, changed_optio assert obj.rendered_stylesheet == 'magenta' if delete: - with qtbot.waitSignal(obj.destroyed): + with qtbot.wait_signal(obj.destroyed): obj.deleteLater() config_stub.set_obj(changed_option, 'yellow') diff --git a/tests/unit/javascript/conftest.py b/tests/unit/javascript/conftest.py index e1f6aac2a..47884687d 100644 --- a/tests/unit/javascript/conftest.py +++ b/tests/unit/javascript/conftest.py @@ -65,14 +65,14 @@ class JSTester: template = self._jinja_env.get_template(path) try: - with self.qtbot.waitSignal(self.tab.load_finished, + with self.qtbot.wait_signal(self.tab.load_finished, timeout=2000) as blocker: self.tab.set_html(template.render(**kwargs), base_url=base_url) except self.qtbot.TimeoutError: # Sometimes this fails for some odd reason on macOS, let's just try # again. print("Trying to load page again...") - with self.qtbot.waitSignal(self.tab.load_finished, + with self.qtbot.wait_signal(self.tab.load_finished, timeout=2000) as blocker: self.tab.set_html(template.render(**kwargs), base_url=base_url) @@ -95,7 +95,7 @@ class JSTester: url: The QUrl to load. force: Whether to force loading even if the file is invalid. """ - with self.qtbot.waitSignal(self.tab.load_finished, + with self.qtbot.wait_signal(self.tab.load_finished, timeout=2000) as blocker: self.tab.load_url(url) if not force: diff --git a/tests/unit/keyinput/test_basekeyparser.py b/tests/unit/keyinput/test_basekeyparser.py index 57563338f..30ee36301 100644 --- a/tests/unit/keyinput/test_basekeyparser.py +++ b/tests/unit/keyinput/test_basekeyparser.py @@ -312,7 +312,7 @@ class TestCount: def test_count_keystring_update(self, qtbot, handle_text, prompt_keyparser): """Make sure the keystring is updated correctly when entering count.""" - with qtbot.waitSignals([ + with qtbot.wait_signals([ prompt_keyparser.keystring_updated, prompt_keyparser.keystring_updated]) as blocker: handle_text(prompt_keyparser, Qt.Key_4, Qt.Key_2) @@ -335,7 +335,7 @@ def test_clear_keystring(qtbot, keyparser): """Test that the keystring is cleared and the signal is emitted.""" keyparser._sequence = keyseq('test') keyparser._count = '23' - with qtbot.waitSignal(keyparser.keystring_updated): + with qtbot.wait_signal(keyparser.keystring_updated): keyparser.clear_keystring() assert not keyparser._sequence assert not keyparser._count diff --git a/tests/unit/mainwindow/statusbar/test_textbase.py b/tests/unit/mainwindow/statusbar/test_textbase.py index e77b11671..631c6ce44 100644 --- a/tests/unit/mainwindow/statusbar/test_textbase.py +++ b/tests/unit/mainwindow/statusbar/test_textbase.py @@ -64,7 +64,7 @@ def test_resize(qtbot): long_string = 'Hello world! ' * 20 label.setText(long_string) - with qtbot.waitExposed(label): + with qtbot.wait_exposed(label): label.show() text_1 = label._elided_text diff --git a/tests/unit/mainwindow/test_messageview.py b/tests/unit/mainwindow/test_messageview.py index 03b8c9879..82328ffea 100644 --- a/tests/unit/mainwindow/test_messageview.py +++ b/tests/unit/mainwindow/test_messageview.py @@ -37,14 +37,14 @@ def view(qtbot, config_stub): usertypes.MessageLevel.error]) @pytest.mark.flaky # on macOS def test_single_message(qtbot, view, level): - with qtbot.waitExposed(view, timeout=5000): + with qtbot.wait_exposed(view, timeout=5000): view.show_message(level, 'test') assert view._messages[0].isVisible() def test_message_hiding(qtbot, view): """Messages should be hidden after the timer times out.""" - with qtbot.waitSignal(view._clear_timer.timeout): + with qtbot.wait_signal(view._clear_timer.timeout): view.show_message(usertypes.MessageLevel.info, 'test') assert not view._messages @@ -61,7 +61,7 @@ def test_size_hint(view): def test_word_wrap(view, qtbot): """A long message should be wrapped.""" - with qtbot.waitSignal(view._clear_timer.timeout): + with qtbot.wait_signal(view._clear_timer.timeout): view.show_message(usertypes.MessageLevel.info, 'short') height1 = view.sizeHint().height() assert height1 > 0 @@ -88,7 +88,7 @@ def test_show_message_twice(view): def test_show_message_twice_after_first_disappears(qtbot, view): """Show the same message twice after the first is gone.""" - with qtbot.waitSignal(view._clear_timer.timeout): + with qtbot.wait_signal(view._clear_timer.timeout): view.show_message(usertypes.MessageLevel.info, 'test') # Just a sanity check assert not view._messages @@ -101,7 +101,7 @@ def test_changing_timer_with_messages_shown(qtbot, view, config_stub): """When we change messages.timeout, the timer should be restarted.""" config_stub.val.messages.timeout = 900000 # 15s view.show_message(usertypes.MessageLevel.info, 'test') - with qtbot.waitSignal(view._clear_timer.timeout): + with qtbot.wait_signal(view._clear_timer.timeout): config_stub.val.messages.timeout = 100 diff --git a/tests/unit/mainwindow/test_tabwidget.py b/tests/unit/mainwindow/test_tabwidget.py index 3f9e0292d..564ca1b38 100644 --- a/tests/unit/mainwindow/test_tabwidget.py +++ b/tests/unit/mainwindow/test_tabwidget.py @@ -36,7 +36,7 @@ class TestTabWidget: @pytest.fixture def widget(self, qtbot, monkeypatch, config_stub): w = tabwidget.TabWidget(0) - qtbot.addWidget(w) + qtbot.add_widget(w) monkeypatch.setattr(tabwidget.objects, 'backend', usertypes.Backend.QtWebKit) w.show() @@ -53,7 +53,7 @@ class TestTabWidget: tab = fake_web_tab() widget.addTab(tab, icon, 'foobar') - with qtbot.waitExposed(widget): + with qtbot.wait_exposed(widget): widget.show() # Sizing tests @@ -118,7 +118,7 @@ class TestTabWidget: for i in range(num_tabs): widget.addTab(fake_web_tab(), 'foobar' + str(i)) - with qtbot.waitExposed(widget): + with qtbot.wait_exposed(widget): widget.show() benchmark(widget.update_tab_titles) diff --git a/tests/unit/misc/test_autoupdate.py b/tests/unit/misc/test_autoupdate.py index f86b9b0ff..f7cf78248 100644 --- a/tests/unit/misc/test_autoupdate.py +++ b/tests/unit/misc/test_autoupdate.py @@ -64,8 +64,8 @@ def test_get_version_success(qtbot): http_stub = HTTPGetStub(success=True) client = autoupdate.PyPIVersionClient(client=http_stub) - with qtbot.assertNotEmitted(client.error): - with qtbot.waitSignal(client.success): + with qtbot.assert_not_emitted(client.error): + with qtbot.wait_signal(client.success): client.get_version('test') assert http_stub.url == QUrl(client.API_URL.format('test')) @@ -76,8 +76,8 @@ def test_get_version_error(qtbot): http_stub = HTTPGetStub(success=False) client = autoupdate.PyPIVersionClient(client=http_stub) - with qtbot.assertNotEmitted(client.success): - with qtbot.waitSignal(client.error): + with qtbot.assert_not_emitted(client.success): + with qtbot.wait_signal(client.error): client.get_version('test') @@ -88,6 +88,6 @@ def test_invalid_json(qtbot, json): client = autoupdate.PyPIVersionClient(client=http_stub) client.get_version('test') - with qtbot.assertNotEmitted(client.success): - with qtbot.waitSignal(client.error): + with qtbot.assert_not_emitted(client.success): + with qtbot.wait_signal(client.error): client.get_version('test') diff --git a/tests/unit/misc/test_guiprocess.py b/tests/unit/misc/test_guiprocess.py index c224118a8..a2acad1ac 100644 --- a/tests/unit/misc/test_guiprocess.py +++ b/tests/unit/misc/test_guiprocess.py @@ -36,7 +36,7 @@ def proc(qtbot, caplog): yield p if p._proc.state() == QProcess.Running: with caplog.at_level(logging.ERROR): - with qtbot.waitSignal(p.finished, timeout=10000, + with qtbot.wait_signal(p.finished, timeout=10000, raising=False) as blocker: p._proc.terminate() if not blocker.signal_triggered: @@ -54,7 +54,7 @@ def fake_proc(monkeypatch, stubs): def test_start(proc, qtbot, message_mock, py_proc): """Test simply starting a process.""" - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + with qtbot.wait_signals([proc.started, proc.finished], timeout=10000, order='strict'): argv = py_proc("import sys; print('test'); sys.exit(0)") proc.start(*argv) @@ -70,7 +70,7 @@ def test_start_verbose(proc, qtbot, message_mock, py_proc): """Test starting a process verbosely.""" proc.verbose = True - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + with qtbot.wait_signals([proc.started, proc.finished], timeout=10000, order='strict'): argv = py_proc("import sys; print('test'); sys.exit(0)") proc.start(*argv) @@ -99,7 +99,7 @@ def test_start_output_message(proc, qtbot, caplog, message_mock, py_proc, code.append("sys.exit(0)") with caplog.at_level(logging.ERROR, 'message'): - with qtbot.waitSignals([proc.started, proc.finished], + with qtbot.wait_signals([proc.started, proc.finished], timeout=10000, order='strict'): argv = py_proc(';'.join(code)) @@ -147,7 +147,7 @@ def test_start_env(monkeypatch, qtbot, py_proc): sys.exit(0) """) - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + with qtbot.wait_signals([proc.started, proc.finished], timeout=10000, order='strict'): proc.start(*argv) @@ -178,7 +178,7 @@ def test_start_detached_error(fake_proc, message_mock, caplog): def test_double_start(qtbot, proc, py_proc): """Test starting a GUIProcess twice.""" - with qtbot.waitSignal(proc.started, timeout=10000): + with qtbot.wait_signal(proc.started, timeout=10000): argv = py_proc("import time; time.sleep(10)") proc.start(*argv) with pytest.raises(ValueError): @@ -187,11 +187,11 @@ def test_double_start(qtbot, proc, py_proc): def test_double_start_finished(qtbot, proc, py_proc): """Test starting a GUIProcess twice (with the first call finished).""" - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + with qtbot.wait_signals([proc.started, proc.finished], timeout=10000, order='strict'): argv = py_proc("import sys; sys.exit(0)") proc.start(*argv) - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + with qtbot.wait_signals([proc.started, proc.finished], timeout=10000, order='strict'): argv = py_proc("import sys; sys.exit(0)") proc.start(*argv) @@ -220,7 +220,7 @@ def test_start_logging(fake_proc, caplog): def test_error(qtbot, proc, caplog, message_mock): """Test the process emitting an error.""" with caplog.at_level(logging.ERROR, 'message'): - with qtbot.waitSignal(proc.error, timeout=5000): + with qtbot.wait_signal(proc.error, timeout=5000): proc.start('this_does_not_exist_either', []) msg = message_mock.getmsg(usertypes.MessageLevel.error) @@ -229,7 +229,7 @@ def test_error(qtbot, proc, caplog, message_mock): def test_exit_unsuccessful(qtbot, proc, message_mock, py_proc, caplog): with caplog.at_level(logging.ERROR): - with qtbot.waitSignal(proc.finished, timeout=10000): + with qtbot.wait_signal(proc.finished, timeout=10000): proc.start(*py_proc('import sys; sys.exit(1)')) msg = message_mock.getmsg(usertypes.MessageLevel.error) @@ -239,7 +239,7 @@ def test_exit_unsuccessful(qtbot, proc, message_mock, py_proc, caplog): def test_exit_crash(qtbot, proc, message_mock, py_proc, caplog): with caplog.at_level(logging.ERROR): - with qtbot.waitSignal(proc.finished, timeout=10000): + with qtbot.wait_signal(proc.finished, timeout=10000): proc.start(*py_proc(""" import os, signal os.kill(os.getpid(), signal.SIGSEGV) @@ -257,7 +257,7 @@ def test_exit_crash(qtbot, proc, message_mock, py_proc, caplog): def test_exit_unsuccessful_output(qtbot, proc, caplog, py_proc, stream): """When a process fails, its output should be logged.""" with caplog.at_level(logging.ERROR): - with qtbot.waitSignal(proc.finished, timeout=10000): + with qtbot.wait_signal(proc.finished, timeout=10000): proc.start(*py_proc(""" import sys print("test", file=sys.{}) @@ -273,7 +273,7 @@ def test_exit_successful_output(qtbot, proc, py_proc, stream): The test doesn't actually check the log as it'd fail because of the error logging. """ - with qtbot.waitSignal(proc.finished, timeout=10000): + with qtbot.wait_signal(proc.finished, timeout=10000): proc.start(*py_proc(""" import sys print("test", file=sys.{}) @@ -283,7 +283,7 @@ def test_exit_successful_output(qtbot, proc, py_proc, stream): def test_stdout_not_decodable(proc, qtbot, message_mock, py_proc): """Test handling malformed utf-8 in stdout.""" - with qtbot.waitSignals([proc.started, proc.finished], timeout=10000, + with qtbot.wait_signals([proc.started, proc.finished], timeout=10000, order='strict'): argv = py_proc(r""" import sys diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index 3b8092281..c19d0bc42 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -57,7 +57,7 @@ def ipc_server(qapp, qtbot): yield server if (server._socket is not None and server._socket.state() != QLocalSocket.UnconnectedState): - with qtbot.waitSignal(server._socket.disconnected, raising=False): + with qtbot.wait_signal(server._socket.disconnected, raising=False): server._socket.abort() try: server.shutdown() @@ -335,11 +335,11 @@ class TestListen: sockfile_path = pathlib.Path(ipc_server._server.fullServerName()) old_atime = sockfile_path.stat().st_atime_ns - with qtbot.waitSignal(ipc_server._atime_timer.timeout, timeout=2000): + with qtbot.wait_signal(ipc_server._atime_timer.timeout, timeout=2000): pass # Make sure the timer is not singleShot - with qtbot.waitSignal(ipc_server._atime_timer.timeout, timeout=2000): + with qtbot.wait_signal(ipc_server._atime_timer.timeout, timeout=2000): pass new_atime = sockfile_path.stat().st_atime_ns @@ -368,7 +368,7 @@ class TestListen: sockfile.unlink() with caplog.at_level(logging.ERROR): - with qtbot.waitSignal(ipc_server._atime_timer.timeout, + with qtbot.wait_signal(ipc_server._atime_timer.timeout, timeout=2000): pass @@ -445,7 +445,7 @@ class TestHandleConnection: ipc_server._server = FakeServer(socket) - with qtbot.waitSignal(ipc_server.got_args) as blocker: + with qtbot.wait_signal(ipc_server.got_args) as blocker: ipc_server.handle_connection() assert blocker.args == [['foo'], 'tab', ''] @@ -458,7 +458,7 @@ def connected_socket(qtbot, qlocalsocket, ipc_server): pytest.skip("Skipping connected_socket test - " "https://github.com/qutebrowser/qutebrowser/issues/1045") ipc_server.listen() - with qtbot.waitSignal(ipc_server._server.newConnection): + with qtbot.wait_signal(ipc_server._server.newConnection): qlocalsocket.connectToServer('qute-test') yield qlocalsocket qlocalsocket.disconnectFromServer() @@ -498,8 +498,8 @@ NEW_VERSION = str(ipc.PROTOCOL_VERSION + 1).encode('utf-8') def test_invalid_data(qtbot, ipc_server, connected_socket, caplog, data, msg): signals = [ipc_server.got_invalid_data, connected_socket.disconnected] with caplog.at_level(logging.ERROR): - with qtbot.assertNotEmitted(ipc_server.got_args): - with qtbot.waitSignals(signals, order='strict'): + with qtbot.assert_not_emitted(ipc_server.got_args): + with qtbot.wait_signals(signals, order='strict'): connected_socket.write(data) invalid_msg = 'Ignoring invalid IPC data from socket ' @@ -516,8 +516,8 @@ def test_multiline(qtbot, ipc_server, connected_socket): ' "protocol_version": {version}}}\n'.format( version=ipc.PROTOCOL_VERSION)) - with qtbot.assertNotEmitted(ipc_server.got_invalid_data): - with qtbot.waitSignals([ipc_server.got_args, ipc_server.got_args], + with qtbot.assert_not_emitted(ipc_server.got_invalid_data): + with qtbot.wait_signals([ipc_server.got_args, ipc_server.got_args], order='strict'): connected_socket.write(data.encode('utf-8')) @@ -538,10 +538,10 @@ class TestSendToRunningInstance: def test_normal(self, qtbot, tmp_path, ipc_server, mocker, has_cwd): ipc_server.listen() - with qtbot.assertNotEmitted(ipc_server.got_invalid_data): - with qtbot.waitSignal(ipc_server.got_args, + with qtbot.assert_not_emitted(ipc_server.got_invalid_data): + with qtbot.wait_signal(ipc_server.got_args, timeout=5000) as blocker: - with qtbot.waitSignal(ipc_server.got_raw, + with qtbot.wait_signal(ipc_server.got_raw, timeout=5000) as raw_blocker: with testutils.change_cwd(tmp_path): if not has_cwd: @@ -590,11 +590,11 @@ def test_timeout(qtbot, caplog, qlocalsocket, ipc_server): ipc_server._timer.setInterval(100) ipc_server.listen() - with qtbot.waitSignal(ipc_server._server.newConnection): + with qtbot.wait_signal(ipc_server._server.newConnection): qlocalsocket.connectToServer('qute-test') with caplog.at_level(logging.ERROR): - with qtbot.waitSignal(qlocalsocket.disconnected, timeout=5000): + with qtbot.wait_signal(qlocalsocket.disconnected, timeout=5000): pass assert caplog.messages[-1].startswith("IPC connection timed out") @@ -656,7 +656,7 @@ class TestSendOrListen: assert "Starting IPC server..." in caplog.messages assert ret_server is ipc.server - with qtbot.waitSignal(ret_server.got_args): + with qtbot.wait_signal(ret_server.got_args): ret_client = ipc.send_or_listen(args) assert ret_client is None diff --git a/tests/unit/misc/test_keyhints.py b/tests/unit/misc/test_keyhints.py index 580869b45..8d9c53c93 100644 --- a/tests/unit/misc/test_keyhints.py +++ b/tests/unit/misc/test_keyhints.py @@ -55,8 +55,8 @@ def keyhint(qtbot, config_stub, key_config_stub): def test_show_and_hide(qtbot, keyhint): - with qtbot.waitSignal(keyhint.update_geometry): - with qtbot.waitExposed(keyhint): + with qtbot.wait_signal(keyhint.update_geometry): + with qtbot.wait_exposed(keyhint): keyhint.show() keyhint.update_keyhint(usertypes.KeyMode.normal, '') assert not keyhint.isVisible() diff --git a/tests/unit/misc/test_miscwidgets.py b/tests/unit/misc/test_miscwidgets.py index 572a5cbc9..6e1919ec3 100644 --- a/tests/unit/misc/test_miscwidgets.py +++ b/tests/unit/misc/test_miscwidgets.py @@ -127,7 +127,7 @@ class TestFullscreenNotification: def test_timeout(self, qtbot, key_config_stub): w = miscwidgets.FullscreenNotification() qtbot.add_widget(w) - with qtbot.waitSignal(w.destroyed): + with qtbot.wait_signal(w.destroyed): w.set_timeout(1) diff --git a/tests/unit/misc/test_msgbox.py b/tests/unit/misc/test_msgbox.py index 7be0266a3..c5c23639a 100644 --- a/tests/unit/misc/test_msgbox.py +++ b/tests/unit/misc/test_msgbox.py @@ -77,7 +77,7 @@ def test_finished_signal(qtbot): qtbot.add_widget(box) - with qtbot.waitSignal(box.finished): + with qtbot.wait_signal(box.finished): box.accept() assert signal_triggered diff --git a/tests/unit/misc/test_pastebin.py b/tests/unit/misc/test_pastebin.py index e750bb299..7a47e723c 100644 --- a/tests/unit/misc/test_pastebin.py +++ b/tests/unit/misc/test_pastebin.py @@ -99,8 +99,8 @@ def test_paste_private(pbclient): "http://paste.the-compiler.org/view/3gjnwg4" ]) def test_on_client_success(http, pbclient, qtbot): - with qtbot.assertNotEmitted(pbclient.error): - with qtbot.waitSignal(pbclient.success): + with qtbot.assert_not_emitted(pbclient.error): + with qtbot.wait_signal(pbclient.success): pbclient._client.success.emit(http) @@ -110,12 +110,12 @@ def test_on_client_success(http, pbclient, qtbot): "http//invalid.com" ]) def test_client_success_invalid_http(http, pbclient, qtbot): - with qtbot.assertNotEmitted(pbclient.success): - with qtbot.waitSignal(pbclient.error): + with qtbot.assert_not_emitted(pbclient.success): + with qtbot.wait_signal(pbclient.error): pbclient._client.success.emit(http) def test_client_error(pbclient, qtbot): - with qtbot.assertNotEmitted(pbclient.success): - with qtbot.waitSignal(pbclient.error): + with qtbot.assert_not_emitted(pbclient.success): + with qtbot.wait_signal(pbclient.error): pbclient._client.error.emit("msg") diff --git a/tests/unit/misc/test_sql.py b/tests/unit/misc/test_sql.py index 92bede511..f6fa68869 100644 --- a/tests/unit/misc/test_sql.py +++ b/tests/unit/misc/test_sql.py @@ -128,18 +128,18 @@ def test_init(): def test_insert(qtbot): table = sql.SqlTable('Foo', ['name', 'val', 'lucky']) - with qtbot.waitSignal(table.changed): + with qtbot.wait_signal(table.changed): table.insert({'name': 'one', 'val': 1, 'lucky': False}) - with qtbot.waitSignal(table.changed): + with qtbot.wait_signal(table.changed): table.insert({'name': 'wan', 'val': 1, 'lucky': False}) def test_insert_replace(qtbot): table = sql.SqlTable('Foo', ['name', 'val', 'lucky'], constraints={'name': 'PRIMARY KEY'}) - with qtbot.waitSignal(table.changed): + with qtbot.wait_signal(table.changed): table.insert({'name': 'one', 'val': 1, 'lucky': False}, replace=True) - with qtbot.waitSignal(table.changed): + with qtbot.wait_signal(table.changed): table.insert({'name': 'one', 'val': 11, 'lucky': True}, replace=True) assert list(table) == [('one', 11, True)] @@ -150,7 +150,7 @@ def test_insert_replace(qtbot): def test_insert_batch(qtbot): table = sql.SqlTable('Foo', ['name', 'val', 'lucky']) - with qtbot.waitSignal(table.changed): + with qtbot.wait_signal(table.changed): table.insert_batch({'name': ['one', 'nine', 'thirteen'], 'val': [1, 9, 13], 'lucky': [False, False, True]}) @@ -164,12 +164,12 @@ def test_insert_batch_replace(qtbot): table = sql.SqlTable('Foo', ['name', 'val', 'lucky'], constraints={'name': 'PRIMARY KEY'}) - with qtbot.waitSignal(table.changed): + with qtbot.wait_signal(table.changed): table.insert_batch({'name': ['one', 'nine', 'thirteen'], 'val': [1, 9, 13], 'lucky': [False, False, True]}) - with qtbot.waitSignal(table.changed): + with qtbot.wait_signal(table.changed): table.insert_batch({'name': ['one', 'nine'], 'val': [11, 19], 'lucky': [True, True]}, @@ -219,10 +219,10 @@ def test_delete(qtbot): table.insert({'name': 'thirteen', 'val': 13, 'lucky': True}) with pytest.raises(KeyError): table.delete('name', 'nope') - with qtbot.waitSignal(table.changed): + with qtbot.wait_signal(table.changed): table.delete('name', 'thirteen') assert list(table) == [('one', 1, False), ('nine', 9, False)] - with qtbot.waitSignal(table.changed): + with qtbot.wait_signal(table.changed): table.delete('lucky', False) assert not list(table) @@ -284,7 +284,7 @@ def test_delete_all(qtbot): table.insert({'name': 'one', 'val': 1, 'lucky': False}) table.insert({'name': 'nine', 'val': 9, 'lucky': False}) table.insert({'name': 'thirteen', 'val': 13, 'lucky': True}) - with qtbot.waitSignal(table.changed): + with qtbot.wait_signal(table.changed): table.delete_all() assert list(table) == [] diff --git a/tests/unit/utils/test_javascript.py b/tests/unit/utils/test_javascript.py index e8acc30fb..7a97ef6d1 100644 --- a/tests/unit/utils/test_javascript.py +++ b/tests/unit/utils/test_javascript.py @@ -73,7 +73,7 @@ class TestStringEscape: """Test conversion by running JS in a tab.""" escaped = javascript.string_escape(text) - with qtbot.waitCallback() as cb: + with qtbot.wait_callback() as cb: web_tab.run_js_async('"{}";'.format(escaped), cb) cb.assert_called_with(text) diff --git a/tests/unit/utils/usertypes/test_question.py b/tests/unit/utils/usertypes/test_question.py index dbb34c47f..5e3731109 100644 --- a/tests/unit/utils/usertypes/test_question.py +++ b/tests/unit/utils/usertypes/test_question.py @@ -53,14 +53,14 @@ def test_done(mode, answer, signal_names, question, qtbot): question.mode = mode question.answer = answer signals = [getattr(question, name) for name in signal_names] - with qtbot.waitSignals(signals, order='strict'): + with qtbot.wait_signals(signals, order='strict'): question.done() assert not question.is_aborted def test_cancel(question, qtbot): """Test Question.cancel().""" - with qtbot.waitSignals([question.cancelled, question.completed], + with qtbot.wait_signals([question.cancelled, question.completed], order='strict'): question.cancel() assert not question.is_aborted @@ -68,7 +68,7 @@ def test_cancel(question, qtbot): def test_abort(question, qtbot): """Test Question.abort().""" - with qtbot.waitSignals([question.aborted, question.completed], + with qtbot.wait_signals([question.aborted, question.completed], order='strict'): question.abort() assert question.is_aborted diff --git a/tests/unit/utils/usertypes/test_timer.py b/tests/unit/utils/usertypes/test_timer.py index 37c56b653..4dc85b06f 100644 --- a/tests/unit/utils/usertypes/test_timer.py +++ b/tests/unit/utils/usertypes/test_timer.py @@ -70,13 +70,13 @@ def test_start_overflow(): def test_timeout_start(qtbot): """Make sure the timer works with start().""" t = usertypes.Timer() - with qtbot.waitSignal(t.timeout, timeout=3000): + with qtbot.wait_signal(t.timeout, timeout=3000): t.start(200) def test_timeout_set_interval(qtbot): """Make sure the timer works with setInterval().""" t = usertypes.Timer() - with qtbot.waitSignal(t.timeout, timeout=3000): + with qtbot.wait_signal(t.timeout, timeout=3000): t.setInterval(200) t.start() |