Add closeEvents to dialogs and set the deleteLater command
This commit is contained in:
@@ -56,14 +56,7 @@ def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
|
||||
|
||||
msgAbout.showReleaseNotes()
|
||||
assert msgAbout.tabBox.currentWidget() == msgAbout.pageNotes
|
||||
msgAbout._doClose()
|
||||
|
||||
# Open Again from Menu
|
||||
nwGUI.mainMenu.aAboutNW.activate(QAction.Trigger)
|
||||
qtbot.waitUntil(lambda: getGuiItem("GuiAbout") is not None, timeout=1000)
|
||||
msgAbout = getGuiItem("GuiAbout")
|
||||
assert msgAbout is not None
|
||||
msgAbout._doClose()
|
||||
msgAbout.close()
|
||||
|
||||
# END Test testDlgAbout_NWDialog
|
||||
|
||||
|
||||
@@ -45,12 +45,11 @@ def testDlgOther_QuoteSelect(qtbot, nwGUI):
|
||||
lastItem = anItem.text()[2]
|
||||
assert nwQuot.previewLabel.text() == lastItem
|
||||
|
||||
nwQuot._doAccept()
|
||||
nwQuot.accept()
|
||||
assert nwQuot.result() == QDialog.Accepted
|
||||
assert nwQuot.selectedQuote == lastItem
|
||||
|
||||
# qtbot.stop()
|
||||
nwQuot._doReject()
|
||||
nwQuot.close()
|
||||
|
||||
# END Test testDlgOther_QuoteSelect
|
||||
@@ -89,7 +88,7 @@ def testDlgOther_Updates(qtbot, monkeypatch, nwGUI):
|
||||
nwGUI.mainMenu.aUpdates.activate(QAction.Trigger)
|
||||
|
||||
# qtbot.stop()
|
||||
nwUpdate._doClose()
|
||||
nwUpdate.close()
|
||||
|
||||
# END Test testDlgOther_Updates
|
||||
|
||||
@@ -101,13 +100,13 @@ def testDlgOther_EditLabel(qtbot, monkeypatch):
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.Accepted)
|
||||
newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World")
|
||||
newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World") # type: ignore
|
||||
assert dlgOk is True
|
||||
assert newLabel == "Hello World"
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.Rejected)
|
||||
newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World")
|
||||
newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World") # type: ignore
|
||||
assert dlgOk is False
|
||||
assert newLabel == "Hello World"
|
||||
|
||||
|
||||
@@ -68,11 +68,11 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, projPath):
|
||||
wList._loadWordList()
|
||||
|
||||
# Check that the content was loaded
|
||||
assert wList.listBox.item(0).text() == "word_a"
|
||||
assert wList.listBox.item(1).text() == "word_b"
|
||||
assert wList.listBox.item(2).text() == "word_c"
|
||||
assert wList.listBox.item(3).text() == "word_f"
|
||||
assert wList.listBox.item(4).text() == "word_g"
|
||||
assert wList.listBox.item(0).text() == "word_a" # type: ignore
|
||||
assert wList.listBox.item(1).text() == "word_b" # type: ignore
|
||||
assert wList.listBox.item(2).text() == "word_c" # type: ignore
|
||||
assert wList.listBox.item(3).text() == "word_f" # type: ignore
|
||||
assert wList.listBox.item(4).text() == "word_g" # type: ignore
|
||||
assert wList.listBox.count() == 5
|
||||
|
||||
# Add a blank word, which is ignored
|
||||
@@ -91,24 +91,24 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, projPath):
|
||||
assert wList.listBox.count() == 6
|
||||
|
||||
# Check that the content now
|
||||
assert wList.listBox.item(0).text() == "word_a"
|
||||
assert wList.listBox.item(1).text() == "word_b"
|
||||
assert wList.listBox.item(2).text() == "word_c"
|
||||
assert wList.listBox.item(3).text() == "word_d"
|
||||
assert wList.listBox.item(4).text() == "word_f"
|
||||
assert wList.listBox.item(5).text() == "word_g"
|
||||
assert wList.listBox.item(0).text() == "word_a" # type: ignore
|
||||
assert wList.listBox.item(1).text() == "word_b" # type: ignore
|
||||
assert wList.listBox.item(2).text() == "word_c" # type: ignore
|
||||
assert wList.listBox.item(3).text() == "word_d" # type: ignore
|
||||
assert wList.listBox.item(4).text() == "word_f" # type: ignore
|
||||
assert wList.listBox.item(5).text() == "word_g" # type: ignore
|
||||
|
||||
# Delete a word
|
||||
wList.newEntry.setText("delete_me")
|
||||
wList._doAdd()
|
||||
assert wList.listBox.item(0).text() == "delete_me"
|
||||
assert wList.listBox.item(0).text() == "delete_me" # type: ignore
|
||||
|
||||
delItem = wList.listBox.findItems("delete_me", Qt.MatchExactly)[0]
|
||||
assert delItem.text() == "delete_me"
|
||||
delItem.setSelected(True)
|
||||
wList._doDelete()
|
||||
assert wList.listBox.findItems("delete_me", Qt.MatchExactly) == []
|
||||
assert wList.listBox.item(0).text() == "word_a"
|
||||
assert wList.listBox.item(0).text() == "word_a" # type: ignore
|
||||
|
||||
# Save files
|
||||
wList._doSave()
|
||||
@@ -122,6 +122,6 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, projPath):
|
||||
assert "word_g" in userDict
|
||||
|
||||
# qtbot.stop()
|
||||
wList._doClose()
|
||||
wList.close()
|
||||
|
||||
# END Test testDlgWordList_Dialog
|
||||
|
||||
Reference in New Issue
Block a user