From 7cc5376f0dbbcb2a2b8ba7e93373d9d4613e1e2d Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Fri, 27 Jul 2018 15:32:44 +0200 Subject: Squish: Fix handling of server issues in tst_codepasting Change-Id: I35d8dbeb11be104a1af2956125a29c4606c7e050 Reviewed-by: Christian Stenger --- tests/system/suite_tools/tst_codepasting/test.py | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'tests/system/suite_tools/tst_codepasting/test.py') diff --git a/tests/system/suite_tools/tst_codepasting/test.py b/tests/system/suite_tools/tst_codepasting/test.py index 998b36bf84..160353b2c5 100644 --- a/tests/system/suite_tools/tst_codepasting/test.py +++ b/tests/system/suite_tools/tst_codepasting/test.py @@ -43,15 +43,20 @@ def invalidPasteId(protocol): return -1 def closeHTTPStatusAndPasterDialog(protocol, pasterDialog): - mBoxStr = "{type='QMessageBox' unnamed='1' visible='1' windowTitle?='%s *'}" % protocol - mBox = waitForObject(mBoxStr, 1000) - text = str(mBox.text) - # close message box and paster window - clickButton("{type='QPushButton' text='Cancel' visible='1' window=%s}" % mBoxStr) - clickButton("{type='QPushButton' text='Cancel' visible='1' window='%s'}" % pasterDialog) - if 'Service Unavailable' in text: - test.warning(text) - return True + try: + mBoxStr = "{type='QMessageBox' unnamed='1' visible='1' windowTitle?='%s *'}" % protocol + mBox = waitForObject(mBoxStr, 1000) + text = str(mBox.text) + # close message box and paster window + clickButton("{type='QPushButton' text='Cancel' visible='1' window=%s}" % mBoxStr) + clickButton("{type='QPushButton' text='Cancel' visible='1' window='%s'}" % pasterDialog) + if 'Service Unavailable' in text: + test.warning(text) + return True + except: + t,v = sys.exc_info()[:2] + test.warning("An exception occurred in closeHTTPStatusAndPasterDialog(): %s(%s)" + % (str(t), str(v))) test.log("Closed dialog without expected error.", text) return False @@ -90,11 +95,9 @@ def pasteFile(sourceFile, protocol): output = str(outputWindow.plainText).splitlines()[-1] except: output = "" - try: - if closeHTTPStatusAndPasterDialog(protocol, ':Send to Codepaster_CodePaster::PasteView'): - raise Exception(serverProblems) - except: - pass + if closeHTTPStatusAndPasterDialog(protocol, ':Send to Codepaster_CodePaster::PasteView'): + resetFiles() + raise Exception(serverProblems) stdErrOut = aut.readStderr() match = re.search("^%s protocol error: (.*)$" % protocol, stdErrOut, re.MULTILINE) if match: @@ -123,11 +126,8 @@ def fetchSnippet(protocol, description, pasteId, skippedPasting): try: pasteModel = waitForObject(":PasteSelectDialog.listWidget_QListWidget").model() except: - try: - if closeHTTPStatusAndPasterDialog(protocol, ':PasteSelectDialog_CodePaster::PasteSelectDialog'): - return -1 - except: - pass + closeHTTPStatusAndPasterDialog(protocol, ':PasteSelectDialog_CodePaster::PasteSelectDialog') + return -1 waitFor("pasteModel.rowCount() > 1", 20000) if (not skippedPasting and not protocol == NAME_PBCA and not any(map(lambda str:pasteId in str, dumpItems(pasteModel)))): -- cgit v1.2.3