aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Löhning <robert.loehning@qt.io>2023-07-26 17:30:53 +0200
committerRobert Löhning <robert.loehning@qt.io>2023-07-27 11:41:40 +0000
commita521114519833efce73afe7dab806cf81e15a27f (patch)
treee2fcd0507991b2c6256e89e052e24ac74be84ee2
parent4a8c08a349638bc3106e341fec5e4d308102a152 (diff)
SquishTests: Don't initialize an entire list for reading one item
The point of Python3 returning objects instead of lists is that it will iterate just as far as items are actually being used. Change-Id: If4d9742bb47aa9cac1166a0ff6f10d211829fd85 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--tests/system/shared/debugger.py4
-rw-r--r--tests/system/shared/qtcreator.py3
-rw-r--r--tests/system/suite_HELP/tst_HELP02/test.py2
-rw-r--r--tests/system/suite_general/tst_cmake_speedcrunch/test.py2
-rw-r--r--tests/system/suite_general/tst_create_proj_wizard/test.py4
-rw-r--r--tests/system/suite_general/tst_default_settings/test.py12
-rw-r--r--tests/system/suite_tools/tst_git_local/test.py4
7 files changed, 16 insertions, 15 deletions
diff --git a/tests/system/shared/debugger.py b/tests/system/shared/debugger.py
index 7176afc8e5..b878f9efef 100644
--- a/tests/system/shared/debugger.py
+++ b/tests/system/shared/debugger.py
@@ -238,7 +238,7 @@ def __logDebugResult__():
def verifyBreakPoint(bpToVerify):
if isinstance(bpToVerify, dict):
- fileName = list(bpToVerify.keys())[0]
+ fileName = next(iter(bpToVerify.keys()))
editor = getEditorForFileSuffix(fileName)
if editor:
test.compare(waitForObject(":DebugModeWidget_QComboBox").toolTip, fileName,
@@ -247,7 +247,7 @@ def verifyBreakPoint(bpToVerify):
windowTitle = str(waitForObject(":Qt Creator_Core::Internal::MainWindow").windowTitle)
test.verify(windowTitle.startswith(os.path.basename(fileName) + " "),
"Verify that Creator's window title changed according to current file")
- return test.compare(line, list(bpToVerify.values())[0],
+ return test.compare(line, next(iter(bpToVerify.values())),
"Compare hit breakpoint to expected line number in %s" % fileName)
else:
test.fatal("Expected a dict for bpToVerify - got '%s'" % className(bpToVerify))
diff --git a/tests/system/shared/qtcreator.py b/tests/system/shared/qtcreator.py
index 0b86001529..bb52497774 100644
--- a/tests/system/shared/qtcreator.py
+++ b/tests/system/shared/qtcreator.py
@@ -206,7 +206,8 @@ def substituteCdb(settingsDir):
try:
serverIni = readFile(os.path.join(os.getenv("APPDATA"), "froglogic",
"Squish", "ver1", "server.ini"))
- autLine = list(filter(lambda line: "AUT/qtcreator" in line, serverIni.splitlines()))[0]
+ autLine = next(iter(filter(lambda line: "AUT/qtcreator" in line,
+ serverIni.splitlines())))
autPath = autLine.split("\"")[1]
return os.path.exists(os.path.join(autPath, "..", "lib", "qtcreatorcdbext64"))
except:
diff --git a/tests/system/suite_HELP/tst_HELP02/test.py b/tests/system/suite_HELP/tst_HELP02/test.py
index 8b6c32b7de..9c5104087e 100644
--- a/tests/system/suite_HELP/tst_HELP02/test.py
+++ b/tests/system/suite_HELP/tst_HELP02/test.py
@@ -44,7 +44,7 @@ def checkQtCreatorHelpVersion(expectedVersion):
helpContentWidget = waitForObject(':Qt Creator_QHelpContentWidget', 5000)
waitFor("any(map(rightStart, dumpItems(helpContentWidget.model())))", 10000)
items = dumpItems(helpContentWidget.model())
- test.compare(list(filter(rightStart, items))[0],
+ test.compare(next(iter(filter(rightStart, items))),
'Qt Creator Manual %s' % expectedVersion,
'Verifying whether manual uses expected version.')
except:
diff --git a/tests/system/suite_general/tst_cmake_speedcrunch/test.py b/tests/system/suite_general/tst_cmake_speedcrunch/test.py
index 681835818e..4f75d43eb9 100644
--- a/tests/system/suite_general/tst_cmake_speedcrunch/test.py
+++ b/tests/system/suite_general/tst_cmake_speedcrunch/test.py
@@ -9,7 +9,7 @@ def cmakeSupported():
versionLines = filter(lambda line: "cmake version " in line,
getOutputFromCmdline(["cmake", "--version"]).splitlines())
try:
- versionLine = list(versionLines)[0]
+ versionLine = next(iter(versionLines))
test.log("Using " + versionLine)
matcher = re.match("cmake version (\d+)\.(\d+)\.\d+", versionLine)
major = __builtin__.int(matcher.group(1))
diff --git a/tests/system/suite_general/tst_create_proj_wizard/test.py b/tests/system/suite_general/tst_create_proj_wizard/test.py
index 8579111b02..d521f2092d 100644
--- a/tests/system/suite_general/tst_create_proj_wizard/test.py
+++ b/tests/system/suite_general/tst_create_proj_wizard/test.py
@@ -49,8 +49,8 @@ def main():
availableProjectTypes.append({category:template})
safeClickButton("Cancel")
for current in availableProjectTypes:
- category = list(current.keys())[0]
- template = list(current.values())[0]
+ category = next(iter(current.keys()))
+ template = next(iter(current.values()))
with TestSection("Testing project template %s -> %s" % (category, template)):
displayedPlatforms = __createProject__(category, template)
if template.startswith("Qt Quick Application"):
diff --git a/tests/system/suite_general/tst_default_settings/test.py b/tests/system/suite_general/tst_default_settings/test.py
index ce026e98d3..f7ece36e6d 100644
--- a/tests/system/suite_general/tst_default_settings/test.py
+++ b/tests/system/suite_general/tst_default_settings/test.py
@@ -311,15 +311,15 @@ def __compareCompilers__(foundCompilers, expectedCompilers):
for currentExp in expectedCompilers:
if isString(currentExp):
continue
- key = list(currentExp.keys())[0]
+ key = next(iter(currentExp.keys()))
# the regex .*? is used for the different possible version strings of the WinSDK
# if it's present a regex will be validated otherwise simple string comparison
# same applies for [.0-9]+ which is used for minor/patch versions
isRegex = ".*?" in key or "[.0-9]+" in key
- if (((isRegex and re.match(key, list(currentFound.keys())[0], flags)))
+ if (((isRegex and re.match(key, next(iter(currentFound.keys())), flags)))
or currentFound.keys() == currentExp.keys()):
- if ((isWin and os.path.abspath(list(currentFound.values())[0].lower())
- == os.path.abspath(list(currentExp.values())[0].lower()))
+ if ((isWin and os.path.abspath(next(iter(currentFound.values())).lower())
+ == os.path.abspath(next(iter(currentExp.values())).lower()))
or currentFound.values() == currentExp.values()):
foundExp = True
break
@@ -375,8 +375,8 @@ def __checkCreatedSettings__(settingsFolder):
test.verify(os.path.isdir(f),
"Verifying whether folder '%s' has been created." % os.path.basename(f))
for f in files:
- fName = list(f.keys())[0]
- fMinSize = list(f.values())[0]
+ fName = next(iter(f.keys()))
+ fMinSize = next(iter(f.values()))
text = "created non-empty"
if fMinSize > 0:
text = "modified"
diff --git a/tests/system/suite_tools/tst_git_local/test.py b/tests/system/suite_tools/tst_git_local/test.py
index 9ce9a0b316..450f3b5855 100644
--- a/tests/system/suite_tools/tst_git_local/test.py
+++ b/tests/system/suite_tools/tst_git_local/test.py
@@ -90,8 +90,8 @@ def __clickCommit__(count):
{"Author: %s, %s" % (id, time): True},
{"Committer: %s, %s" % (id, time): True}]
for line, exp in zip(show.splitlines(), expected):
- expLine = list(exp.keys())[0]
- isRegex = list(exp.values())[0]
+ expLine = next(iter(exp.keys()))
+ isRegex = next(iter(exp.values()))
if isRegex:
test.verify(re.match(expLine, line), "Verifying commit header line '%s'" % line)
else: