diff --git a/tests/tools.py b/tests/tools.py index 6346432b..835a61f5 100644 --- a/tests/tools.py +++ b/tests/tools.py @@ -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