diff options
author | Robert Löhning <robert.loehning@qt.io> | 2024-01-25 12:02:29 +0100 |
---|---|---|
committer | Robert Löhning <robert.loehning@qt.io> | 2024-04-10 07:30:00 +0000 |
commit | 95df308bc315f353883dbd9f2c0a8f8ca806470d (patch) | |
tree | bbbdeb8a80ef2832991a9e5219d0549ed127972e /tests | |
parent | 7bf7c4fbe3326cda0d2dca6a32eaabe40305bce6 (diff) |
SquishTests: Remove compatibility code for Python 2
Change-Id: Ibcf9a76fb163aa7167ad0ef0616c39b33c30d7c5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/system/shared/classes.py | 7 | ||||
-rw-r--r-- | tests/system/shared/project.py | 2 | ||||
-rw-r--r-- | tests/system/shared/qtcreator.py | 6 | ||||
-rw-r--r-- | tests/system/shared/utils.py | 9 | ||||
-rw-r--r-- | tests/system/suite_editors/tst_revert_changes/test.py | 2 | ||||
-rw-r--r-- | tests/system/suite_general/tst_cmake_speedcrunch/test.py | 4 | ||||
-rw-r--r-- | tests/system/suite_qtquick/tst_qml_outline/test.py | 2 | ||||
-rw-r--r-- | tests/system/suite_tools/tst_codepasting/test.py | 2 |
8 files changed, 12 insertions, 22 deletions
diff --git a/tests/system/shared/classes.py b/tests/system/shared/classes.py index dcc702295b..4611a0cefe 100644 --- a/tests/system/shared/classes.py +++ b/tests/system/shared/classes.py @@ -1,10 +1,7 @@ # Copyright (C) 2016 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -try: - import __builtin__ # Python 2 -except ImportError: - import builtins as __builtin__ # Python 3 +import builtins # for easier re-usage (because Python hasn't an enum type) class Targets: @@ -128,7 +125,7 @@ class QtPath: @staticmethod def toVersionTuple(versionString): - return tuple(map(__builtin__.int, versionString.split("."))) + return tuple(map(builtins.int, versionString.split("."))) @staticmethod def getQtVersion(target): diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py index 00641e465b..a45d78cfc4 100644 --- a/tests/system/shared/project.py +++ b/tests/system/shared/project.py @@ -603,7 +603,7 @@ def __writeProjectTreeFile__(projectTree, filename): def __getTestData__(record): return [testData.field(record, "text"), - __builtin__.int(testData.field(record, "nestinglevel"))] + builtins.int(testData.field(record, "nestinglevel"))] def compareProjectTree(rootObject, dataset): root = waitForObject(rootObject) diff --git a/tests/system/shared/qtcreator.py b/tests/system/shared/qtcreator.py index e97c0b025f..f1d4078fb5 100644 --- a/tests/system/shared/qtcreator.py +++ b/tests/system/shared/qtcreator.py @@ -12,11 +12,7 @@ import subprocess; import sys import errno; from datetime import datetime,timedelta; -if sys.version_info.major > 2: - import builtins as __builtin__ -else: - import __builtin__ - +import builtins srcPath = '' SettingsPath = [] diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index 8890ce4da0..f115d7103f 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -595,15 +595,12 @@ def getHelpTitle(): def isString(sth): - if sys.version_info.major > 2: - return isinstance(sth, str) - else: - return isinstance(sth, (str, unicode)) + return isinstance(sth, str) + # helper function to ensure we get str, converts bytes if necessary def stringify(obj): - stringTypes = (str, unicode) if sys.version_info.major == 2 else (str) - if isinstance(obj, stringTypes): + if isString(obj): return obj if isinstance(obj, bytes): if not platform.system() in ('Microsoft', 'Windows'): diff --git a/tests/system/suite_editors/tst_revert_changes/test.py b/tests/system/suite_editors/tst_revert_changes/test.py index 6ad06b1124..7774faed4b 100644 --- a/tests/system/suite_editors/tst_revert_changes/test.py +++ b/tests/system/suite_editors/tst_revert_changes/test.py @@ -33,7 +33,7 @@ def main(): __modifyFile__(fileName, modification) test.log("Reverting all files...") fileModifications = dict(zip(fileModifications.keys(), - (__builtin__.bool(v) for v in fileModifications.values()))) + (builtins.bool(v) for v in fileModifications.values()))) revertChanges(fileModifications) invokeMenuItem("File", "Exit") diff --git a/tests/system/suite_general/tst_cmake_speedcrunch/test.py b/tests/system/suite_general/tst_cmake_speedcrunch/test.py index 4f75d43eb9..4761daaed1 100644 --- a/tests/system/suite_general/tst_cmake_speedcrunch/test.py +++ b/tests/system/suite_general/tst_cmake_speedcrunch/test.py @@ -12,8 +12,8 @@ def cmakeSupported(): versionLine = next(iter(versionLines)) test.log("Using " + versionLine) matcher = re.match("cmake version (\d+)\.(\d+)\.\d+", versionLine) - major = __builtin__.int(matcher.group(1)) - minor = __builtin__.int(matcher.group(2)) + major = builtins.int(matcher.group(1)) + minor = builtins.int(matcher.group(2)) except: return False diff --git a/tests/system/suite_qtquick/tst_qml_outline/test.py b/tests/system/suite_qtquick/tst_qml_outline/test.py index fb3662b805..5eb9ab3e33 100644 --- a/tests/system/suite_qtquick/tst_qml_outline/test.py +++ b/tests/system/suite_qtquick/tst_qml_outline/test.py @@ -104,7 +104,7 @@ def __writeOutlineFile__(outlinePseudoTree, filename): def retrieveData(record): return (testData.field(record, "element"), - __builtin__.int(testData.field(record, "nestinglevel")), + builtins.int(testData.field(record, "nestinglevel")), testData.field(record, "value")) def verifyOutline(outlinePseudoTree, datasetFileName): diff --git a/tests/system/suite_tools/tst_codepasting/test.py b/tests/system/suite_tools/tst_codepasting/test.py index ec0d9ee226..2720b336df 100644 --- a/tests/system/suite_tools/tst_codepasting/test.py +++ b/tests/system/suite_tools/tst_codepasting/test.py @@ -243,7 +243,7 @@ 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." - newParagraph = chr(0x2029) if sys.version_info.major > 2 else unichr(0x2029) + newParagraph = chr(0x2029) selectedText = str(editor.textCursor().selectedText()).replace(newParagraph, "\n") invokeMenuItem("Tools", "Code Pasting", "Paste Snippet...") test.compare(waitForObject(":stackedWidget.plainTextEdit_QPlainTextEdit").plainText, |