From ff10f8c3a58c2c57e221e294d5c4829c3fd05c15 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Thu, 2 Aug 2018 13:45:34 +0200 Subject: Squish: Fix warnings Warnings from static code checks, that is, not test.warning() at runtime. Change-Id: I651d13491106583908059ecdb5f700f539b6d9c8 Reviewed-by: Christian Stenger --- tests/system/shared/build_utils.py | 2 +- tests/system/shared/classes.py | 1 - tests/system/shared/debugger.py | 6 ++---- tests/system/shared/editor_utils.py | 7 +++---- tests/system/shared/project_explorer.py | 4 ++-- tests/system/shared/utils.py | 4 ++-- tests/system/suite_APTW/tst_APTW03/test.py | 2 +- tests/system/suite_CSUP/tst_CSUP04/test.py | 2 +- tests/system/suite_CSUP/tst_CSUP05/test.py | 2 +- tests/system/suite_HELP/tst_HELP06/test.py | 2 +- tests/system/suite_QMLS/tst_QMLS02/test.py | 2 +- tests/system/suite_QMLS/tst_QMLS03/test.py | 6 +++--- tests/system/suite_QMLS/tst_QMLS04/test.py | 2 +- tests/system/suite_QMLS/tst_QMLS05/test.py | 4 ++-- tests/system/suite_QMLS/tst_QMLS06/test.py | 4 ++-- tests/system/suite_QMLS/tst_QMLS07/test.py | 2 +- tests/system/suite_QMLS/tst_QMLS08/test.py | 2 +- tests/system/suite_debugger/tst_qml_js_console/test.py | 3 +-- tests/system/suite_debugger/tst_qml_locals/test.py | 2 +- tests/system/suite_editors/tst_qml_indent/test.py | 1 - tests/system/suite_editors/tst_rename_macros/test.py | 2 +- tests/system/suite_general/tst_build_speedcrunch/test.py | 1 - tests/system/suite_general/tst_create_proj_wizard/test.py | 1 - tests/system/suite_general/tst_default_settings/test.py | 2 -- tests/system/suite_qtquick/tst_qml_outline/test.py | 6 +++--- tests/system/suite_qtquick/tst_qtquick_creation/test.py | 1 - tests/system/suite_tools/tst_git_local/test.py | 4 ++-- 27 files changed, 33 insertions(+), 44 deletions(-) (limited to 'tests') diff --git a/tests/system/shared/build_utils.py b/tests/system/shared/build_utils.py index d2d1f596007..0aaab2ac33d 100644 --- a/tests/system/shared/build_utils.py +++ b/tests/system/shared/build_utils.py @@ -37,7 +37,7 @@ def getBuildIssues(): def checkLastBuild(expectedToFail=False, createTasksFileOnError=True): try: # can't use waitForObject() 'cause visible is always 0 - buildProg = findObject("{type='ProjectExplorer::Internal::BuildProgress' unnamed='1' }") + findObject("{type='ProjectExplorer::Internal::BuildProgress' unnamed='1' }") except LookupError: test.log("checkLastBuild called without a build") return diff --git a/tests/system/shared/classes.py b/tests/system/shared/classes.py index c4db7046e28..a8bdbf96640 100644 --- a/tests/system/shared/classes.py +++ b/tests/system/shared/classes.py @@ -24,7 +24,6 @@ ############################################################################ import __builtin__ -import operator # for easier re-usage (because Python hasn't an enum type) class Targets: diff --git a/tests/system/shared/debugger.py b/tests/system/shared/debugger.py index b3cf7988a99..1a1fc39a567 100644 --- a/tests/system/shared/debugger.py +++ b/tests/system/shared/debugger.py @@ -23,8 +23,6 @@ # ############################################################################ -import re - def handleDebuggerWarnings(config, isMsvcBuild=False): if isMsvcBuild: try: @@ -71,8 +69,8 @@ def setBreakpointsForCurrentProject(filesAndLines): if not filesAndLines or not isinstance(filesAndLines, (list,tuple)): test.fatal("This function only takes a non-empty list/tuple holding dicts.") return False - navTree = waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' " - "window=':Qt Creator_Core::Internal::MainWindow'}") + waitForObject("{type='Utils::NavigationTreeView' unnamed='1' visible='1' " + "window=':Qt Creator_Core::Internal::MainWindow'}") for current in filesAndLines: for curFile,curLine in current.iteritems(): if not openDocument(curFile): diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index 09b3af6ae71..df3f7d37ea5 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -106,7 +106,7 @@ def openContextMenuOnTextCursorPosition(editor): # param direction is one of "Left", "Right", "Up", "Down", but "End" and combinations work as well # param typeCount defines how often the cursor will be moved in the given direction (while marking) def markText(editor, direction, typeCount=1): - for i in range(typeCount): + for _ in range(typeCount): type(editor, "" % direction) # works for all standard editors @@ -173,7 +173,7 @@ def verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, e # param expectedVals a dict holding property value pairs that must match def __handleTextTips__(textTip, expectedVals, alternativeVals): props = object.properties(textTip) - expFail = altFail = False + expFail = False eResult = verifyProperties(props, expectedVals) for val in eResult.itervalues(): if not val: @@ -182,7 +182,6 @@ def __handleTextTips__(textTip, expectedVals, alternativeVals): if expFail and alternativeVals != None: aResult = verifyProperties(props, alternativeVals) else: - altFail = True aResult = None if not expFail: test.passes("TextTip verified") @@ -360,7 +359,7 @@ def invokeContextMenuItem(editorArea, command1, command2 = None): def invokeFindUsage(editor, line, typeOperation, n=1): if not placeCursorToLine(editor, line, True): return False - for i in range(n): + for _ in range(n): type(editor, typeOperation) snooze(1) invokeContextMenuItem(editor, "Find Usages") diff --git a/tests/system/shared/project_explorer.py b/tests/system/shared/project_explorer.py index 336d82fc485..2ad9a329577 100644 --- a/tests/system/shared/project_explorer.py +++ b/tests/system/shared/project_explorer.py @@ -42,7 +42,7 @@ def switchViewTo(view): text = "" pattern = ViewConstants.getToolTipForViewTab(view) if re.match(pattern, unicode(text), re.UNICODE): - test.passes("ToolTip verified") + test.passes("ToolTip verified") else: test.warning("ToolTip does not match", "Expected pattern: %s\nGot: %s" % (pattern, text)) mouseClick(waitForObject("{type='Core::Internal::FancyTabBar' unnamed='1' visible='1' " @@ -158,7 +158,7 @@ def addAndActivateKit(kit): kitString = Targets.getStringForTarget(kit) switchViewTo(ViewConstants.PROJECTS) try: - treeView = waitForObject(":Projects.ProjectNavigationTreeView") + waitForObject(":Projects.ProjectNavigationTreeView") wanted = getQModelIndexStr("text='%s'" % kitString, bAndRIndex) index = findObject(wanted) if str(index.toolTip).startswith(clickToActivate): diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index 590b277a1e6..097772769d0 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -458,7 +458,7 @@ def iterateQtVersions(keepOptionsOpen=False, alreadyOnOptionsDialog=False, currResult = additionalFunction(target, version, *argsForAdditionalFunc) except: import sys - t,v,tb = sys.exc_info() + t,v,_ = sys.exc_info() currResult = None test.fatal("Function to additionally execute on Options Dialog could not be found or " "an exception occurred while executing it.", "%s(%s)" % (str(t), str(v))) @@ -521,7 +521,7 @@ def iterateKits(keepOptionsOpen=False, alreadyOnOptionsDialog=False, currResult = additionalFunction(item, kitName, *argsForAdditionalFunc) except: import sys - t,v,tb = sys.exc_info() + t,v,_ = sys.exc_info() currResult = None test.fatal("Function to additionally execute on Options Dialog could not be " "found or an exception occurred while executing it.", "%s(%s)" % diff --git a/tests/system/suite_APTW/tst_APTW03/test.py b/tests/system/suite_APTW/tst_APTW03/test.py index 022c1ba8130..ca1378196af 100644 --- a/tests/system/suite_APTW/tst_APTW03/test.py +++ b/tests/system/suite_APTW/tst_APTW03/test.py @@ -98,7 +98,7 @@ def main(): test.fail("Could not open %s.h - continuing." % className.lower()) continue editor = getEditorForFileSuffix("%s.h" % className.lower()) - oldContent = str(editor.plainText) + str(editor.plainText) placeCursorToLine(editor, "class %s.*" % className, True) snooze(4) # avoid timing issue with the parser invokeContextMenuItem(editor, "Refactor", "Insert Virtual Functions of Base Classes") diff --git a/tests/system/suite_CSUP/tst_CSUP04/test.py b/tests/system/suite_CSUP/tst_CSUP04/test.py index e922281d4b8..d6eaf7086ea 100644 --- a/tests/system/suite_CSUP/tst_CSUP04/test.py +++ b/tests/system/suite_CSUP/tst_CSUP04/test.py @@ -70,7 +70,7 @@ def main(): openDocument("openglwindow.Sources.main\\.cpp") if not placeCursorToLine(editorWidget, 'm_posAttr = m_program->attributeLocation("posAttr");'): return - for i in range(13): + for _ in range(13): type(editorWidget, "") type(editorWidget, "") # wait until search finished and verify search results diff --git a/tests/system/suite_CSUP/tst_CSUP05/test.py b/tests/system/suite_CSUP/tst_CSUP05/test.py index 466b77b5fbb..0824ef48fdc 100644 --- a/tests/system/suite_CSUP/tst_CSUP05/test.py +++ b/tests/system/suite_CSUP/tst_CSUP05/test.py @@ -76,7 +76,7 @@ def main(): # select some other word in .cpp file and select "Edit" -> "Find/Replace". clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton")) placeCursorToLine(editorWidget, "void Trianglefind::render()") - for i in range(10): + for _ in range(10): type(editorWidget, "") markText(editorWidget, "Left", 12) invokeMenuItem("Edit", "Find/Replace", "Find/Replace") diff --git a/tests/system/suite_HELP/tst_HELP06/test.py b/tests/system/suite_HELP/tst_HELP06/test.py index d1d87f0b048..11ef0e7c0e8 100755 --- a/tests/system/suite_HELP/tst_HELP06/test.py +++ b/tests/system/suite_HELP/tst_HELP06/test.py @@ -107,7 +107,7 @@ def main(): checkIfObjectExists(manualQModelIndex, verboseOnFail = True), "Verifying if all folders and bookmarks are present") mouseClick(waitForObject(":Qt Creator_Bookmarks_TreeView"), 5, 5, 0, Qt.LeftButton) - for i in range(6): + for _ in range(6): type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "") type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "") test.verify(textForQtVersion("Building and Running an Example") in getHelpTitle(), diff --git a/tests/system/suite_QMLS/tst_QMLS02/test.py b/tests/system/suite_QMLS/tst_QMLS02/test.py index 687f53a53f5..752bf3a05e5 100644 --- a/tests/system/suite_QMLS/tst_QMLS02/test.py +++ b/tests/system/suite_QMLS/tst_QMLS02/test.py @@ -48,7 +48,7 @@ def main(): "Verifying if error is properly reported") # repair error - go to written line placeCursorToLine(editorArea, testingCodeLine) - for i in range(14): + for _ in range(14): type(editorArea, "") markText(editorArea, "Right") type(editorArea, "c") diff --git a/tests/system/suite_QMLS/tst_QMLS03/test.py b/tests/system/suite_QMLS/tst_QMLS03/test.py index 0287c352f36..16120b81fe4 100644 --- a/tests/system/suite_QMLS/tst_QMLS03/test.py +++ b/tests/system/suite_QMLS/tst_QMLS03/test.py @@ -90,7 +90,7 @@ def main(): if not placeCursorToLine(editorArea, "Rectangle {"): invokeMenuItem("File", "Exit") return - for i in range(5): + for _ in range(5): type(editorArea, "") invokeContextMenuItem(editorArea, "Find Usages") # check if usage was properly found @@ -109,7 +109,7 @@ def main(): if not placeCursorToLine(editorArea, "anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }"): invokeMenuItem("File", "Exit") return - for i in range(87): + for _ in range(87): type(editorArea, "") invokeMenuItem("Tools", "QML/JS", "Find Usages") # check if usage was properly found @@ -128,7 +128,7 @@ def main(): if not placeCursorToLine(editorArea, "SequentialAnimation on opacity {"): invokeMenuItem("File", "Exit") return - for i in range(5): + for _ in range(5): type(editorArea, "") type(editorArea, "") # check if usage was properly found diff --git a/tests/system/suite_QMLS/tst_QMLS04/test.py b/tests/system/suite_QMLS/tst_QMLS04/test.py index 6d4d9624775..b6336700c43 100644 --- a/tests/system/suite_QMLS/tst_QMLS04/test.py +++ b/tests/system/suite_QMLS/tst_QMLS04/test.py @@ -37,7 +37,7 @@ def main(): saveAndExit() return placeCursorToLine(editorArea, "TextEdit {") - for i in range(5): + for _ in range(5): type(editorArea, "") # invoke Refactoring - Move Component into separate file invokeContextMenuItem(editorArea, "Refactoring", "Move Component into Separate File") diff --git a/tests/system/suite_QMLS/tst_QMLS05/test.py b/tests/system/suite_QMLS/tst_QMLS05/test.py index 111bf68f391..9f78d8b8c4f 100644 --- a/tests/system/suite_QMLS/tst_QMLS05/test.py +++ b/tests/system/suite_QMLS/tst_QMLS05/test.py @@ -32,13 +32,13 @@ def main(): homeKey = "" if platform.system() == "Darwin": homeKey = "" - for i in range(2): + for _ in range(2): type(editorArea, homeKey) type(editorArea, "") type(editorArea, "") type(editorArea, "") type(editorArea, "Item { x: 10; y: 20; width: 10 }") - for i in range(30): + for _ in range(30): type(editorArea, "") invokeMenuItem("File", "Save All") # activate menu and apply 'Refactoring - Split initializer' diff --git a/tests/system/suite_QMLS/tst_QMLS06/test.py b/tests/system/suite_QMLS/tst_QMLS06/test.py index f4e9a12d92d..9c61188e1f3 100644 --- a/tests/system/suite_QMLS/tst_QMLS06/test.py +++ b/tests/system/suite_QMLS/tst_QMLS06/test.py @@ -32,14 +32,14 @@ def main(): homeKey = "" if platform.system() == "Darwin": homeKey = "" - for i in range(2): + for _ in range(2): type(editorArea, homeKey) type(editorArea, "") type(editorArea, "") type(editorArea, "") testingItemText = "Item { x: 10; y: 20; width: 10 }" type(editorArea, testingItemText) - for i in range(30): + for _ in range(30): type(editorArea, "") invokeMenuItem("File", "Save All") # invoke Refactoring - Wrap Component in Loader diff --git a/tests/system/suite_QMLS/tst_QMLS07/test.py b/tests/system/suite_QMLS/tst_QMLS07/test.py index 631aff02205..054332e5213 100644 --- a/tests/system/suite_QMLS/tst_QMLS07/test.py +++ b/tests/system/suite_QMLS/tst_QMLS07/test.py @@ -31,7 +31,7 @@ def main(): return type(editorArea, "") type(editorArea, "Color") - for i in range(3): + for _ in range(3): type(editorArea, "") invokeMenuItem("File", "Save All") # invoke Refactoring - Add a message suppression comment. diff --git a/tests/system/suite_QMLS/tst_QMLS08/test.py b/tests/system/suite_QMLS/tst_QMLS08/test.py index bb5f9e4c14d..5e0b3aefea9 100644 --- a/tests/system/suite_QMLS/tst_QMLS08/test.py +++ b/tests/system/suite_QMLS/tst_QMLS08/test.py @@ -71,7 +71,7 @@ def main(): return # cancel indentation type(editorArea, "") - for i in range(5): + for _ in range(5): type(editorArea, "") # select unindented block type(editorArea, "") diff --git a/tests/system/suite_debugger/tst_qml_js_console/test.py b/tests/system/suite_debugger/tst_qml_js_console/test.py index 7022b09cd5f..1d193541bcd 100644 --- a/tests/system/suite_debugger/tst_qml_js_console/test.py +++ b/tests/system/suite_debugger/tst_qml_js_console/test.py @@ -68,7 +68,6 @@ def debuggerHasStopped(): def getQmlJSConsoleOutput(): try: - result = [] consoleView = waitForObject(":DebugModeWidget_Debugger::Internal::ConsoleView") model = consoleView.model() # old input, output, new input > 2 @@ -135,7 +134,7 @@ def main(): switchViewTo(ViewConstants.EDIT) # start debugging clickButton(fancyDebugButton) - locAndExprTV = waitForObject(":Locals and Expressions_Debugger::Internal::WatchTreeView") + waitForObject(":Locals and Expressions_Debugger::Internal::WatchTreeView") rootIndex = getQModelIndexStr("text='Rectangle'", ":Locals and Expressions_Debugger::Internal::WatchTreeView") # make sure the items inside the root item are visible diff --git a/tests/system/suite_debugger/tst_qml_locals/test.py b/tests/system/suite_debugger/tst_qml_locals/test.py index 06a60bb1166..3429d5725f9 100644 --- a/tests/system/suite_debugger/tst_qml_locals/test.py +++ b/tests/system/suite_debugger/tst_qml_locals/test.py @@ -117,7 +117,7 @@ def fetchItems(index, valIndex, treeView): tree.setName(name) tree.setValue(value) for row in range(model.rowCount(index)): - tree.addChild(fetchItems(model.index(row, 0, index), model.index(row, 1, index), treeView)) + tree.addChild(fetchItems(model.index(row, 0, index), model.index(row, 1, index), treeView)) return tree def checkForEmptyRows(items, isRootCheck=True): diff --git a/tests/system/suite_editors/tst_qml_indent/test.py b/tests/system/suite_editors/tst_qml_indent/test.py index f05da16317e..2be24a94ce9 100644 --- a/tests/system/suite_editors/tst_qml_indent/test.py +++ b/tests/system/suite_editors/tst_qml_indent/test.py @@ -44,7 +44,6 @@ def prepareQmlFile(): editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget") isDarwin = platform.system() == 'Darwin' for i in range(3): - content = "%s" % editor.plainText if not placeCursorToLine(editor, 'title: qsTr("Hello World")'): test.fatal("Couldn't find line(s) I'm looking for - QML file seems to " "have changed!\nLeaving test...") diff --git a/tests/system/suite_editors/tst_rename_macros/test.py b/tests/system/suite_editors/tst_rename_macros/test.py index 581247bfdfb..5a4177daad4 100644 --- a/tests/system/suite_editors/tst_rename_macros/test.py +++ b/tests/system/suite_editors/tst_rename_macros/test.py @@ -118,7 +118,7 @@ def testRenameMacroAfterSourceMoving(): return True def performMacroRenaming(newMacroName): - for i in range(10): + for _ in range(10): type(cppEditorStr, "") invokeContextMenuItem(waitForObject(cppEditorStr), "Refactor", "Rename Symbol Under Cursor") diff --git a/tests/system/suite_general/tst_build_speedcrunch/test.py b/tests/system/suite_general/tst_build_speedcrunch/test.py index ef51997c7f9..1d7eda90884 100644 --- a/tests/system/suite_general/tst_build_speedcrunch/test.py +++ b/tests/system/suite_general/tst_build_speedcrunch/test.py @@ -24,7 +24,6 @@ ############################################################################ source("../../shared/qtcreator.py") -import re SpeedCrunchPath = "" 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 adfe3d60442..34878b9566a 100644 --- a/tests/system/suite_general/tst_create_proj_wizard/test.py +++ b/tests/system/suite_general/tst_create_proj_wizard/test.py @@ -45,7 +45,6 @@ def main(): projects = catModel.index(0, 0) test.compare("Projects", str(projects.data())) comboBox = findObject(":New.comboBox_QComboBox") - targets = zip(*kits.values())[0] test.verify(comboBox.enabled, "Verifying whether combobox is enabled.") test.compare(comboBox.currentText, "All Templates") try: diff --git a/tests/system/suite_general/tst_default_settings/test.py b/tests/system/suite_general/tst_default_settings/test.py index 72ff89c7e38..bb75bf9b326 100644 --- a/tests/system/suite_general/tst_default_settings/test.py +++ b/tests/system/suite_general/tst_default_settings/test.py @@ -26,8 +26,6 @@ source("../../shared/qtcreator.py") import re -import tempfile -import __builtin__ currentSelectedTreeItem = None warningOrError = re.compile('

((Error|Warning).*?)

') diff --git a/tests/system/suite_qtquick/tst_qml_outline/test.py b/tests/system/suite_qtquick/tst_qml_outline/test.py index e14c5eb5394..7b806afc28a 100644 --- a/tests/system/suite_qtquick/tst_qml_outline/test.py +++ b/tests/system/suite_qtquick/tst_qml_outline/test.py @@ -139,9 +139,9 @@ def verifyOutline(outlinePseudoTree, datasetFileName): "Found %d elements, but expected %d" % (len(outlinePseudoTree), len(expected))) return for counter, (expectedItem, foundItem) in enumerate(zip(expected, outlinePseudoTree)): - if expectedItem != foundItem: - test.fail("Mismatch in element number %d for '%s'" % (counter + 1, fileName), + if expectedItem != foundItem: + test.fail("Mismatch in element number %d for '%s'" % (counter + 1, fileName), "%s != %s" % (str(expectedItem), str(foundItem))) - return + return test.passes("All nodes (%d) inside outline match expected nodes for '%s'." % (len(expected), fileName)) diff --git a/tests/system/suite_qtquick/tst_qtquick_creation/test.py b/tests/system/suite_qtquick/tst_qtquick_creation/test.py index 584235282fa..3eda2c6e0ee 100644 --- a/tests/system/suite_qtquick/tst_qtquick_creation/test.py +++ b/tests/system/suite_qtquick/tst_qtquick_creation/test.py @@ -34,7 +34,6 @@ def main(): for qtVersion, controls in available: targ = [Targets.DESKTOP_5_6_1_DEFAULT] - quick = "2.6" # using a temporary directory won't mess up a potentially existing workingDir = tempDir() checkedTargets = createNewQtQuickApplication(workingDir, targets=targ, diff --git a/tests/system/suite_tools/tst_git_local/test.py b/tests/system/suite_tools/tst_git_local/test.py index 0206885fa28..4998c393e03 100644 --- a/tests/system/suite_tools/tst_git_local/test.py +++ b/tests/system/suite_tools/tst_git_local/test.py @@ -92,7 +92,7 @@ def __clickCommit__(count): test.fail("Could not find the %d. commit - leaving test" % count) return False placeCursorToLine(gitEditor, line) - for i in range(30): + for _ in range(30): type(gitEditor, "") # get the current cursor rectangle which should be positioned on the commit ID rect = gitEditor.cursorRect() @@ -234,7 +234,7 @@ def deleteProject(): if os.path.exists(path): try: # Make files in .git writable to remove them - for root, dirs, files in os.walk(path): + for root, _, files in os.walk(path): for name in files: os.chmod(os.path.join(root, name), stat.S_IWUSR) shutil.rmtree(path) -- cgit v1.2.3