Add travis to run pylint and unit tests by KazuCocoa · Pull Request #239 · appium/python-client · GitHub
Skip to content
Merged
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
553 changes: 553 additions & 0 deletions .pylintrc

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions .travis.yml
11 changes: 7 additions & 4 deletions appium/saucetestcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: disable=import-error,no-member

from __future__ import print_function

import unittest
import os
import sys
Expand All @@ -28,8 +32,8 @@ def decorator(base_class):
module = sys.modules[base_class.__module__].__dict__
for i, platform in enumerate(platforms):
name = "%s_%s" % (base_class.__name__, i + 1)
d = {'desired_capabilities' : platform}
module[name] = type(name, (base_class,), d)
d_caps = {'desired_capabilities' : platform}
module[name] = type(name, (base_class,), d_caps)
return decorator


Expand All @@ -42,7 +46,7 @@ def setUp(self):
command_executor=sauce_url % (SAUCE_USERNAME, SAUCE_ACCESS_KEY)
)
self.driver.implicitly_wait(30)

def tearDown(self):
print("Link to your job: https://saucelabs.com/jobs/%s" % self.driver.session_id)
try:
Expand All @@ -52,4 +56,3 @@ def tearDown(self):
sauce.jobs.update_job(self.driver.session_id, passed=False)
finally:
self.driver.quit()

3 changes: 1 addition & 2 deletions appium/webdriver/common/multi_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,4 @@ def json_wire_gestures(self):
actions.append(action.json_wire_gestures)
if self._element is not None:
return {'actions': actions, 'elementId': self._element.id}
else:
return {'actions': actions}
return {'actions': actions}
4 changes: 3 additions & 1 deletion appium/webdriver/common/touch_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#
# Theirs is `TouchActions`. Appium's is `TouchAction`.

# pylint: disable=no-self-use

import copy

from appium.webdriver.mobilecommand import MobileCommand as Command
Expand Down Expand Up @@ -112,7 +114,7 @@ def _add_action(self, action, options):
}
self._actions.append(gesture)

def _get_opts(self, element, x, y, duration = None):
def _get_opts(self, element, x, y, duration=None):
opts = {}
if element is not None:
opts['element'] = element.id
Expand Down
1 change: 0 additions & 1 deletion appium/webdriver/errorhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ def check_response(self, response):
raise NoSuchContextException(wde.msg, wde.screen, wde.stacktrace)
else:
raise wde

5 changes: 3 additions & 2 deletions appium/webdriver/imagelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import math
# pylint: disable=no-self-use

import math

class ImageElement:
class ImageElement(object):

def __init__(self, driver, x, y, width, height):
self.driver = driver
Expand Down
43 changes: 23 additions & 20 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from selenium import webdriver
# pylint: disable=too-many-lines,too-many-public-methods,too-many-statements,no-self-use

from .mobilecommand import MobileCommand as Command
from .errorhandler import MobileErrorHandler
from .switch_to import MobileSwitchTo
from .webelement import WebElement as MobileWebElement
from .imagelement import ImageElement
import base64
import copy

from appium.webdriver.clipboard_content_type import ClipboardContentType
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction
from selenium import webdriver

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import (TimeoutException,
WebDriverException, InvalidArgumentException, NoSuchElementException)
from selenium.common.exceptions import (TimeoutException, WebDriverException, InvalidArgumentException, NoSuchElementException)

from selenium.webdriver.remote.command import Command as RemoteCommand

import base64
import copy
from appium.webdriver.clipboard_content_type import ClipboardContentType
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction

from .mobilecommand import MobileCommand as Command
from .errorhandler import MobileErrorHandler
from .switch_to import MobileSwitchTo
from .webelement import WebElement as MobileWebElement
from .imagelement import ImageElement

DEFAULT_MATCH_THRESHOLD = 0.5

Expand Down Expand Up @@ -387,29 +388,29 @@ def find_elements_by_image(self, png_img_path,
pass
return els

def find_element_by_accessibility_id(self, id):
def find_element_by_accessibility_id(self, accessibility_id):
"""Finds an element by accessibility id.

:Args:
- id - a string corresponding to a recursive element search using the
- accessibility_id - a string corresponding to a recursive element search using the
Id/Name that the native Accessibility options utilize

:Usage:
driver.find_element_by_accessibility_id()
"""
return self.find_element(by=By.ACCESSIBILITY_ID, value=id)
return self.find_element(by=By.ACCESSIBILITY_ID, value=accessibility_id)

def find_elements_by_accessibility_id(self, id):
def find_elements_by_accessibility_id(self, accessibility_id):
"""Finds elements by accessibility id.

:Args:
- id - a string corresponding to a recursive element search using the
- accessibility_id - a string corresponding to a recursive element search using the
Id/Name that the native Accessibility options utilize

:Usage:
driver.find_elements_by_accessibility_id()
"""
return self.find_elements(by=By.ACCESSIBILITY_ID, value=id)
return self.find_elements(by=By.ACCESSIBILITY_ID, value=accessibility_id)

def create_web_element(self, element_id):
"""
Expand Down Expand Up @@ -1376,6 +1377,8 @@ def battery_info(self):
"""
return self.execute_script('mobile: batteryInfo')


# pylint: disable=protected-access
def _addCommands(self):
self.command_executor._commands[Command.CONTEXTS] = \
('GET', '/session/$sessionId/contexts')
Expand Down
15 changes: 7 additions & 8 deletions appium/webdriver/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .mobilecommand import MobileCommand as Command

from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement as SeleniumWebElement

from .mobilecommand import MobileCommand as Command

class WebElement(SeleniumWebElement):
def find_element_by_ios_uiautomation(self, uia_string):
Expand Down Expand Up @@ -107,29 +106,29 @@ def find_elements_by_android_uiautomator(self, uia_string):
"""
return self.find_elements(by=By.ANDROID_UIAUTOMATOR, value=uia_string)

def find_element_by_accessibility_id(self, id):
def find_element_by_accessibility_id(self, accessibility_id):
"""Finds an element by accessibility id.

:Args:
- id - a string corresponding to a recursive element search using the
- accessibility_id - a string corresponding to a recursive element search using the
Id/Name that the native Accessibility options utilize

:Usage:
driver.find_element_by_accessibility_id()
"""
return self.find_element(by=By.ACCESSIBILITY_ID, value=id)
return self.find_element(by=By.ACCESSIBILITY_ID, value=accessibility_id)

def find_elements_by_accessibility_id(self, id):
def find_elements_by_accessibility_id(self, accessibility_id):
"""Finds elements by accessibility id.

:Args:
- id - a string corresponding to a recursive element search using the
- accessibility_id - a string corresponding to a recursive element search using the
Id/Name that the native Accessibility options utilize

:Usage:
driver.find_elements_by_accessibility_id()
"""
return self.find_elements(by=By.ACCESSIBILITY_ID, value=id)
return self.find_elements(by=By.ACCESSIBILITY_ID, value=accessibility_id)

def set_text(self, keys=''):
"""Sends text to the element. Previous text is removed.
Expand Down
3 changes: 3 additions & 0 deletions ci-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
astroid
isort
pylint
3 changes: 1 addition & 2 deletions test/unit/multi_action_tests.py