Skip to content

Commit

Permalink
Updated logging lines
Browse files Browse the repository at this point in the history
Update testutil code
  • Loading branch information
SimplisticCode committed Dec 14, 2023
1 parent 4e37af2 commit d5387e8
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions external_tester/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,34 @@ def compareCSV(expected, actual):
print(f"ERROR: {expected} doest not exist!")
return False

def comparText(s1, s2):
def comparText(file1, file):
expectedFile = open(file1, 'r')
actualFile = open(file, 'r')

expectedLines = expectedFile.readlines()
actualLines = actualFile.readlines()
print("Expected lines:" + str(expectedLines))
print("Actual lines:" + str(actualLines))

expectedFile.close()
actualFile.close()

remove = string.whitespace
return s1.translate(None, remove) == s2.translate(None, remove)
return expectedLines.translate(None, remove) == actualLines.translate(None, remove)

def compare(strPrefix, expected, actual):
if os.path.exists(expected):
convert(expected)
expectedFile = open(expected, 'r')
actualFile = open(actual, 'r')

expectedLines = expectedFile.readlines()
actualLines = actualFile.readlines()

compareRes = comparText(expectedLines, actualLines)
if compareRes:
print("%s: Files match" % strPrefix)
return True

expectedFile.close()
actualFile.close()

compareResult = filecmp.cmp(expected, actual)
if not compareResult:
print("ERROR: {}: Files {} and {} do not match".format(strPrefix, expected, actual))
print("Diff:" + str(filecmp.cmp(expected, actual, shallow=False)))
return False
compareRes = comparText(expected, actual)
if not compareRes:
print("ERROR: {}: Files {} and {} do not match".format(strPrefix, expected, actual))
return False
else:
print("%s: Files match" % strPrefix)
return True
else:
print("%s: Files match" % strPrefix)
return True
Expand Down

0 comments on commit d5387e8

Please sign in to comment.