Added test framwork and two simple tests for the config class
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""novelWriter Test Tools
|
||||
"""
|
||||
|
||||
def cmpFiles(fileOne, fileTwo, ignoreLines=[]):
|
||||
foOne = open(fileOne,mode="r")
|
||||
foTwo = open(fileTwo,mode="r")
|
||||
|
||||
txtOne = foOne.readlines()
|
||||
txtTwo = foTwo.readlines()
|
||||
|
||||
if len(txtOne) != len(txtTwo):
|
||||
print("Files are not the same length")
|
||||
return False
|
||||
|
||||
diffFound = False
|
||||
for n in range(len(txtOne)):
|
||||
lnOne = txtOne[n].strip()
|
||||
lnTwo = txtTwo[n].strip()
|
||||
|
||||
if n+1 in ignoreLines:
|
||||
print("Ignoring line %d" % (n+1))
|
||||
continue
|
||||
|
||||
if lnOne != lnTwo:
|
||||
print("Diff on line %d:" % (n+1))
|
||||
print(" << '%s'" % lnOne)
|
||||
print(" >> '%s'" % lnTwo)
|
||||
diffFound = True
|
||||
|
||||
foOne.close()
|
||||
foTwo.close()
|
||||
|
||||
return not diffFound
|
||||
Reference in New Issue
Block a user