Updated tests for NWSpell* classes

This commit is contained in:
Veronica K. B. Olsen
2020-12-03 18:37:52 +01:00
parent c13bd18271
commit c7c70a35a0
7 changed files with 219 additions and 33 deletions
+4 -5
View File
@@ -5,6 +5,8 @@
import os
import pytest
from dummy import causeOSError
from nw.core import NWProject, NWDoc
from nw.core.item import NWItem
from nw.constants import nwItemClass, nwItemLayout
@@ -75,10 +77,7 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal):
assert inFile.read() == theText
# Cause open() to fail while saving
def dummyIO(*args, **kwargs):
raise OSError
monkeypatch.setattr("builtins.open", dummyIO)
monkeypatch.setattr("builtins.open", causeOSError)
assert not theDoc.saveDocument(theText)
monkeypatch.undo()
@@ -91,7 +90,7 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal):
assert os.path.isfile(docPath)
# Cause the delete to fail
monkeypatch.setattr("os.unlink", dummyIO)
monkeypatch.setattr("os.unlink", causeOSError)
assert not theDoc.deleteDocument(xHandle)
monkeypatch.undo()