Update tests
This commit is contained in:
@@ -57,7 +57,6 @@ spellcheck = en
|
|||||||
showtabsnspaces = False
|
showtabsnspaces = False
|
||||||
showlineendings = False
|
showlineendings = False
|
||||||
showmultispaces = True
|
showmultispaces = True
|
||||||
wordcounttimer = 5.0
|
|
||||||
incnoteswcount = True
|
incnoteswcount = True
|
||||||
showfullpath = True
|
showfullpath = True
|
||||||
highlightquotes = True
|
highlightquotes = True
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testDlgOther_QuoteSelect(qtbot, nwGUI):
|
def testDlgOther_QuoteSelect(qtbot, monkeypatch, nwGUI):
|
||||||
"""Test the quote symbols dialog."""
|
"""Test the quote symbols dialog."""
|
||||||
|
monkeypatch.setattr(GuiQuoteSelect, "exec_", lambda *a: None)
|
||||||
|
|
||||||
nwQuot = GuiQuoteSelect(nwGUI)
|
nwQuot = GuiQuoteSelect(nwGUI)
|
||||||
nwQuot.show()
|
nwQuot.show()
|
||||||
|
|
||||||
@@ -41,16 +43,25 @@ def testDlgOther_QuoteSelect(qtbot, nwGUI):
|
|||||||
anItem = nwQuot.listBox.item(i)
|
anItem = nwQuot.listBox.item(i)
|
||||||
assert isinstance(anItem, QListWidgetItem)
|
assert isinstance(anItem, QListWidgetItem)
|
||||||
nwQuot.listBox.clearSelection()
|
nwQuot.listBox.clearSelection()
|
||||||
nwQuot.listBox.setCurrentItem(anItem, QItemSelectionModel.Select)
|
nwQuot.listBox.setCurrentItem(anItem, QItemSelectionModel.SelectionFlag.Select)
|
||||||
lastItem = anItem.text()[2]
|
lastItem = anItem.text()[2]
|
||||||
assert nwQuot.previewLabel.text() == lastItem
|
assert nwQuot.previewLabel.text() == lastItem
|
||||||
|
|
||||||
nwQuot.accept()
|
nwQuot.accept()
|
||||||
assert nwQuot.result() == QDialog.Accepted
|
assert nwQuot.result() == QDialog.Accepted
|
||||||
assert nwQuot.selectedQuote == lastItem
|
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()
|
# qtbot.stop()
|
||||||
nwQuot.close()
|
|
||||||
|
|
||||||
# END Test testDlgOther_QuoteSelect
|
# END Test testDlgOther_QuoteSelect
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user