Fix ignored lines in XML comparison
This commit is contained in:
@@ -26,7 +26,7 @@ from shutil import copyfile
|
|||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
from tools import cmpFiles, writeFile, readFile, buildTestProject
|
from tools import cmpFiles, writeFile, readFile, buildTestProject, XML_IGNORE
|
||||||
from mock import causeOSError
|
from mock import causeOSError
|
||||||
|
|
||||||
from novelwriter.core.project import NWProject
|
from novelwriter.core.project import NWProject
|
||||||
@@ -67,7 +67,7 @@ def testCoreProject_NewMinimal(fncDir, outDir, refDir, mockGUI, mockRnd):
|
|||||||
assert theProject.saveProject() is True
|
assert theProject.saveProject() is True
|
||||||
assert theProject.closeProject() is True
|
assert theProject.closeProject() is True
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
|
||||||
assert theProject.projChanged is False
|
assert theProject.projChanged is False
|
||||||
|
|
||||||
# Open a second time
|
# Open a second time
|
||||||
@@ -77,7 +77,7 @@ def testCoreProject_NewMinimal(fncDir, outDir, refDir, mockGUI, mockRnd):
|
|||||||
assert theProject.saveProject() is True
|
assert theProject.saveProject() is True
|
||||||
assert theProject.closeProject() is True
|
assert theProject.closeProject() is True
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
|
||||||
|
|
||||||
# END Test testCoreProject_NewMinimal
|
# END Test testCoreProject_NewMinimal
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ def testCoreProject_NewCustomA(fncDir, outDir, refDir, mockGUI, mockRnd):
|
|||||||
assert theProject.closeProject() is True
|
assert theProject.closeProject() is True
|
||||||
|
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
|
||||||
|
|
||||||
# END Test testCoreProject_NewCustomA
|
# END Test testCoreProject_NewCustomA
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ def testCoreProject_NewCustomB(fncDir, outDir, refDir, mockGUI, mockRnd):
|
|||||||
assert theProject.closeProject() is True
|
assert theProject.closeProject() is True
|
||||||
|
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
|
||||||
|
|
||||||
# END Test testCoreProject_NewCustomB
|
# END Test testCoreProject_NewCustomB
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ def testCoreProject_NewRoot(fncDir, outDir, refDir, mockGUI, mockRnd):
|
|||||||
assert theProject.closeProject() is True
|
assert theProject.closeProject() is True
|
||||||
|
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
|
||||||
assert theProject.projChanged is False
|
assert theProject.projChanged is False
|
||||||
|
|
||||||
# END Test testCoreProject_NewRoot
|
# END Test testCoreProject_NewRoot
|
||||||
@@ -302,7 +302,7 @@ def testCoreProject_NewFile(fncDir, outDir, refDir, mockGUI, mockRnd):
|
|||||||
assert theProject.closeProject() is True
|
assert theProject.closeProject() is True
|
||||||
|
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
|
||||||
assert theProject.projChanged is False
|
assert theProject.projChanged is False
|
||||||
|
|
||||||
# END Test testCoreProject_NewFile
|
# END Test testCoreProject_NewFile
|
||||||
@@ -483,7 +483,7 @@ def testCoreProject_Save(monkeypatch, nwMinimal, mockGUI, refDir):
|
|||||||
assert theProject.saveProject() is True
|
assert theProject.saveProject() is True
|
||||||
assert theProject.saveCount == saveCount + 1
|
assert theProject.saveCount == saveCount + 1
|
||||||
assert theProject.autoCount == autoCount
|
assert theProject.autoCount == autoCount
|
||||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8, 9])
|
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
|
||||||
|
|
||||||
# Check that a second save creates a .bak file
|
# Check that a second save creates a .bak file
|
||||||
assert os.path.isfile(backFile) is True
|
assert os.path.isfile(backFile) is True
|
||||||
@@ -494,7 +494,7 @@ def testCoreProject_Save(monkeypatch, nwMinimal, mockGUI, refDir):
|
|||||||
assert theProject.saveProject(autoSave=True) is True
|
assert theProject.saveProject(autoSave=True) is True
|
||||||
assert theProject.saveCount == saveCount
|
assert theProject.saveCount == saveCount
|
||||||
assert theProject.autoCount == autoCount + 1
|
assert theProject.autoCount == autoCount + 1
|
||||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8, 9])
|
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
|
||||||
|
|
||||||
# Close test project
|
# Close test project
|
||||||
assert theProject.closeProject()
|
assert theProject.closeProject()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import os
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from tools import cmpFiles, buildTestProject
|
from tools import cmpFiles, buildTestProject, XML_IGNORE
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import QMessageBox, QDialog
|
from PyQt5.QtWidgets import QMessageBox, QDialog
|
||||||
@@ -158,7 +158,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
|
|||||||
testFile = os.path.join(outDir, "guiEditor_Main_Initial_nwProject.nwx")
|
testFile = os.path.join(outDir, "guiEditor_Main_Initial_nwProject.nwx")
|
||||||
compFile = os.path.join(refDir, "guiEditor_Main_Initial_nwProject.nwx")
|
compFile = os.path.join(refDir, "guiEditor_Main_Initial_nwProject.nwx")
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
|
|
||||||
# qtbot.stopForInteraction()
|
# qtbot.stopForInteraction()
|
||||||
@@ -436,7 +436,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
|
|||||||
testFile = os.path.join(outDir, "guiEditor_Main_Final_nwProject.nwx")
|
testFile = os.path.join(outDir, "guiEditor_Main_Final_nwProject.nwx")
|
||||||
compFile = os.path.join(refDir, "guiEditor_Main_Final_nwProject.nwx")
|
compFile = os.path.join(refDir, "guiEditor_Main_Final_nwProject.nwx")
|
||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, compFile, [2, 6, 7, 8])
|
assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE)
|
||||||
|
|
||||||
projFile = os.path.join(fncProj, "content", "000000000000f.nwd")
|
projFile = os.path.join(fncProj, "content", "000000000000f.nwd")
|
||||||
testFile = os.path.join(outDir, "guiEditor_Main_Final_000000000000f.nwd")
|
testFile = os.path.join(outDir, "guiEditor_Main_Final_000000000000f.nwd")
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import shutil
|
|||||||
|
|
||||||
from PyQt5.QtWidgets import qApp
|
from PyQt5.QtWidgets import qApp
|
||||||
|
|
||||||
|
XML_IGNORE = ("<novelWriterXML", "<saveCount", "<autoCount", "<editTime")
|
||||||
|
|
||||||
|
|
||||||
def cmpFiles(fileOne, fileTwo, ignoreLines=None, ignoreStart=None):
|
def cmpFiles(fileOne, fileTwo, ignoreLines=None, ignoreStart=None):
|
||||||
"""Compare two files, but optionally ignore lines given by a list.
|
"""Compare two files, but optionally ignore lines given by a list.
|
||||||
|
|||||||
Reference in New Issue
Block a user