From 0b241f42f186e13b70550c070d3d271c1eb9e989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20L=C3=B6hning?= Date: Mon, 8 May 2023 18:12:33 +0200 Subject: SquishTests: Make suite_tools Python3 compatible Except for tst_designer_edit which needs a bigger update. Change-Id: I8300a9491ec34b4d8deeed39f02fc59281cc20c9 Reviewed-by: Reviewed-by: Christian Stenger --- tests/system/suite_tools/tst_codepasting/test.py | 14 ++++++++------ tests/system/suite_tools/tst_git_local/test.py | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/system/suite_tools/tst_codepasting/test.py b/tests/system/suite_tools/tst_codepasting/test.py index 148052a804..ec0d9ee226 100644 --- a/tests/system/suite_tools/tst_codepasting/test.py +++ b/tests/system/suite_tools/tst_codepasting/test.py @@ -72,7 +72,7 @@ def pasteFile(sourceFile, protocol): try: outputWindow = waitForObject(":Qt Creator_Core::OutputWindow") waitFor("re.search('^https://', str(outputWindow.plainText)) is not None", 20000) - output = filter(lambda x: len(x), str(outputWindow.plainText).splitlines())[-1] + output = list(filter(lambda x: len(x), str(outputWindow.plainText).splitlines()))[-1] except: output = "" if closeHTTPStatusAndPasterDialog(protocol, ':Send to Codepaster_CodePaster::PasteView'): @@ -126,10 +126,11 @@ def fetchSnippet(protocol, description, pasteId, skippedPasting): waitFor("pasteModel.rowCount() == 1", 1000) waitFor("pasteModel.rowCount() > 1", 20000) if pasteId == invalidPasteId(protocol): - try: - pasteLine = filter(lambda str:description in str, dumpItems(pasteModel))[0] - pasteId = pasteLine.split(" ", 1)[0] - except: + for currentItem in dumpItems(pasteModel): + if description in currentItem: + pasteId = currentItem.split(" ", 1)[0] + break + if pasteId == invalidPasteId(protocol): test.fail("Could not find description line in list of pastes from %s" % protocol) clickButton(waitForObject(":PasteSelectDialog.Cancel_QPushButton")) return pasteId @@ -242,7 +243,8 @@ def main(): # QString QTextCursor::selectedText () const: # "Note: If the selection obtained from an editor spans a line break, the text will contain a # Unicode U+2029 paragraph separator character instead of a newline \n character." - selectedText = str(editor.textCursor().selectedText()).replace(unichr(0x2029), "\n") + newParagraph = chr(0x2029) if sys.version_info.major > 2 else unichr(0x2029) + selectedText = str(editor.textCursor().selectedText()).replace(newParagraph, "\n") invokeMenuItem("Tools", "Code Pasting", "Paste Snippet...") test.compare(waitForObject(":stackedWidget.plainTextEdit_QPlainTextEdit").plainText, selectedText, "Verify that dialog shows selected text from the editor") diff --git a/tests/system/suite_tools/tst_git_local/test.py b/tests/system/suite_tools/tst_git_local/test.py index 07208367fd..ab36b86b25 100644 --- a/tests/system/suite_tools/tst_git_local/test.py +++ b/tests/system/suite_tools/tst_git_local/test.py @@ -65,7 +65,8 @@ def __clickCommit__(count): # find commit try: # Commits are listed in reverse chronologic order, so we have to invert count - line = filter(lambda line: line.startswith("commit"), content.splitlines())[-count].strip() + line = list(filter(lambda line: line.startswith("commit"), + content.splitlines()))[-count].strip() commit = line.split(" ", 1)[1] except: test.fail("Could not find the %d. commit - leaving test" % count) @@ -90,7 +91,7 @@ def __clickCommit__(count): {"Committer: %s, %s" % (id, time): True}] for line, exp in zip(show.splitlines(), expected): expLine = list(exp.keys())[0] - isRegex = exp.values()[0] + isRegex = list(exp.values())[0] if isRegex: test.verify(re.match(expLine, line), "Verifying commit header line '%s'" % line) else: -- cgit v1.2.1