From 3b5a7d233335177ad51e15aaa26bda646fa41f2f Mon Sep 17 00:00:00 2001 From: Atsushi Mori Date: Sat, 25 Jan 2020 02:31:25 +0900 Subject: [PATCH 1/5] Removed unused import --- appium/saucetestcase.py | 2 +- appium/webdriver/extensions/android/display.py | 2 -- appium/webdriver/extensions/android/network.py | 4 ++-- appium/webdriver/extensions/clipboard.py | 2 +- appium/webdriver/extensions/location.py | 2 +- .../extensions/search_context/base_search_context.py | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/appium/saucetestcase.py b/appium/saucetestcase.py index a2e94aba..754146fb 100644 --- a/appium/saucetestcase.py +++ b/appium/saucetestcase.py @@ -19,7 +19,7 @@ import os import sys import unittest -from typing import Any, Callable, List +from typing import Callable, List from sauceclient import SauceClient diff --git a/appium/webdriver/extensions/android/display.py b/appium/webdriver/extensions/android/display.py index 73ac1ccb..f07c0875 100644 --- a/appium/webdriver/extensions/android/display.py +++ b/appium/webdriver/extensions/android/display.py @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import TypeVar - from selenium import webdriver from appium.webdriver.mobilecommand import MobileCommand as Command diff --git a/appium/webdriver/extensions/android/network.py b/appium/webdriver/extensions/android/network.py index 99c71763..4d890752 100644 --- a/appium/webdriver/extensions/android/network.py +++ b/appium/webdriver/extensions/android/network.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, TypeVar +from typing import TypeVar from selenium import webdriver @@ -23,7 +23,7 @@ T = TypeVar('T', bound='Network') -class NetSpeed(object): +class NetSpeed: GSM = 'gsm' # GSM/CSD (up: 14.4(kbps), down: 14.4(kbps)) SCSD = 'scsd' # HSCSD (up: 14.4, down: 57.6) GPRS = 'gprs' # GPRS (up: 28.8, down: 57.6) diff --git a/appium/webdriver/extensions/clipboard.py b/appium/webdriver/extensions/clipboard.py index e4f7bc71..02e3f522 100644 --- a/appium/webdriver/extensions/clipboard.py +++ b/appium/webdriver/extensions/clipboard.py @@ -13,7 +13,7 @@ # limitations under the License. import base64 -from typing import Any, Dict, Optional, TypeVar +from typing import Optional, TypeVar from selenium import webdriver diff --git a/appium/webdriver/extensions/location.py b/appium/webdriver/extensions/location.py index 054cf44e..4af21de9 100644 --- a/appium/webdriver/extensions/location.py +++ b/appium/webdriver/extensions/location.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Dict, Optional, TypeVar, Union +from typing import Dict, TypeVar, Union from selenium import webdriver diff --git a/appium/webdriver/extensions/search_context/base_search_context.py b/appium/webdriver/extensions/search_context/base_search_context.py index 404aa62a..e5f6e3cd 100644 --- a/appium/webdriver/extensions/search_context/base_search_context.py +++ b/appium/webdriver/extensions/search_context/base_search_context.py @@ -14,7 +14,7 @@ # pylint: disable=abstract-method -from typing import TYPE_CHECKING, Dict, List, Optional, Union +from typing import TYPE_CHECKING, Dict, List, Union if TYPE_CHECKING: from appium.webdriver.webelement import WebElement From 720affb386c17113b11260bf15ce760c20b2df28 Mon Sep 17 00:00:00 2001 From: Atsushi Mori Date: Sat, 25 Jan 2020 02:40:16 +0900 Subject: [PATCH 2/5] Removed unnecessary codes --- appium/webdriver/appium_service.py | 2 +- appium/webdriver/applicationstate.py | 2 +- appium/webdriver/clipboard_content_type.py | 2 +- appium/webdriver/common/multi_action.py | 2 +- appium/webdriver/common/touch_action.py | 2 +- appium/webdriver/connectiontype.py | 2 +- appium/webdriver/extensions/android/gsm.py | 6 +++--- appium/webdriver/extensions/execute_driver.py | 2 +- .../extensions/search_context/base_search_context.py | 2 +- appium/webdriver/mobilecommand.py | 2 +- test/functional/ios/helper/desired_capabilities.py | 2 +- test/functional/ios/webdriver_tests.py | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/appium/webdriver/appium_service.py b/appium/webdriver/appium_service.py index 7683782a..9c68a9a9 100644 --- a/appium/webdriver/appium_service.py +++ b/appium/webdriver/appium_service.py @@ -67,7 +67,7 @@ class AppiumServiceError(RuntimeError): T = TypeVar('T', bound='AppiumService') -class AppiumService(object): +class AppiumService: def __init__(self) -> None: self._process: Optional[sp.Popen] = None self._cmd: Optional[List] = None diff --git a/appium/webdriver/applicationstate.py b/appium/webdriver/applicationstate.py index e3c255ae..0658b264 100644 --- a/appium/webdriver/applicationstate.py +++ b/appium/webdriver/applicationstate.py @@ -13,7 +13,7 @@ # limitations under the License. -class ApplicationState(object): +class ApplicationState: NOT_INSTALLED = 0 NOT_RUNNING = 1 RUNNING_IN_BACKGROUND_SUSPENDED = 2 diff --git a/appium/webdriver/clipboard_content_type.py b/appium/webdriver/clipboard_content_type.py index 67aac351..7c1211b3 100644 --- a/appium/webdriver/clipboard_content_type.py +++ b/appium/webdriver/clipboard_content_type.py @@ -13,7 +13,7 @@ # limitations under the License. -class ClipboardContentType(object): +class ClipboardContentType: PLAINTEXT = 'plaintext' IMAGE = 'image' URL = 'url' diff --git a/appium/webdriver/common/multi_action.py b/appium/webdriver/common/multi_action.py index f3326534..e6a84cfe 100644 --- a/appium/webdriver/common/multi_action.py +++ b/appium/webdriver/common/multi_action.py @@ -31,7 +31,7 @@ T = TypeVar('T', bound='MultiAction') -class MultiAction(object): +class MultiAction: def __init__(self, driver: 'WebDriver', element: Optional['WebElement'] = None) -> None: self._driver = driver self._element = element diff --git a/appium/webdriver/common/touch_action.py b/appium/webdriver/common/touch_action.py index a8fb299d..a9544063 100644 --- a/appium/webdriver/common/touch_action.py +++ b/appium/webdriver/common/touch_action.py @@ -35,7 +35,7 @@ T = TypeVar('T', bound='TouchAction') -class TouchAction(object): +class TouchAction: def __init__(self, driver: Optional['WebDriver'] = None): self._driver = driver diff --git a/appium/webdriver/connectiontype.py b/appium/webdriver/connectiontype.py index 5a408ba5..7d477680 100644 --- a/appium/webdriver/connectiontype.py +++ b/appium/webdriver/connectiontype.py @@ -26,7 +26,7 @@ """ -class ConnectionType(object): +class ConnectionType: NO_CONNECTION = 0 AIRPLANE_MODE = 1 WIFI_ONLY = 2 diff --git a/appium/webdriver/extensions/android/gsm.py b/appium/webdriver/extensions/android/gsm.py index df4ea95e..fcfa5e4f 100644 --- a/appium/webdriver/extensions/android/gsm.py +++ b/appium/webdriver/extensions/android/gsm.py @@ -21,14 +21,14 @@ from appium.webdriver.mobilecommand import MobileCommand as Command -class GsmCallActions(object): +class GsmCallActions: CALL = 'call' ACCEPT = 'accept' CANCEL = 'cancel' HOLD = 'hold' -class GsmSignalStrength(object): +class GsmSignalStrength: NONE_OR_UNKNOWN = 0 POOR = 1 MODERATE = 2 @@ -36,7 +36,7 @@ class GsmSignalStrength(object): GREAT = 4 -class GsmVoiceState(object): +class GsmVoiceState: UNREGISTERED = 'unregistered' HOME = 'home' ROAMING = 'roaming' diff --git a/appium/webdriver/extensions/execute_driver.py b/appium/webdriver/extensions/execute_driver.py index f6c00fb0..3b3778c3 100644 --- a/appium/webdriver/extensions/execute_driver.py +++ b/appium/webdriver/extensions/execute_driver.py @@ -44,7 +44,7 @@ def execute_driver(self, script: str, script_type: str = 'webdriverio', timeout_ WebDriverException: If something error happenes in the script. The message has the original error message. """ - class Result(object): + class Result: def __init__(self, response: Dict): self.result = response['result'] diff --git a/appium/webdriver/extensions/search_context/base_search_context.py b/appium/webdriver/extensions/search_context/base_search_context.py index e5f6e3cd..317069f0 100644 --- a/appium/webdriver/extensions/search_context/base_search_context.py +++ b/appium/webdriver/extensions/search_context/base_search_context.py @@ -20,7 +20,7 @@ from appium.webdriver.webelement import WebElement -class BaseSearchContext(object): +class BaseSearchContext: """Used by each search context. Dummy find_element/s are for preventing pylint error""" def find_element(self, by: str, value: Union[str, Dict] = None) -> 'WebElement': diff --git a/appium/webdriver/mobilecommand.py b/appium/webdriver/mobilecommand.py index f6d90679..b0bd8c4d 100644 --- a/appium/webdriver/mobilecommand.py +++ b/appium/webdriver/mobilecommand.py @@ -13,7 +13,7 @@ # limitations under the License. -class MobileCommand(object): +class MobileCommand: # Common GET_SESSION = 'getSession' GET_ALL_SESSIONS = 'getAllSessions' diff --git a/test/functional/ios/helper/desired_capabilities.py b/test/functional/ios/helper/desired_capabilities.py index 7a98f61a..b71dd321 100644 --- a/test/functional/ios/helper/desired_capabilities.py +++ b/test/functional/ios/helper/desired_capabilities.py @@ -41,7 +41,7 @@ def get_desired_capabilities(app=None): return desired_caps -class PytestXdistWorker(object): +class PytestXdistWorker: NUMBER = os.getenv('PYTEST_XDIST_WORKER') COUNT = os.getenv('PYTEST_XDIST_WORKER_COUNT') # Return 2 if `-n 2` is passed diff --git a/test/functional/ios/webdriver_tests.py b/test/functional/ios/webdriver_tests.py index 51c7bc58..3d0f113f 100644 --- a/test/functional/ios/webdriver_tests.py +++ b/test/functional/ios/webdriver_tests.py @@ -36,7 +36,7 @@ def test_all_sessions(self): desired_caps['deviceName'] = 'iPhone Xs Max' desired_caps['wdaLocalPort'] = port - class session_counts_is_two(object): + class session_counts_is_two: TIMEOUT = 10 def __call__(self, driver): From 73d4620bdd0f0c1b317c0db3b469565cd28ddad2 Mon Sep 17 00:00:00 2001 From: Atsushi Mori Date: Sat, 25 Jan 2020 19:34:19 +0900 Subject: [PATCH 3/5] Applied f'' format instead ''.format() --- appium/webdriver/appium_service.py | 10 ++++------ appium/webdriver/extensions/android/gsm.py | 12 ++++++------ appium/webdriver/extensions/android/network.py | 4 ++-- appium/webdriver/extensions/remote_fs.py | 2 +- appium/webdriver/webdriver.py | 9 ++------- test/functional/android/common_tests.py | 2 +- test/functional/android/ime_tests.py | 2 +- test/functional/android/log_event_tests.py | 2 +- test/functional/android/webelement_tests.py | 2 +- test/functional/ios/helper/desired_capabilities.py | 2 +- test/functional/test_helper.py | 3 +-- test/unit/helper/test_helper.py | 2 +- test/unit/webdriver/webdriver_test.py | 2 +- 13 files changed, 23 insertions(+), 31 deletions(-) diff --git a/appium/webdriver/appium_service.py b/appium/webdriver/appium_service.py index 9c68a9a9..269f4a34 100644 --- a/appium/webdriver/appium_service.py +++ b/appium/webdriver/appium_service.py @@ -50,8 +50,7 @@ def poll_url(host: str, port: int, path: str, timeout_ms: int) -> bool: while time.time() < time_started_sec + timeout_ms / 1000.0: try: conn = urllib3.PoolManager(timeout=1.0) - resp = conn.request('HEAD', 'http://{host}:{port}{path}'.format( - host=host, port=port, path=path)) + resp = conn.request('HEAD', f'http://{host}:{port}{path}') if resp.status < 400: return True except Exception: @@ -103,7 +102,7 @@ def _get_main_script(self) -> Union[str, bytes]: self._main_script = sp.check_output( [self._get_node(), '-e', - 'console.log(require.resolve("{}"))'.format(MAIN_SCRIPT_PATH)]).strip() + f'console.log(require.resolve("{MAIN_SCRIPT_PATH}"))']).strip() except sp.CalledProcessError as e: raise AppiumServiceError(e.output) return self._main_script @@ -169,13 +168,12 @@ def start(self, **kwargs: Any) -> sp.Popen: port = self._parse_port(args) error_msg: Optional[str] = None if not self.is_running or (timeout_ms > 0 and not poll_url(host, port, STATUS_URL, timeout_ms)): - error_msg = 'Appium has failed to start on {}:{} within {}ms timeout'\ - .format(host, port, timeout_ms) + error_msg = f'Appium has failed to start on {host}:{port} within {timeout_ms}ms timeout' if error_msg is not None: if stderr == sp.PIPE: err_output = self._process.stderr.read() if err_output: - error_msg += '\nOriginal error: {}'.format(str(err_output)) + error_msg += f'\nOriginal error: {str(err_output)}' self.stop() raise AppiumServiceError(error_msg) return self._process diff --git a/appium/webdriver/extensions/android/gsm.py b/appium/webdriver/extensions/android/gsm.py index fcfa5e4f..325ff573 100644 --- a/appium/webdriver/extensions/android/gsm.py +++ b/appium/webdriver/extensions/android/gsm.py @@ -66,8 +66,8 @@ def make_gsm_call(self, phone_number: str, action: str) -> T: """ constants = extract_const_attributes(GsmCallActions) if action not in constants.values(): - logger.warning('{} is unknown. Consider using one of {} constants. (e.g. {}.CALL)'.format( - action, list(constants.keys()), GsmCallActions.__name__)) + logger.warning( + f'{action} is unknown. Consider using one of {list(constants.keys())} constants. (e.g. {GsmCallActions.__name__}.CALL)') self.execute(Command.MAKE_GSM_CALL, {'phoneNumber': phone_number, 'action': action}) return self @@ -85,8 +85,8 @@ def set_gsm_signal(self, strength: int) -> T: """ constants = extract_const_attributes(GsmSignalStrength) if strength not in constants.values(): - logger.warning('{} is out of range. Consider using one of {} constants. (e.g. {}.GOOD)'.format( - strength, list(constants.keys()), GsmSignalStrength.__name__)) + logger.warning( + f'{strength} is out of range. Consider using one of {list(constants.keys())} constants. (e.g. {GsmSignalStrength.__name__}.GOOD)') self.execute(Command.SET_GSM_SIGNAL, {'signalStrength': strength, 'signalStrengh': strength}) return self @@ -104,8 +104,8 @@ def set_gsm_voice(self, state: str) -> T: """ constants = extract_const_attributes(GsmVoiceState) if state not in constants.values(): - logger.warning('{} is unknown. Consider using one of {} constants. (e.g. {}.HOME)'.format( - state, list(constants.keys()), GsmVoiceState.__name__)) + logger.warning( + f'{state} is unknown. Consider using one of {list(constants.keys())} constants. (e.g. {GsmVoiceState.__name__}.HOME)') self.execute(Command.SET_GSM_VOICE, {'state': state}) return self diff --git a/appium/webdriver/extensions/android/network.py b/appium/webdriver/extensions/android/network.py index 4d890752..4f874687 100644 --- a/appium/webdriver/extensions/android/network.py +++ b/appium/webdriver/extensions/android/network.py @@ -98,8 +98,8 @@ def set_network_speed(self, speed_type: str) -> T: """ constants = extract_const_attributes(NetSpeed) if speed_type not in constants.values(): - logger.warning('{} is unknown. Consider using one of {} constants. (e.g. {}.LTE)'.format( - speed_type, list(constants.keys()), NetSpeed.__name__)) + logger.warning( + f'{speed_type} is unknown. Consider using one of {list(constants.keys())} constants. (e.g. {NetSpeed.__name__}.LTE)') self.execute(Command.SET_NETWORK_SPEED, {'netspeed': speed_type}) return self diff --git a/appium/webdriver/extensions/remote_fs.py b/appium/webdriver/extensions/remote_fs.py index dd256a7a..1a80286c 100644 --- a/appium/webdriver/extensions/remote_fs.py +++ b/appium/webdriver/extensions/remote_fs.py @@ -74,7 +74,7 @@ def push_file(self, destination_path: str, with open(source_path, 'rb') as f: file_data = f.read() except IOError: - message = 'source_path {} could not be found. Are you sure the file exists?'.format(source_path) + message = f'source_path {source_path} could not be found. Are you sure the file exists?' raise InvalidArgumentException(message) base64data = base64.b64encode(file_data).decode('utf-8') diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 13e9619f..8b28e4ef 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -185,7 +185,7 @@ def _update_command_executor(self, keep_alive: bool) -> None: if (not {direct_protocol, direct_host, direct_port, direct_path}.issubset(set(self.capabilities))): message = 'Direct connect capabilities from server were:\n' for key in [direct_protocol, direct_host, direct_port, direct_path]: - message += '{}: \'{}\'\n'.format(key, self.capabilities.get(key, '')) + message += f'{key}: \'{self.capabilities.get(key, "")}\'\n' logger.warning(message) return @@ -193,12 +193,7 @@ def _update_command_executor(self, keep_alive: bool) -> None: hostname = self.capabilities[direct_host] port = self.capabilities[direct_port] path = self.capabilities[direct_path] - executor = '{scheme}://{hostname}:{port}{path}'.format( - scheme=protocol, - hostname=hostname, - port=port, - path=path - ) + executor = f'{protocol}://{hostname}:{port}{path}' logger.info('Updated request endpoint to %s', executor) # Override command executor diff --git a/test/functional/android/common_tests.py b/test/functional/android/common_tests.py index cf5ea791..04fb63e8 100644 --- a/test/functional/android/common_tests.py +++ b/test/functional/android/common_tests.py @@ -44,7 +44,7 @@ def test_open_notifications(self): self.skipTest('Need to fix flaky test during running on CI.') for word in ['App', 'Notification', 'Status Bar', ':-|']: wait_for_element(self.driver, MobileBy.ANDROID_UIAUTOMATOR, - 'new UiSelector().text("{}")'.format(word)).click() + f'new UiSelector().text("{word}")').click() self.driver.open_notifications() sleep(1) diff --git a/test/functional/android/ime_tests.py b/test/functional/android/ime_tests.py index 86bf7449..263b5a55 100644 --- a/test/functional/android/ime_tests.py +++ b/test/functional/android/ime_tests.py @@ -40,7 +40,7 @@ def test_activate_ime_engine(self): active_engine = self.driver.active_ime_engine self.driver.activate_ime_engine(engines[-1]) - self.assertEqual(self.driver.active_ime_engine, engines[-1]) + self.assertEqual(active_engine, engines[-1]) def test_deactivate_ime_engine(self): engines = self.driver.available_ime_engines diff --git a/test/functional/android/log_event_tests.py b/test/functional/android/log_event_tests.py index 8067e9f7..a64ff9a0 100644 --- a/test/functional/android/log_event_tests.py +++ b/test/functional/android/log_event_tests.py @@ -23,7 +23,7 @@ def test_log_event(self): vendor = 'appium' event = 'funEvent' self.driver.log_event(vendor, event) - assert '{}:{}'.format(vendor, event) in self.driver.get_events().keys() + assert f'{vendor}:{event}' in self.driver.get_events().keys() if __name__ == '__main__': diff --git a/test/functional/android/webelement_tests.py b/test/functional/android/webelement_tests.py index 1a16473b..b936ffc4 100644 --- a/test/functional/android/webelement_tests.py +++ b/test/functional/android/webelement_tests.py @@ -47,7 +47,7 @@ def test_set_text(self): def test_send_keys(self): for text in ['App', 'Activity', 'Custom Title']: wait_for_element(self.driver, MobileBy.XPATH, - "//android.widget.TextView[@text='{}']".format(text)).click() + f"//android.widget.TextView[@text='{text}']").click() el = wait_for_element(self.driver, MobileBy.ID, '{}:id/left_text_edit'.format(APIDEMO_PKG_NAME)) el.send_keys(' text') diff --git a/test/functional/ios/helper/desired_capabilities.py b/test/functional/ios/helper/desired_capabilities.py index b71dd321..12dc982a 100644 --- a/test/functional/ios/helper/desired_capabilities.py +++ b/test/functional/ios/helper/desired_capabilities.py @@ -53,7 +53,7 @@ def gw(number): if number >= PytestXdistWorker.COUNT: return 'gw0' - return 'gw{}'.format(number) + return f'gw{number}' # If you run tests with pytest-xdist, you can run tests in parallel. diff --git a/test/functional/test_helper.py b/test/functional/test_helper.py index a531d053..ee6b6daf 100644 --- a/test/functional/test_helper.py +++ b/test/functional/test_helper.py @@ -20,8 +20,7 @@ def get_available_from_port_range(from_port, to_port): finally: sock.close() - raise NoAvailablePortError('No available port between {} and {}'.format( - from_port, to_port)) + raise NoAvailablePortError(f'No available port between {from_port} and {to_port}') def is_ci(): diff --git a/test/unit/helper/test_helper.py b/test/unit/helper/test_helper.py index f7ff3ca0..4c1b2d07 100644 --- a/test/unit/helper/test_helper.py +++ b/test/unit/helper/test_helper.py @@ -28,7 +28,7 @@ def appium_command(command): Returns: str: A string of command URL """ - return '{}{}'.format(SERVER_URL_BASE, command) + return f'{SERVER_URL_BASE}{command}' def android_w3c_driver(): diff --git a/test/unit/webdriver/webdriver_test.py b/test/unit/webdriver/webdriver_test.py index 40e458d5..cdfd27cc 100644 --- a/test/unit/webdriver/webdriver_test.py +++ b/test/unit/webdriver/webdriver_test.py @@ -52,7 +52,7 @@ def test_create_session(self): request = httpretty.HTTPretty.latest_requests[0] assert request.headers['content-type'] == 'application/json;charset=UTF-8' - assert 'appium/python {} (selenium'.format(appium_version.version) in request.headers['user-agent'] + assert f'appium/python {appium_version.version} (selenium' in request.headers['user-agent'] request_json = json.loads(httpretty.HTTPretty.latest_requests[0].body.decode('utf-8')) assert request_json.get('capabilities') is not None From f1aed65e8a2f5169d413a218aacc3f3d7d838bd8 Mon Sep 17 00:00:00 2001 From: Atsushi Mori Date: Sat, 25 Jan 2020 20:03:28 +0900 Subject: [PATCH 4/5] Fixes --- appium/webdriver/appium_service.py | 2 +- appium/webdriver/webdriver.py | 2 +- test/functional/android/ime_tests.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/appium/webdriver/appium_service.py b/appium/webdriver/appium_service.py index 269f4a34..d2aedadb 100644 --- a/appium/webdriver/appium_service.py +++ b/appium/webdriver/appium_service.py @@ -102,7 +102,7 @@ def _get_main_script(self) -> Union[str, bytes]: self._main_script = sp.check_output( [self._get_node(), '-e', - f'console.log(require.resolve("{MAIN_SCRIPT_PATH}"))']).strip() + 'console.log(require.resolve("{}"))'.format(MAIN_SCRIPT_PATH)]).strip() except sp.CalledProcessError as e: raise AppiumServiceError(e.output) return self._main_script diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 8b28e4ef..3a0512bc 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -185,7 +185,7 @@ def _update_command_executor(self, keep_alive: bool) -> None: if (not {direct_protocol, direct_host, direct_port, direct_path}.issubset(set(self.capabilities))): message = 'Direct connect capabilities from server were:\n' for key in [direct_protocol, direct_host, direct_port, direct_path]: - message += f'{key}: \'{self.capabilities.get(key, "")}\'\n' + message += '{}: \'{}\'\n'.format(key, self.capabilities.get(key, '')) logger.warning(message) return diff --git a/test/functional/android/ime_tests.py b/test/functional/android/ime_tests.py index 263b5a55..6cac0e73 100644 --- a/test/functional/android/ime_tests.py +++ b/test/functional/android/ime_tests.py @@ -37,10 +37,9 @@ def test_active_ime_engine(self): def test_activate_ime_engine(self): engines = self.driver.available_ime_engines - active_engine = self.driver.active_ime_engine self.driver.activate_ime_engine(engines[-1]) - self.assertEqual(active_engine, engines[-1]) + self.assertEqual(self.driver.active_ime_engine, engines[-1]) def test_deactivate_ime_engine(self): engines = self.driver.available_ime_engines From 9168af2fdb6998337f94b1dd4b67fe0247cfb6b6 Mon Sep 17 00:00:00 2001 From: Atsushi Mori Date: Sat, 25 Jan 2020 22:15:11 +0900 Subject: [PATCH 5/5] tweak --- appium/webdriver/extensions/remote_fs.py | 2 +- test/unit/webdriver/webdriver_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appium/webdriver/extensions/remote_fs.py b/appium/webdriver/extensions/remote_fs.py index 1a80286c..4f8ff871 100644 --- a/appium/webdriver/extensions/remote_fs.py +++ b/appium/webdriver/extensions/remote_fs.py @@ -74,7 +74,7 @@ def push_file(self, destination_path: str, with open(source_path, 'rb') as f: file_data = f.read() except IOError: - message = f'source_path {source_path} could not be found. Are you sure the file exists?' + message = f'source_path "{source_path}" could not be found. Are you sure the file exists?' raise InvalidArgumentException(message) base64data = base64.b64encode(file_data).decode('utf-8') diff --git a/test/unit/webdriver/webdriver_test.py b/test/unit/webdriver/webdriver_test.py index cdfd27cc..40e458d5 100644 --- a/test/unit/webdriver/webdriver_test.py +++ b/test/unit/webdriver/webdriver_test.py @@ -52,7 +52,7 @@ def test_create_session(self): request = httpretty.HTTPretty.latest_requests[0] assert request.headers['content-type'] == 'application/json;charset=UTF-8' - assert f'appium/python {appium_version.version} (selenium' in request.headers['user-agent'] + assert 'appium/python {} (selenium'.format(appium_version.version) in request.headers['user-agent'] request_json = json.loads(httpretty.HTTPretty.latest_requests[0].body.decode('utf-8')) assert request_json.get('capabilities') is not None