From d7628892b04d1a1ed47d6d6c355940f9915dcd99 Mon Sep 17 00:00:00 2001 From: Ilmari Lauhakangas Date: Sun, 28 Jul 2024 20:07:43 +0300 Subject: [PATCH] testtools, uitest, unotest: fix issues found by Ruff linter Change-Id: I4a848b0f1f114d1262b5242786e088eb50a33cef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171145 Reviewed-by: Ilmari Lauhakangas Tested-by: Ilmari Lauhakangas Tested-by: Jenkins --- testtools/source/bridgetest/pyuno/core.py | 30 +++++++++---------- .../bridgetest/pyuno/samplecomponent.py | 30 +++++++++---------- uitest/test_main.py | 2 +- uitest/ui_logger_dsl/dsl_core.py | 4 +-- uitest/uitest/uihelper/testDialog.py | 8 ++--- .../source/python/org/libreoffice/unotest.py | 2 +- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/testtools/source/bridgetest/pyuno/core.py b/testtools/source/bridgetest/pyuno/core.py index 5c0ede8888f8..c0c798daa5f4 100644 --- a/testtools/source/bridgetest/pyuno/core.py +++ b/testtools/source/bridgetest/pyuno/core.py @@ -46,21 +46,21 @@ def equalsEps( a,b,eps ): def assign( rData, bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\ nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny ): - rData.Bool = bBool; - rData.Char = cChar; - rData.Byte = nByte; - rData.Short = nShort; - rData.UShort = nUShort; - rData.Long = nLong; - rData.ULong = nULong; - rData.Hyper = nHyper; - rData.UHyper = nUHyper; - rData.Float = fFloat; - rData.Double = fDouble; - rData.Enum = eEnum; - rData.String = rStr; - rData.Interface = xTest; - rData.Any = rAny; + rData.Bool = bBool + rData.Char = cChar + rData.Byte = nByte + rData.Short = nShort + rData.UShort = nUShort + rData.Long = nLong + rData.ULong = nULong + rData.Hyper = nHyper + rData.UHyper = nUHyper + rData.Float = fFloat + rData.Double = fDouble + rData.Enum = eEnum + rData.String = rStr + rData.Interface = xTest + rData.Any = rAny class PythonTransporter: diff --git a/testtools/source/bridgetest/pyuno/samplecomponent.py b/testtools/source/bridgetest/pyuno/samplecomponent.py index 4778a76022e0..1af48bb67876 100644 --- a/testtools/source/bridgetest/pyuno/samplecomponent.py +++ b/testtools/source/bridgetest/pyuno/samplecomponent.py @@ -32,21 +32,21 @@ g_attribs = "RuntimeException", "Bool", "Char", "Byte", "Short", "UShort", \ def assign( rData, bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\ nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny ): - rData.Bool = bBool; - rData.Char = cChar; - rData.Byte = nByte; - rData.Short = nShort; - rData.UShort = nUShort; - rData.Long = nLong; - rData.ULong = nULong; - rData.Hyper = nHyper; - rData.UHyper = nUHyper; - rData.Float = fFloat; - rData.Double = fDouble; - rData.Enum = eEnum; - rData.String = rStr; - rData.Interface = xTest; - rData.Any = rAny; + rData.Bool = bBool + rData.Char = cChar + rData.Byte = nByte + rData.Short = nShort + rData.UShort = nUShort + rData.Long = nLong + rData.ULong = nULong + rData.Hyper = nHyper + rData.UHyper = nUHyper + rData.Float = fFloat + rData.Double = fDouble + rData.Enum = eEnum + rData.String = rStr + rData.Interface = xTest + rData.Any = rAny class MyRecursiveCall( XRecursiveCall, unohelper.Base ): def callRecursivly( xCall, nToCall ): diff --git a/uitest/test_main.py b/uitest/test_main.py index 1957f54dc373..9106d1b8e86a 100644 --- a/uitest/test_main.py +++ b/uitest/test_main.py @@ -116,7 +116,7 @@ if __name__ == '__main__': if "-h" in opts or "--help" in opts: usage() sys.exit() - elif not "--soffice" in opts: + elif "--soffice" not in opts: usage() sys.exit(1) elif "--dir" in opts: diff --git a/uitest/ui_logger_dsl/dsl_core.py b/uitest/ui_logger_dsl/dsl_core.py index 79bd748b54e2..ef0a36273219 100644 --- a/uitest/ui_logger_dsl/dsl_core.py +++ b/uitest/ui_logger_dsl/dsl_core.py @@ -46,7 +46,7 @@ class ul_Compiler: parent_hierarchy_count = 0 last_parent = [] flag_for_QuerySaveDialog = False - math_element_selector_initializer= False; + math_element_selector_initializer= False def __init__(self, input_address, output_address): self.ui_dsl_mm = metamodel_from_file("ui_logger_dsl_grammar.tx") @@ -961,7 +961,7 @@ class ul_Compiler: def handle_math_element_selector(self, math_element_selector): - if( self.math_element_selector_initializer == False ): + if not self.math_element_selector_initializer: # This part is for initializing the element selector in the Math application self.math_element_selector_initializer = True line = ( diff --git a/uitest/uitest/uihelper/testDialog.py b/uitest/uitest/uihelper/testDialog.py index 20d37205d5a2..76b3c2fcc49b 100644 --- a/uitest/uitest/uihelper/testDialog.py +++ b/uitest/uitest/uihelper/testDialog.py @@ -16,14 +16,14 @@ def testAppDialog(UITestCase, app, dialog): with UITestCase.ui_test.create_doc_in_start_center(app): with UITestCase.ui_test.execute_dialog_through_command( dialog['command'], close_button=dialog['closeButton']) as xDialog: - if 'skipTestOK' in dialog and dialog['skipTestOK'] == True: + if 'skipTestOK' in dialog and dialog['skipTestOK']: xOKBtn = None else: try: xOKBtn = xDialog.getChild("ok") if (get_state_as_dict(xOKBtn)["Enabled"] != "true"): xOKBtn = None - except: + except Exception: xOKBtn = None if (xOKBtn is not None): @@ -47,14 +47,14 @@ def testChartDialog(UITestCase, dialog): xObj, "COMMAND", mkPropertyValues({"COMMAND": dialog['command']}), close_button=dialog['closeButton']) as xDialog: - if 'skipTestOK' in dialog and dialog['skipTestOK'] == True: + if 'skipTestOK' in dialog and dialog['skipTestOK']: xOKBtn = None else: try: xOKBtn = xDialog.getChild("ok") if (get_state_as_dict(xOKBtn)["Enabled"] != "true"): xOKBtn = None - except: + except Exception: xOKBtn = None if (xOKBtn is not None): diff --git a/unotest/source/python/org/libreoffice/unotest.py b/unotest/source/python/org/libreoffice/unotest.py index 743e1781de84..e3865fdc0b8e 100644 --- a/unotest/source/python/org/libreoffice/unotest.py +++ b/unotest/source/python/org/libreoffice/unotest.py @@ -265,7 +265,7 @@ def retryInvoke(connection, test): connection.postTest() except KeyboardInterrupt: raise # Ctrl+C should work - except: + except Exception: print("retryInvoke: caught exception") raise Exception("FAILED retryInvoke")