Fix tests of XML files and version number

This commit is contained in:
Veronica Berglyd Olsen
2022-11-10 18:26:08 +01:00
parent dbfda1e680
commit 402cb09bb6
+13 -13
View File
@@ -26,7 +26,7 @@ from shutil import copyfile
from datetime import datetime from datetime import datetime
from mock import causeOSError from mock import causeOSError
from tools import cmpFiles, writeFile from tools import XML_IGNORE, cmpFiles, writeFile
from novelwriter.core.item import NWItem from novelwriter.core.item import NWItem
from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState
@@ -203,7 +203,7 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
compFile = tstPaths.refDir / "projectXML_ReadCurrent.json" compFile = tstPaths.refDir / "projectXML_ReadCurrent.json"
with open(dumpFile, mode="w", encoding="utf-8") as dump: with open(dumpFile, mode="w", encoding="utf-8") as dump:
json.dump(content, dump, indent=2) json.dump(content, dump, indent=2)
assert cmpFiles(dumpFile, compFile) assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE)
packedContent = [] packedContent = []
mockProject = MockProject() mockProject = MockProject()
@@ -232,7 +232,7 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
assert xmlWriter.write(data, packedContent, timeStamp, 1000) is True assert xmlWriter.write(data, packedContent, timeStamp, 1000) is True
assert xmlWriter.write(data, packedContent, timeStamp, 1000) is True assert xmlWriter.write(data, packedContent, timeStamp, 1000) is True
copyfile(outFile, tstFile) copyfile(outFile, tstFile)
assert cmpFiles(tstFile, refFile) assert cmpFiles(tstFile, refFile, ignoreStart=XML_IGNORE)
# END Test testCoreProjectXML_ReadCurrent # END Test testCoreProjectXML_ReadCurrent
@@ -329,7 +329,7 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd):
compFile = tstPaths.refDir / "projectXML_ReadLegacy10.json" compFile = tstPaths.refDir / "projectXML_ReadLegacy10.json"
with open(dumpFile, mode="w", encoding="utf-8") as dump: with open(dumpFile, mode="w", encoding="utf-8") as dump:
json.dump(content, dump, indent=2) json.dump(content, dump, indent=2)
assert cmpFiles(dumpFile, compFile) assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE)
packedContent = [] packedContent = []
mockProject = MockProject() mockProject = MockProject()
@@ -374,7 +374,7 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd):
testFile = tstPaths.outDir / "projectXML_ReadLegacy10.nwx" testFile = tstPaths.outDir / "projectXML_ReadLegacy10.nwx"
compFile = tstPaths.refDir / "projectXML_ReadLegacy10.nwx" compFile = tstPaths.refDir / "projectXML_ReadLegacy10.nwx"
copyfile(outFile, testFile) copyfile(outFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
# END Test testCoreProjectXML_ReadLegacy10 # END Test testCoreProjectXML_ReadLegacy10
@@ -471,7 +471,7 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd):
compFile = tstPaths.refDir / "projectXML_ReadLegacy11.json" compFile = tstPaths.refDir / "projectXML_ReadLegacy11.json"
with open(dumpFile, mode="w", encoding="utf-8") as dump: with open(dumpFile, mode="w", encoding="utf-8") as dump:
json.dump(content, dump, indent=2) json.dump(content, dump, indent=2)
assert cmpFiles(dumpFile, compFile) assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE)
packedContent = [] packedContent = []
mockProject = MockProject() mockProject = MockProject()
@@ -516,7 +516,7 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd):
testFile = tstPaths.outDir / "projectXML_ReadLegacy11.nwx" testFile = tstPaths.outDir / "projectXML_ReadLegacy11.nwx"
compFile = tstPaths.refDir / "projectXML_ReadLegacy11.nwx" compFile = tstPaths.refDir / "projectXML_ReadLegacy11.nwx"
copyfile(outFile, testFile) copyfile(outFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
# END Test testCoreProjectXML_ReadLegacy11 # END Test testCoreProjectXML_ReadLegacy11
@@ -613,7 +613,7 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd):
compFile = tstPaths.refDir / "projectXML_ReadLegacy12.json" compFile = tstPaths.refDir / "projectXML_ReadLegacy12.json"
with open(dumpFile, mode="w", encoding="utf-8") as dump: with open(dumpFile, mode="w", encoding="utf-8") as dump:
json.dump(content, dump, indent=2) json.dump(content, dump, indent=2)
assert cmpFiles(dumpFile, compFile) assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE)
packedContent = [] packedContent = []
mockProject = MockProject() mockProject = MockProject()
@@ -661,7 +661,7 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd):
testFile = tstPaths.outDir / "projectXML_ReadLegacy12.nwx" testFile = tstPaths.outDir / "projectXML_ReadLegacy12.nwx"
compFile = tstPaths.refDir / "projectXML_ReadLegacy12.nwx" compFile = tstPaths.refDir / "projectXML_ReadLegacy12.nwx"
copyfile(outFile, testFile) copyfile(outFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
# END Test testCoreProjectXML_ReadLegacy12 # END Test testCoreProjectXML_ReadLegacy12
@@ -758,7 +758,7 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd):
compFile = tstPaths.refDir / "projectXML_ReadLegacy13.json" compFile = tstPaths.refDir / "projectXML_ReadLegacy13.json"
with open(dumpFile, mode="w", encoding="utf-8") as dump: with open(dumpFile, mode="w", encoding="utf-8") as dump:
json.dump(content, dump, indent=2) json.dump(content, dump, indent=2)
assert cmpFiles(dumpFile, compFile) assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE)
packedContent = [] packedContent = []
mockProject = MockProject() mockProject = MockProject()
@@ -806,7 +806,7 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd):
testFile = tstPaths.outDir / "projectXML_ReadLegacy13.nwx" testFile = tstPaths.outDir / "projectXML_ReadLegacy13.nwx"
compFile = tstPaths.refDir / "projectXML_ReadLegacy13.nwx" compFile = tstPaths.refDir / "projectXML_ReadLegacy13.nwx"
copyfile(outFile, testFile) copyfile(outFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
# END Test testCoreProjectXML_ReadLegacy13 # END Test testCoreProjectXML_ReadLegacy13
@@ -903,7 +903,7 @@ def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockRnd):
compFile = tstPaths.refDir / "projectXML_ReadLegacy14.json" compFile = tstPaths.refDir / "projectXML_ReadLegacy14.json"
with open(dumpFile, mode="w", encoding="utf-8") as dump: with open(dumpFile, mode="w", encoding="utf-8") as dump:
json.dump(content, dump, indent=2) json.dump(content, dump, indent=2)
assert cmpFiles(dumpFile, compFile) assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE)
packedContent = [] packedContent = []
mockProject = MockProject() mockProject = MockProject()
@@ -953,6 +953,6 @@ def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockRnd):
testFile = tstPaths.outDir / "projectXML_ReadLegacy14.nwx" testFile = tstPaths.outDir / "projectXML_ReadLegacy14.nwx"
compFile = tstPaths.refDir / "projectXML_ReadLegacy14.nwx" compFile = tstPaths.refDir / "projectXML_ReadLegacy14.nwx"
copyfile(outFile, testFile) copyfile(outFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
# END Test testCoreProjectXML_ReadLegacy14 # END Test testCoreProjectXML_ReadLegacy14