Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions script/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_current_version():
current = (
io.open(os.path.join(os.path.dirname('__file__'), 'appium', 'version.py'), encoding='utf-8').read().rstrip()
)
print('The current version is {}, type a new one'.format(MESSAGE_YELLOW.format(current)))
print(f'The current version is {MESSAGE_YELLOW.format(current)}, type a new one')
return current


Expand All @@ -51,72 +51,72 @@ def get_new_version():

def update_version_file(version):
new_version = VERSION_FORMAT.format(version)
with open(VERSION_FILE_PATH, 'w') as f:
with open(VERSION_FILE_PATH, 'w', encoding="utf-8") as f:
f.write(new_version)


def call_bash_script(cmd):
if os.environ.get('DRY_RUN') is not None:
print('{} Calls: {}'.format(MESSAGE_RED.format('[DRY_RUN]'), cmd))
print(f"{MESSAGE_RED.format('[DRY_RUN]')} Calls: {cmd}")
else:
os.system(cmd)


def commit_version_code(new_version_num):
call_bash_script('git commit {} -m "Bump {}"'.format(VERSION_FILE_PATH, new_version_num))
call_bash_script(f'git commit {VERSION_FILE_PATH} -m "Bump {new_version_num}"')


def tag_and_generate_changelog(new_version_num):
call_bash_script('git tag "v{}"'.format(new_version_num))
call_bash_script('gitchangelog > {}'.format(CHANGELOG_PATH))
call_bash_script('git commit {} -m "Update changelog for {}"'.format(CHANGELOG_PATH, new_version_num))
call_bash_script(f'git tag "v{new_version_num}"')
call_bash_script(f'gitchangelog > {CHANGELOG_PATH}')
call_bash_script(f'git commit {CHANGELOG_PATH} -m "Update changelog for {new_version_num}"')


def upload_sdist(new_version_num):
push_file = 'dist/Appium-Python-Client-{}.tar.gz'.format(new_version_num)
push_file = f'dist/Appium-Python-Client-{new_version_num}.tar.gz'
try:
call_bash_script('twine upload "{}"'.format(push_file))
call_bash_script(f'twine upload "{push_file}"')
except Exception as e:
print(
'Failed to upload {} to pypi. '
'Please fix the original error and push it again later. Original error: {}'.format(push_file, e)
f'Failed to upload {push_file} to pypi. '
f'Please fix the original error and push it again later. Original error: {e}'
)


def push_changes_to_master(new_version_num):
call_bash_script('git push origin master')
call_bash_script('git push origin "v{}"'.format(new_version_num))
call_bash_script(f'git push origin "v{new_version_num}"')


def ensure_publication(new_version_num):
if os.environ.get('DRY_RUN') is not None:
print('Run with {} mode.'.format(MESSAGE_RED.format('[DRY_RUN]')))
print(f"Run with {MESSAGE_RED.format('[DRY_RUN]')} mode.")

print('Are you sure to release as {}?[y/n]'.format(MESSAGE_YELLOW.format(new_version_num)))
print(f'Are you sure to release as {MESSAGE_YELLOW.format(new_version_num)}?[y/n]')
for line in sys.stdin:
if line.rstrip().lower() == 'y':
return
exit('Canceled release process.')
sys.exit('Canceled release process.')


def build_sdist():
call_bash_script('{} setup.py sdist'.format(sys.executable))
call_bash_script(f'{sys.executable} setup.py sdist')


def validate_release_env():
if os.system('which twine') != 0:
exit("Please get twine via 'pip install twine'")
sys.exit("Please get twine via 'pip install twine'")
if os.system('which gitchangelog') != 0:
exit(
sys.exit(
"Please get twine via 'pip install gitchangelog' or 'pip install git+git://github.com/vaab/gitchangelog.git' for Python 3.7"
)


def build() -> None:
shutil.rmtree(BUILT_APPIUM_DIR_PATH, ignore_errors=True)
status, output = subprocess.getstatusoutput('{} setup.py install'.format(os.getenv('PYTHON_BIN_PATH')))
status, output = subprocess.getstatusoutput(f"{os.getenv('PYTHON_BIN_PATH')} setup.py install")
if status != 0:
exit(f'Failed to build the package:\n{output}')
sys.exit(f'Failed to build the package:\n{output}')


def get_py_files_in_dir(root_dir: str) -> List[str]:
Expand Down Expand Up @@ -144,7 +144,7 @@ def assert_files_count_in_package() -> None:
if diff:
print(f"{BUILT_APPIUM_DIR_PATH} has {diff} files than {APPIUM_DIR_PATH}")

exit(
sys.exit(
f"Python files in '{BUILT_APPIUM_DIR_PATH}' may differ from '{APPIUM_DIR_PATH}'. "
"Please make sure setup.py is configured properly."
)
Expand Down
6 changes: 3 additions & 3 deletions test/functional/android/applications_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ def test_app_management(self) -> None:

def test_app_strings(self) -> None:
strings = self.driver.app_strings()
assert u'You can\'t wipe my data, you are a monkey!' == strings[u'monkey_wipe_data']
assert 'You can\'t wipe my data, you are a monkey!' == strings['monkey_wipe_data']

def test_app_strings_with_language(self) -> None:
strings = self.driver.app_strings('en')
assert u'You can\'t wipe my data, you are a monkey!' == strings[u'monkey_wipe_data']
assert 'You can\'t wipe my data, you are a monkey!' == strings['monkey_wipe_data']

def test_app_strings_with_language_and_file(self) -> None:
strings = self.driver.app_strings('en', 'some_file')
assert u'You can\'t wipe my data, you are a monkey!' == strings[u'monkey_wipe_data']
assert 'You can\'t wipe my data, you are a monkey!' == strings['monkey_wipe_data']

def test_reset(self) -> None:
self.driver.reset()
Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/chrome_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from .helper.desired_capabilities import get_desired_capabilities


class TestChrome(object):
class TestChrome():
def setup_method(self) -> None:
caps = get_desired_capabilities()
caps['browserName'] = 'Chrome'
Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/context_switching_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


@pytest.mark.skip(reason="Need to fix broken test")
class TestContextSwitching(object):
class TestContextSwitching():
def setup_method(self) -> None:
caps = desired_capabilities.get_desired_capabilities('selendroid-test-app.apk')
self.driver = webdriver.Remote(SERVER_URL_BASE, options=AppiumOptions().load_capabilities(caps))
Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/remote_fs_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_push_pull_file(self) -> None:
assert data == data_ret

def test_pull_folder(self) -> None:
data = bytes('random string data {}'.format(random.randint(0, 1000)), 'utf-8')
data = bytes(f'random string data {random.randint(0, 1000)}', 'utf-8')
dest_dir = '/data/local/tmp/'

for filename in ['1.txt', '2.txt']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from test.helpers.constants import SERVER_URL_BASE


class TestFindByImage(object):
class TestFindByImage():
def setup_method(self) -> None:
caps = desired_capabilities.get_desired_capabilities('ApiDemos-debug.apk.zip')
self.driver = webdriver.Remote(SERVER_URL_BASE, options=AppiumOptions().load_capabilities(caps))
Expand Down
12 changes: 6 additions & 6 deletions test/functional/android/touch_action_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ def test_drag_and_drop(self) -> None:
el = wait_for_element(self.driver, AppiumBy.ACCESSIBILITY_ID, 'Drag and Drop')
action.tap(el).perform()

dd3 = wait_for_element(self.driver, AppiumBy.ID, '{}:id/drag_dot_3'.format(APIDEMO_PKG_NAME))
dd2 = self.driver.find_element(by=AppiumBy.ID, value='{}:id/drag_dot_2'.format(APIDEMO_PKG_NAME))
dd3 = wait_for_element(self.driver, AppiumBy.ID, f'{APIDEMO_PKG_NAME}:id/drag_dot_3')
dd2 = self.driver.find_element(by=AppiumBy.ID, value=f'{APIDEMO_PKG_NAME}:id/drag_dot_2')

# dnd is stimulated by longpress-move_to-release
action.long_press(dd3).move_to(dd2).release().perform()

el = wait_for_element(self.driver, AppiumBy.ID, '{}:id/drag_result_text'.format(APIDEMO_PKG_NAME))
el = wait_for_element(self.driver, AppiumBy.ID, f'{APIDEMO_PKG_NAME}:id/drag_result_text')
assert 'Dropped!' in el.text

def test_driver_drag_and_drop(self) -> None:
Expand All @@ -147,12 +147,12 @@ def test_driver_drag_and_drop(self) -> None:
el = wait_for_element(self.driver, AppiumBy.ACCESSIBILITY_ID, 'Drag and Drop')
action.tap(el).perform()

dd3 = wait_for_element(self.driver, AppiumBy.ID, '{}:id/drag_dot_3'.format(APIDEMO_PKG_NAME))
dd2 = self.driver.find_element(by=AppiumBy.ID, value='{}:id/drag_dot_2'.format(APIDEMO_PKG_NAME))
dd3 = wait_for_element(self.driver, AppiumBy.ID, f'{APIDEMO_PKG_NAME}:id/drag_dot_3')
dd2 = self.driver.find_element(by=AppiumBy.ID, value=f'{APIDEMO_PKG_NAME}:id/drag_dot_2')

self.driver.drag_and_drop(dd3, dd2)

el = wait_for_element(self.driver, AppiumBy.ID, '{}:id/drag_result_text'.format(APIDEMO_PKG_NAME))
el = wait_for_element(self.driver, AppiumBy.ID, f'{APIDEMO_PKG_NAME}:id/drag_result_text')
assert 'Dropped!' in el.text

def test_driver_swipe(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/webelement_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_send_keys(self) -> None:
for text in ['App', 'Activity', 'Custom Title']:
wait_for_element(self.driver, AppiumBy.XPATH, f"//android.widget.TextView[@text='{text}']").click()

el = wait_for_element(self.driver, AppiumBy.ID, '{}:id/left_text_edit'.format(APIDEMO_PKG_NAME))
el = wait_for_element(self.driver, AppiumBy.ID, f'{APIDEMO_PKG_NAME}:id/left_text_edit')
el.send_keys(' text')

assert 'Left is best text' == el.text
2 changes: 1 addition & 1 deletion test/functional/ios/helper/desired_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def iphone_device_name() -> str:
prefix = 'iPhone 12'
if PytestXdistWorker.NUMBER == PytestXdistWorker.gw(0):
return f'{prefix} - 8100'
elif PytestXdistWorker.NUMBER == PytestXdistWorker.gw(1):
if PytestXdistWorker.NUMBER == PytestXdistWorker.gw(1):
return f'{prefix} - 8101'

return prefix
2 changes: 1 addition & 1 deletion test/functional/ios/helper/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from . import desired_capabilities


class BaseTestCase(object):
class BaseTestCase():
def setup_method(self) -> None:
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
self.driver = webdriver.Remote(SERVER_URL_BASE, options=XCUITestOptions().load_capabilities(desired_caps))
Expand Down
2 changes: 1 addition & 1 deletion test/functional/mac/helper/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .desired_capabilities import get_desired_capabilities


class BaseTestCase(object):
class BaseTestCase():
def setup_method(self) -> None:
self.driver = webdriver.Remote(
SERVER_URL_BASE, options=Mac2Options().load_capabilities(get_desired_capabilities())
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body


class TestWebDriverApp(object):
class TestWebDriverApp():
@httpretty.activate
def test_reset(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/appium_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
from appium.webdriver.appium_service import AppiumService


class TestAppiumService(object):
class TestAppiumService():
def test_get_instance(self):
assert AppiumService()
2 changes: 1 addition & 1 deletion test/unit/webdriver/context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command


class TestWebDriverContext(object):
class TestWebDriverContext():
@httpretty.activate
def test_get_contexts(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/activities_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body


class TestWebDriverActivities(object):
class TestWebDriverActivities():
@httpretty.activate
def test_start_activity(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/clipboard_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body, ios_w3c_driver


class TestWebDriverClipboard(object):
class TestWebDriverClipboard():
@httpretty.activate
def test_set_clipboard_with_url(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command


class TestWebDriverCommon(object):
class TestWebDriverCommon():
@httpretty.activate
def test_open_notifications(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/device_time_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body


class TestWebDriverDeviceTime(object):
class TestWebDriverDeviceTime():
@httpretty.activate
def test_device_time(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/display_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command


class TestWebDriverDisplay(object):
class TestWebDriverDisplay():
@httpretty.activate
def test_get_display_density(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/fingerprint_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body


class TestWebDriverFingerprint(object):
class TestWebDriverFingerprint():
@httpretty.activate
def test_finger_print(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/gsm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body


class TestWebDriveGsm(object):
class TestWebDriveGsm():
@httpretty.activate
def test_make_gsm_call(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/keyboard_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body


class TestWebDriverKeyboard(object):
class TestWebDriverKeyboard():
@httpretty.activate
def test_hide_keyboard(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/location_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
FLT_EPSILON = 1e-9


class TestWebDriverLocation(object):
class TestWebDriverLocation():
@httpretty.activate
def test_toggle_location_services(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/lock_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body


class TestWebDriverLock(object):
class TestWebDriverLock():
@httpretty.activate
def test_lock(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/power_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body


class TestWebDriverPower(object):
class TestWebDriverPower():
@httpretty.activate
def test_set_power_capacity(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/remote_fs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body


class TestWebDriverRemoteFs(object):
class TestWebDriverRemoteFs():
@httpretty.activate
def test_push_file(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/shake_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command


class TestWebDriverShake(object):
class TestWebDriverShake():
@httpretty.activate
def test_shake(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/sms_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body


class TestWebDriverSms(object):
class TestWebDriverSms():
@httpretty.activate
def test_send_sms(self):
driver = android_w3c_driver()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/device/system_bars_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from test.unit.helper.test_helper import android_w3c_driver, appium_command


class TestWebDriverSystemBars(object):
class TestWebDriverSystemBars():
@httpretty.activate
def test_get_system_bars(self):
driver = android_w3c_driver()
Expand Down
Loading