diff --git a/external_tester/testutils.py b/external_tester/testutils.py index 4bd85c4c..9076a7d6 100644 --- a/external_tester/testutils.py +++ b/external_tester/testutils.py @@ -70,19 +70,23 @@ def compareCSV(expected, actual): else: print(f"ERROR: {expected} doest not exist!") return False - -def comparText(file1, file2): + +def compareTexts(expectedText, actualText): + remove = str.maketrans('', '', string.whitespace) + expectedText = expectedText.translate(remove) + actualLines = actualText.translate(remove) + return expectedText == actualLines + +def compareFiles(file1, file2): expectedFile = open(file1, 'r') actualFile = open(file2, 'r') - remove = str.maketrans('', '', string.whitespace) expectedLines = expectedFile.readlines() actualLines = actualFile.readlines() - expectedLines = "".join(expectedLines).translate(remove) - actualLines = "".join(actualLines).translate(remove) + expectedLines = "".join(expectedLines) + actualLines = "".join(actualLines) expectedFile.close() actualFile.close() - - return expectedLines == actualLines + return compareTexts(expectedLines, actualLines) def compare(strPrefix, expected, actual): if os.path.exists(expected): @@ -90,7 +94,7 @@ def compare(strPrefix, expected, actual): compareResult = filecmp.cmp(expected, actual) if not compareResult: - compareRes = comparText(expected, actual) + compareRes = compareFiles(expected, actual) if not compareRes: print("ERROR: {}: Files {} and {} do not match".format(strPrefix, expected, actual)) return False diff --git a/external_tester/webapi_test.py b/external_tester/webapi_test.py index ecae3c1a..b5c4c277 100644 --- a/external_tester/webapi_test.py +++ b/external_tester/webapi_test.py @@ -198,7 +198,7 @@ def testScenarioController(basicUrl): expectedMasterModel = bytes(expectedMasterModel, "utf-8").decode("unicode_escape") - if(not testutils.compare("Generate from scenario", expectedMasterModel, actualMasterModel)): + if(not testutils.compareTexts(expectedMasterModel, actualMasterModel)): print("ERROR: actual and expected master model do not match") print("Actual:") print(json.dumps(actualMasterModel, indent=2)) diff --git a/pom.xml b/pom.xml index 46db6e9f..5d26b4ba 100644 --- a/pom.xml +++ b/pom.xml @@ -279,7 +279,7 @@ maven-surefire-plugin - 3.0.0-M5 + 3.2.3 true @@ -354,7 +354,7 @@ org.apache.maven.plugins maven-surefire-report-plugin - 3.0.0-M5 + 3.2.3