diff --git a/test/gui/shared/scripts/bdd_hooks.py b/test/gui/shared/scripts/bdd_hooks.py index 5b4334ef3f9..78485926a2d 100644 --- a/test/gui/shared/scripts/bdd_hooks.py +++ b/test/gui/shared/scripts/bdd_hooks.py @@ -119,6 +119,12 @@ def hook(context): @OnScenarioEnd def hook(context): + # close socket connection + global socketConnect + if(socketConnect): + socketConnect.connected = False + socketConnect._sock.close() + # Currently, this workaround is needed because we cannot find out a way to determine the pass/fail status of currently running test scenario. # And, resultCount("errors") and resultCount("fails") return the total number of error/failed test scenarios of a test suite. global previousFailResultCount diff --git a/test/gui/shared/steps/steps.py b/test/gui/shared/steps/steps.py index 950d9beb051..4e7673061a1 100644 --- a/test/gui/shared/steps/steps.py +++ b/test/gui/shared/steps/steps.py @@ -27,7 +27,7 @@ # to switch from the built-in interpreter see https://kb.froglogic.com/squish/howto/using-external-python-interpreter-squish-6-6/ # if the IDE fails to reference the script, add the folder in Edit->Preferences->PyDev->Interpreters->Libraries sys.path.append(os.path.realpath('../../../shell_integration/nautilus/')) -import syncstate +from syncstate import SocketConnect import functools @@ -142,11 +142,18 @@ def step(context): newAccount.addAccountCredential(context) +def getSocketConnection(): + global socketConnect + if not socketConnect or not socketConnect.connected: + socketConnect = SocketConnect() + return socketConnect + + # Using socket API to check file sync status def hasSyncStatus(type, itemName, status): if type != 'FILE' and type != 'FOLDER': raise Exception("type must be 'FILE' or 'FOLDER'") - socketConnect = syncstate.SocketConnect() + socketConnect = getSocketConnection() socketConnect.sendCommand("RETRIEVE_" + type + "_STATUS:" + itemName + "\n") if not socketConnect.read_socket_data_with_timeout(0.1): @@ -282,7 +289,7 @@ def sanitizePath(path): def shareResource(resource): - socketConnect = syncstate.SocketConnect() + socketConnect = getSocketConnection() socketConnect.sendCommand("SHARE:" + resource + "\n") if not socketConnect.read_socket_data_with_timeout(0.1): return False @@ -376,7 +383,7 @@ def collaboratorShouldBeListed( context, receiver, resource, permissions, receiverCount=0 ): resource = getResourcePath(context, resource) - socketConnect = syncstate.SocketConnect() + socketConnect = getSocketConnection() socketConnect.sendCommand("SHARE:" + resource + "\n") permissionsList = permissions.split(',')