Fix tests for variable change, and change monkeypatches to use the context manager

This commit is contained in:
Veronica K. B. Olsen
2021-02-18 19:21:46 +01:00
parent 8b0ac6e81e
commit e4d03f9581
28 changed files with 274 additions and 296 deletions
+3 -3
View File
@@ -534,9 +534,9 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
# Faulty Keyword Inserts
assert not nwGUI.docEditor.insertKeyWord("blabla")
monkeypatch.setattr(QTextBlock, "isValid", lambda *args, **kwards: False)
assert not nwGUI.docEditor.insertKeyWord(nwKeyWords.TAG_KEY)
monkeypatch.undo()
with monkeypatch.context() as mp:
mp.setattr(QTextBlock, "isValid", lambda *args, **kwards: False)
assert not nwGUI.docEditor.insertKeyWord(nwKeyWords.TAG_KEY)
nwGUI.docEditor.clear()
-1
View File
@@ -110,6 +110,5 @@ def testGuiProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
# Clean Up
projDet._doClose()
nwGUI.closeMain()
monkeypatch.undo()
# END Test testGuiProjDetails_Dialog
+9 -10
View File
@@ -62,18 +62,17 @@ def testGuiProjectWizard_Main(qtbot, monkeypatch, nwGUI, nwMinimal):
# Close project, but call with invalid path
assert nwGUI.closeProject()
monkeypatch.setattr(nwGUI, "showNewProjectDialog", lambda *args: None)
assert not nwGUI.newProject()
with monkeypatch.context() as mp:
mp.setattr(nwGUI, "showNewProjectDialog", lambda *args: None)
assert not nwGUI.newProject()
# Now, with an empty dictionary
monkeypatch.setattr(nwGUI, "showNewProjectDialog", lambda *args: {})
assert not nwGUI.newProject()
# Now, with an empty dictionary
mp.setattr(nwGUI, "showNewProjectDialog", lambda *args: {})
assert not nwGUI.newProject()
# Now, with a non-empty folder
monkeypatch.setattr(nwGUI, "showNewProjectDialog", lambda *args: {"projPath": nwMinimal})
assert not nwGUI.newProject()
monkeypatch.undo()
# Now, with a non-empty folder
mp.setattr(nwGUI, "showNewProjectDialog", lambda *args: {"projPath": nwMinimal})
assert not nwGUI.newProject()
##
# Test the Wizard
-2
View File
@@ -428,6 +428,4 @@ def testGuiWritingStats_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
assert nwGUI.closeProject()
qtbot.wait(stepDelay)
monkeypatch.undo()
# END Test testGuiWritingStats_Dialog