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
+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