From d86b09129732e8f2f4c4b8970e65fb60e7d6fcde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20L=C3=B6hning?= Date: Fri, 28 Apr 2023 17:29:34 +0200 Subject: SquishTests: Further Python3 adaption Fixing tests in suite_editors Change-Id: I4e5e1adc2c4e6606232d76a794aff7a7144d5c9e Reviewed-by: Christian Stenger --- tests/system/shared/project.py | 1 + tests/system/shared/utils.py | 9 +++++++-- tests/system/suite_editors/tst_clean_whitespaces/test.py | 2 +- tests/system/suite_editors/tst_select_all/test.py | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py index 06c7e115e3..babbf0eb6e 100644 --- a/tests/system/shared/project.py +++ b/tests/system/shared/project.py @@ -544,6 +544,7 @@ def checkAndCopyFiles(dataSet, fieldName, templateDir): files = map(lambda record: os.path.normpath(os.path.join(srcPath, testData.field(record, fieldName))), dataSet) + files = list(files) # copy data from map object to list to make it reusable for currentFile in files: if not neededFilePresent(currentFile): return [] diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index 7397fad5ed..96e63f29f0 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -513,8 +513,13 @@ def progressBarWait(timeout=60000, warn=True): checkIfObjectExists(":Qt Creator_Core::Internal::ProgressBar", False, timeout) def readFile(filename): - with open(filename, "r") as f: - return f.read() + try: + with open(filename, "r") as f: + return f.read() + except: + # Read file as binary + with open(filename, "rb") as f: + return f.read() def simpleFileName(navigatorFileName): # try to find the last part of the given name, assume it's inside a (folder) structure diff --git a/tests/system/suite_editors/tst_clean_whitespaces/test.py b/tests/system/suite_editors/tst_clean_whitespaces/test.py index cdf2add27c..6dab4720f9 100644 --- a/tests/system/suite_editors/tst_clean_whitespaces/test.py +++ b/tests/system/suite_editors/tst_clean_whitespaces/test.py @@ -12,7 +12,7 @@ TripleTab = '\t\t\t' def main(): files = map(lambda record: os.path.join(srcPath, testData.field(record, "filename")), testData.dataset("files.tsv")) - files = filter(lambda x: not x.endswith(".bin"), files) + files = list(filter(lambda x: not x.endswith(".bin"), files)) for currentFile in files: if not neededFilePresent(currentFile): return diff --git a/tests/system/suite_editors/tst_select_all/test.py b/tests/system/suite_editors/tst_select_all/test.py index be96e8f482..bf95250cf7 100644 --- a/tests/system/suite_editors/tst_select_all/test.py +++ b/tests/system/suite_editors/tst_select_all/test.py @@ -8,7 +8,7 @@ source("../../shared/qtcreator.py") def main(): files = map(lambda record: os.path.join(srcPath, testData.field(record, "filename")), testData.dataset("files.tsv")) - files = filter(lambda x: not x.endswith(".bin"), files) + files = list(filter(lambda x: not x.endswith(".bin"), files)) for currentFile in files: if not neededFilePresent(currentFile): return -- cgit v1.2.1