Improve the test file compare function
This commit is contained in:
+4
-8
@@ -70,20 +70,19 @@ def cmpFiles(
|
|||||||
ignoreLines = []
|
ignoreLines = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
foOne = open(fileOne, mode="r", encoding="utf-8")
|
with open(fileOne, mode="r", encoding="utf-8") as fo:
|
||||||
|
txtOne = fo.read().strip().splitlines()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print(str(exc))
|
print(str(exc))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
foTwo = open(fileTwo, mode="r", encoding="utf-8")
|
with open(fileTwo, mode="r", encoding="utf-8") as fo:
|
||||||
|
txtTwo = fo.read().strip().splitlines()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print(str(exc))
|
print(str(exc))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
txtOne = foOne.readlines()
|
|
||||||
txtTwo = foTwo.readlines()
|
|
||||||
|
|
||||||
if len(txtOne) != len(txtTwo):
|
if len(txtOne) != len(txtTwo):
|
||||||
print("Files are not the same length")
|
print("Files are not the same length")
|
||||||
return False
|
return False
|
||||||
@@ -108,9 +107,6 @@ def cmpFiles(
|
|||||||
print(" >> '%s'" % lnTwo)
|
print(" >> '%s'" % lnTwo)
|
||||||
diffFound = True
|
diffFound = True
|
||||||
|
|
||||||
foOne.close()
|
|
||||||
foTwo.close()
|
|
||||||
|
|
||||||
return not diffFound
|
return not diffFound
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user