From 402cb09bb6ec24153513f30a8e7d953c0616afb9 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Thu, 10 Nov 2022 18:26:08 +0100 Subject: [PATCH] Fix tests of XML files and version number --- tests/test_core/test_core_projectxml.py | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/test_core/test_core_projectxml.py b/tests/test_core/test_core_projectxml.py index b9dce90c..a742b026 100644 --- a/tests/test_core/test_core_projectxml.py +++ b/tests/test_core/test_core_projectxml.py @@ -26,7 +26,7 @@ from shutil import copyfile from datetime import datetime 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.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState @@ -203,7 +203,7 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath): compFile = tstPaths.refDir / "projectXML_ReadCurrent.json" with open(dumpFile, mode="w", encoding="utf-8") as dump: json.dump(content, dump, indent=2) - assert cmpFiles(dumpFile, compFile) + assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE) packedContent = [] 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 copyfile(outFile, tstFile) - assert cmpFiles(tstFile, refFile) + assert cmpFiles(tstFile, refFile, ignoreStart=XML_IGNORE) # END Test testCoreProjectXML_ReadCurrent @@ -329,7 +329,7 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd): compFile = tstPaths.refDir / "projectXML_ReadLegacy10.json" with open(dumpFile, mode="w", encoding="utf-8") as dump: json.dump(content, dump, indent=2) - assert cmpFiles(dumpFile, compFile) + assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE) packedContent = [] mockProject = MockProject() @@ -374,7 +374,7 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd): testFile = tstPaths.outDir / "projectXML_ReadLegacy10.nwx" compFile = tstPaths.refDir / "projectXML_ReadLegacy10.nwx" copyfile(outFile, testFile) - assert cmpFiles(testFile, compFile) + assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) # END Test testCoreProjectXML_ReadLegacy10 @@ -471,7 +471,7 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd): compFile = tstPaths.refDir / "projectXML_ReadLegacy11.json" with open(dumpFile, mode="w", encoding="utf-8") as dump: json.dump(content, dump, indent=2) - assert cmpFiles(dumpFile, compFile) + assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE) packedContent = [] mockProject = MockProject() @@ -516,7 +516,7 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd): testFile = tstPaths.outDir / "projectXML_ReadLegacy11.nwx" compFile = tstPaths.refDir / "projectXML_ReadLegacy11.nwx" copyfile(outFile, testFile) - assert cmpFiles(testFile, compFile) + assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) # END Test testCoreProjectXML_ReadLegacy11 @@ -613,7 +613,7 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd): compFile = tstPaths.refDir / "projectXML_ReadLegacy12.json" with open(dumpFile, mode="w", encoding="utf-8") as dump: json.dump(content, dump, indent=2) - assert cmpFiles(dumpFile, compFile) + assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE) packedContent = [] mockProject = MockProject() @@ -661,7 +661,7 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd): testFile = tstPaths.outDir / "projectXML_ReadLegacy12.nwx" compFile = tstPaths.refDir / "projectXML_ReadLegacy12.nwx" copyfile(outFile, testFile) - assert cmpFiles(testFile, compFile) + assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) # END Test testCoreProjectXML_ReadLegacy12 @@ -758,7 +758,7 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd): compFile = tstPaths.refDir / "projectXML_ReadLegacy13.json" with open(dumpFile, mode="w", encoding="utf-8") as dump: json.dump(content, dump, indent=2) - assert cmpFiles(dumpFile, compFile) + assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE) packedContent = [] mockProject = MockProject() @@ -806,7 +806,7 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd): testFile = tstPaths.outDir / "projectXML_ReadLegacy13.nwx" compFile = tstPaths.refDir / "projectXML_ReadLegacy13.nwx" copyfile(outFile, testFile) - assert cmpFiles(testFile, compFile) + assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) # END Test testCoreProjectXML_ReadLegacy13 @@ -903,7 +903,7 @@ def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockRnd): compFile = tstPaths.refDir / "projectXML_ReadLegacy14.json" with open(dumpFile, mode="w", encoding="utf-8") as dump: json.dump(content, dump, indent=2) - assert cmpFiles(dumpFile, compFile) + assert cmpFiles(dumpFile, compFile, ignoreStart=XML_IGNORE) packedContent = [] mockProject = MockProject() @@ -953,6 +953,6 @@ def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockRnd): testFile = tstPaths.outDir / "projectXML_ReadLegacy14.nwx" compFile = tstPaths.refDir / "projectXML_ReadLegacy14.nwx" copyfile(outFile, testFile) - assert cmpFiles(testFile, compFile) + assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) # END Test testCoreProjectXML_ReadLegacy14