From b7b4e9dc237821ee9954d39e538b76eb243889bb Mon Sep 17 00:00:00 2001 From: Alvaro Laserna Date: Thu, 11 Jul 2024 16:06:18 +0300 Subject: [PATCH 1/3] add deprecation notice for touch actions --- testui/support/testui_driver.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testui/support/testui_driver.py b/testui/support/testui_driver.py index c075571..4acdf67 100644 --- a/testui/support/testui_driver.py +++ b/testui/support/testui_driver.py @@ -9,6 +9,7 @@ from appium.webdriver.webdriver import WebDriver from selenium.webdriver import ActionChains from selenium.common.exceptions import WebDriverException +from warnings import deprecated from testui.elements.testui_element import e from testui.support import logger @@ -120,6 +121,7 @@ def remove_log_file(self, when_no_errors=True): logger.log_debug("Log file already removed") return self + @deprecated("use actions() instead") def touch_actions(self) -> TouchAction: """ Deprecated function, soon to be removed, use actions instead. From 6d00b59e9cbac28cd3cac46d6f3f726b6fc1e733 Mon Sep 17 00:00:00 2001 From: Alvaro Laserna Date: Thu, 11 Jul 2024 16:17:58 +0300 Subject: [PATCH 2/3] fix deprecated method --- testui/support/testui_driver.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/testui/support/testui_driver.py b/testui/support/testui_driver.py index 4acdf67..ed01bb0 100644 --- a/testui/support/testui_driver.py +++ b/testui/support/testui_driver.py @@ -1,5 +1,6 @@ import base64 import os +import warnings from datetime import datetime from os import path @@ -9,7 +10,6 @@ from appium.webdriver.webdriver import WebDriver from selenium.webdriver import ActionChains from selenium.common.exceptions import WebDriverException -from warnings import deprecated from testui.elements.testui_element import e from testui.support import logger @@ -18,6 +18,18 @@ from testui.support.configuration import Configuration +def deprecated(message): + def decorator(func): + def wrapper(*args, **kwargs): + warnings.warn( + f"{func.__name__} is deprecated: {message}", + category=DeprecationWarning, + stacklevel=2 + ) + return func(*args, **kwargs) + return wrapper + return decorator + class TestUIDriver: """ This class is the main class for the TestUI framework. It is used to @@ -121,7 +133,7 @@ def remove_log_file(self, when_no_errors=True): logger.log_debug("Log file already removed") return self - @deprecated("use actions() instead") + @deprecated("This method is deprecated and will be removed in a future version. Use actions() instead") def touch_actions(self) -> TouchAction: """ Deprecated function, soon to be removed, use actions instead. From adddee6a2269c3de200960211d02f46af70002aa Mon Sep 17 00:00:00 2001 From: Alvaro Laserna Date: Thu, 11 Jul 2024 16:18:22 +0300 Subject: [PATCH 3/3] fix formatting --- testui/support/testui_driver.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/testui/support/testui_driver.py b/testui/support/testui_driver.py index ed01bb0..c18a126 100644 --- a/testui/support/testui_driver.py +++ b/testui/support/testui_driver.py @@ -27,9 +27,12 @@ def wrapper(*args, **kwargs): stacklevel=2 ) return func(*args, **kwargs) + return wrapper + return decorator + class TestUIDriver: """ This class is the main class for the TestUI framework. It is used to @@ -226,12 +229,12 @@ def network_connection(self) -> int: return self.driver.network_connection def find_image_match( - self, - comparison, - threshold=0.90, - assertion=False, - not_found=False, - image_match="", + self, + comparison, + threshold=0.90, + assertion=False, + not_found=False, + image_match="", ) -> bool: """ Will find an image match based on the comparison type and threshold @@ -490,13 +493,13 @@ def stop_recording_screen(self, file_name="testui-video.mp4"): return self def stop_recording_and_compare( - self, - comparison, - threshold=0.9, - fps_reduction=1, - not_found=False, - keep_image_as="", - assertion=True, + self, + comparison, + threshold=0.9, + fps_reduction=1, + not_found=False, + keep_image_as="", + assertion=True, ) -> bool: """ Stop recording the screen and compare the video with the given image