From 2cb772847e26673b8a3062e985078edc05c6bf6f Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 13 Jan 2024 18:29:06 +0100 Subject: [PATCH] Update tests --- tests/reference/baseConfig_novelwriter.conf | 1 - tests/test_dialogs/test_dlg_dialogs.py | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/reference/baseConfig_novelwriter.conf b/tests/reference/baseConfig_novelwriter.conf index 6f064701..32a9883e 100644 --- a/tests/reference/baseConfig_novelwriter.conf +++ b/tests/reference/baseConfig_novelwriter.conf @@ -57,7 +57,6 @@ spellcheck = en showtabsnspaces = False showlineendings = False showmultispaces = True -wordcounttimer = 5.0 incnoteswcount = True showfullpath = True highlightquotes = True diff --git a/tests/test_dialogs/test_dlg_dialogs.py b/tests/test_dialogs/test_dlg_dialogs.py index 0aa43e39..94d488ed 100644 --- a/tests/test_dialogs/test_dlg_dialogs.py +++ b/tests/test_dialogs/test_dlg_dialogs.py @@ -31,8 +31,10 @@ from novelwriter.dialogs.editlabel import GuiEditLabel @pytest.mark.gui -def testDlgOther_QuoteSelect(qtbot, nwGUI): +def testDlgOther_QuoteSelect(qtbot, monkeypatch, nwGUI): """Test the quote symbols dialog.""" + monkeypatch.setattr(GuiQuoteSelect, "exec_", lambda *a: None) + nwQuot = GuiQuoteSelect(nwGUI) nwQuot.show() @@ -41,16 +43,25 @@ def testDlgOther_QuoteSelect(qtbot, nwGUI): anItem = nwQuot.listBox.item(i) assert isinstance(anItem, QListWidgetItem) nwQuot.listBox.clearSelection() - nwQuot.listBox.setCurrentItem(anItem, QItemSelectionModel.Select) + nwQuot.listBox.setCurrentItem(anItem, QItemSelectionModel.SelectionFlag.Select) lastItem = anItem.text()[2] assert nwQuot.previewLabel.text() == lastItem nwQuot.accept() assert nwQuot.result() == QDialog.Accepted assert nwQuot.selectedQuote == lastItem + nwQuot.close() + + # Test Class Method + with monkeypatch.context() as mp: + mp.setattr(GuiQuoteSelect, "result", lambda *a: QDialog.DialogCode.Accepted) + assert GuiQuoteSelect.getQuote(nwGUI, current="X") == ("X", True) + + with monkeypatch.context() as mp: + mp.setattr(GuiQuoteSelect, "result", lambda *a: QDialog.DialogCode.Rejected) + assert GuiQuoteSelect.getQuote(nwGUI, current="X") == ("X", False) # qtbot.stop() - nwQuot.close() # END Test testDlgOther_QuoteSelect