From 5b8cd6ef1d09fdca2566855aa695fac821d0a17f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20V=C3=A5gsether?= Date: Thu, 9 May 2024 12:18:16 +0200 Subject: [PATCH] grc-qt: (test_qtbot) Update monkeypatch for save dialogs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Vågsether --- tests/test_qtbot.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/test_qtbot.py b/tests/test_qtbot.py index 3d002d0..9b3d61d 100644 --- a/tests/test_qtbot.py +++ b/tests/test_qtbot.py @@ -612,7 +612,10 @@ def test_bypass(qtbot, qapp_cls_): def test_file_save(qtbot, qapp_cls_, monkeypatch, tmp_path): fg_path = tmp_path / "test_save.grc" monkeypatch.setattr( - QtWidgets.QFileDialog, "getSaveFileName", lambda *args, **kargs: (fg_path, "") + QtWidgets.QFileDialog, "selectedFiles", lambda *args, **kargs: (fg_path, "") + ) + monkeypatch.setattr( + QtWidgets.QFileDialog, "exec_", lambda *args: QtWidgets.QFileDialog.Accepted ) assert not fg_path.exists(), "File/Save (setup): File already exists" @@ -623,7 +626,10 @@ def test_file_save(qtbot, qapp_cls_, monkeypatch, tmp_path): def test_file_save_as(qtbot, qapp_cls_, monkeypatch, tmp_path): fg_path = tmp_path / "test.grc" monkeypatch.setattr( - QtWidgets.QFileDialog, "getSaveFileName", lambda *args, **kargs: (fg_path, "") + QtWidgets.QFileDialog, "selectedFiles", lambda *args, **kargs: (fg_path, "") + ) + monkeypatch.setattr( + QtWidgets.QFileDialog, "exec_", lambda *args: QtWidgets.QFileDialog.Accepted ) qtbot.wait(100) @@ -635,7 +641,10 @@ def test_file_save_as(qtbot, qapp_cls_, monkeypatch, tmp_path): def test_file_save_copy(qtbot, qapp_cls_, monkeypatch, tmp_path): fg_path = tmp_path / "test_copy.grc" monkeypatch.setattr( - QtWidgets.QFileDialog, "getSaveFileName", lambda *args, **kargs: (fg_path, "") + QtWidgets.QFileDialog, "selectedFiles", lambda *args, **kargs: (fg_path, "") + ) + monkeypatch.setattr( + QtWidgets.QFileDialog, "exec_", lambda *args: QtWidgets.QFileDialog.Accepted ) qtbot.wait(100) @@ -860,7 +869,10 @@ def test_generate(qtbot, qapp_cls_, monkeypatch, tmp_path): fg_path = tmp_path / "test_generate.grc" py_path = tmp_path / "default.py" monkeypatch.setattr( - QtWidgets.QFileDialog, "getSaveFileName", lambda *args, **kargs: (fg_path, "") + QtWidgets.QFileDialog, "selectedFiles", lambda *args, **kargs: (fg_path, "") + ) + monkeypatch.setattr( + QtWidgets.QFileDialog, "exec_", lambda *args: QtWidgets.QFileDialog.Accepted ) qtbot.wait(100)