Improve the test file compare function

This commit is contained in:
Veronica Berglyd Olsen
2024-02-15 21:46:35 +01:00
parent 76864f2a2f
commit 2e55d28a10
+4 -8
View File
@@ -70,20 +70,19 @@ def cmpFiles(
ignoreLines = []
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:
print(str(exc))
return False
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:
print(str(exc))
return False
txtOne = foOne.readlines()
txtTwo = foTwo.readlines()
if len(txtOne) != len(txtTwo):
print("Files are not the same length")
return False
@@ -108,9 +107,6 @@ def cmpFiles(
print(" >> '%s'" % lnTwo)
diffFound = True
foOne.close()
foTwo.close()
return not diffFound