Skip to content

Commit 098581a

Browse files
KazuCocoaimurchie
authored andcommitted
Add travis to run pylint and unit tests (appium#239)
* add pylint * add rcfile * tweak pylint * fix lint * add running pytest * tweak indentations
1 parent ecea948 commit 098581a

11 files changed

Lines changed: 612 additions & 40 deletions

File tree

.pylintrc

Lines changed: 553 additions & 0 deletions
Large diffs are not rendered by default.

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: python
2+
python:
3+
- "2.7"
4+
- "3.7"
5+
6+
install:
7+
- pip install -r ci-requirements.txt
8+
9+
script:
10+
- pylint --rcfile .pylintrc appium test
11+
- pytest test/unit/*

appium/saucetestcase.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# pylint: disable=import-error,no-member
16+
17+
from __future__ import print_function
18+
1519
import unittest
1620
import os
1721
import sys
@@ -28,8 +32,8 @@ def decorator(base_class):
2832
module = sys.modules[base_class.__module__].__dict__
2933
for i, platform in enumerate(platforms):
3034
name = "%s_%s" % (base_class.__name__, i + 1)
31-
d = {'desired_capabilities' : platform}
32-
module[name] = type(name, (base_class,), d)
35+
d_caps = {'desired_capabilities' : platform}
36+
module[name] = type(name, (base_class,), d_caps)
3337
return decorator
3438

3539

@@ -42,7 +46,7 @@ def setUp(self):
4246
command_executor=sauce_url % (SAUCE_USERNAME, SAUCE_ACCESS_KEY)
4347
)
4448
self.driver.implicitly_wait(30)
45-
49+
4650
def tearDown(self):
4751
print("Link to your job: https://saucelabs.com/jobs/%s" % self.driver.session_id)
4852
try:
@@ -52,4 +56,3 @@ def tearDown(self):
5256
sauce.jobs.update_job(self.driver.session_id, passed=False)
5357
finally:
5458
self.driver.quit()
55-

appium/webdriver/common/multi_action.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,4 @@ def json_wire_gestures(self):
7575
actions.append(action.json_wire_gestures)
7676
if self._element is not None:
7777
return {'actions': actions, 'elementId': self._element.id}
78-
else:
79-
return {'actions': actions}
78+
return {'actions': actions}

appium/webdriver/common/touch_action.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#
2222
# Theirs is `TouchActions`. Appium's is `TouchAction`.
2323

24+
# pylint: disable=no-self-use
25+
2426
import copy
2527

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

115-
def _get_opts(self, element, x, y, duration = None):
117+
def _get_opts(self, element, x, y, duration=None):
116118
opts = {}
117119
if element is not None:
118120
opts['element'] = element.id

appium/webdriver/errorhandler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ def check_response(self, response):
2727
raise NoSuchContextException(wde.msg, wde.screen, wde.stacktrace)
2828
else:
2929
raise wde
30-

appium/webdriver/imagelement.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13-
import math
13+
# pylint: disable=no-self-use
1414

15+
import math
1516

16-
class ImageElement:
17+
class ImageElement(object):
1718

1819
def __init__(self, driver, x, y, width, height):
1920
self.driver = driver

appium/webdriver/webdriver.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,29 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

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

17-
from .mobilecommand import MobileCommand as Command
18-
from .errorhandler import MobileErrorHandler
19-
from .switch_to import MobileSwitchTo
20-
from .webelement import WebElement as MobileWebElement
21-
from .imagelement import ImageElement
17+
import base64
18+
import copy
2219

23-
from appium.webdriver.clipboard_content_type import ClipboardContentType
24-
from appium.webdriver.common.mobileby import MobileBy
25-
from appium.webdriver.common.touch_action import TouchAction
26-
from appium.webdriver.common.multi_action import MultiAction
20+
from selenium import webdriver
2721

2822
from selenium.webdriver.common.by import By
2923
from selenium.webdriver.support.ui import WebDriverWait
30-
from selenium.common.exceptions import (TimeoutException,
31-
WebDriverException, InvalidArgumentException, NoSuchElementException)
24+
from selenium.common.exceptions import (TimeoutException, WebDriverException, InvalidArgumentException, NoSuchElementException)
3225

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

35-
import base64
36-
import copy
28+
from appium.webdriver.clipboard_content_type import ClipboardContentType
29+
from appium.webdriver.common.mobileby import MobileBy
30+
from appium.webdriver.common.touch_action import TouchAction
31+
from appium.webdriver.common.multi_action import MultiAction
32+
33+
from .mobilecommand import MobileCommand as Command
34+
from .errorhandler import MobileErrorHandler
35+
from .switch_to import MobileSwitchTo
36+
from .webelement import WebElement as MobileWebElement
37+
from .imagelement import ImageElement
3738

3839
DEFAULT_MATCH_THRESHOLD = 0.5
3940

@@ -411,29 +412,29 @@ def find_elements_by_image(self, png_img_path,
411412
pass
412413
return els
413414

414-
def find_element_by_accessibility_id(self, id):
415+
def find_element_by_accessibility_id(self, accessibility_id):
415416
"""Finds an element by accessibility id.
416417
417418
:Args:
418-
- id - a string corresponding to a recursive element search using the
419+
- accessibility_id - a string corresponding to a recursive element search using the
419420
Id/Name that the native Accessibility options utilize
420421
421422
:Usage:
422423
driver.find_element_by_accessibility_id()
423424
"""
424-
return self.find_element(by=By.ACCESSIBILITY_ID, value=id)
425+
return self.find_element(by=By.ACCESSIBILITY_ID, value=accessibility_id)
425426

426-
def find_elements_by_accessibility_id(self, id):
427+
def find_elements_by_accessibility_id(self, accessibility_id):
427428
"""Finds elements by accessibility id.
428429
429430
:Args:
430-
- id - a string corresponding to a recursive element search using the
431+
- accessibility_id - a string corresponding to a recursive element search using the
431432
Id/Name that the native Accessibility options utilize
432433
433434
:Usage:
434435
driver.find_elements_by_accessibility_id()
435436
"""
436-
return self.find_elements(by=By.ACCESSIBILITY_ID, value=id)
437+
return self.find_elements(by=By.ACCESSIBILITY_ID, value=accessibility_id)
437438

438439
def create_web_element(self, element_id):
439440
"""
@@ -1400,6 +1401,8 @@ def battery_info(self):
14001401
"""
14011402
return self.execute_script('mobile: batteryInfo')
14021403

1404+
1405+
# pylint: disable=protected-access
14031406
def _addCommands(self):
14041407
self.command_executor._commands[Command.CONTEXTS] = \
14051408
('GET', '/session/$sessionId/contexts')

appium/webdriver/webelement.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from .mobilecommand import MobileCommand as Command
16-
1715
from selenium.webdriver.common.by import By
1816
from selenium.webdriver.remote.webelement import WebElement as SeleniumWebElement
1917

18+
from .mobilecommand import MobileCommand as Command
2019

2120
class WebElement(SeleniumWebElement):
2221
def find_element_by_ios_uiautomation(self, uia_string):
@@ -107,29 +106,29 @@ def find_elements_by_android_uiautomator(self, uia_string):
107106
"""
108107
return self.find_elements(by=By.ANDROID_UIAUTOMATOR, value=uia_string)
109108

110-
def find_element_by_accessibility_id(self, id):
109+
def find_element_by_accessibility_id(self, accessibility_id):
111110
"""Finds an element by accessibility id.
112111
113112
:Args:
114-
- id - a string corresponding to a recursive element search using the
113+
- accessibility_id - a string corresponding to a recursive element search using the
115114
Id/Name that the native Accessibility options utilize
116115
117116
:Usage:
118117
driver.find_element_by_accessibility_id()
119118
"""
120-
return self.find_element(by=By.ACCESSIBILITY_ID, value=id)
119+
return self.find_element(by=By.ACCESSIBILITY_ID, value=accessibility_id)
121120

122-
def find_elements_by_accessibility_id(self, id):
121+
def find_elements_by_accessibility_id(self, accessibility_id):
123122
"""Finds elements by accessibility id.
124123
125124
:Args:
126-
- id - a string corresponding to a recursive element search using the
125+
- accessibility_id - a string corresponding to a recursive element search using the
127126
Id/Name that the native Accessibility options utilize
128127
129128
:Usage:
130129
driver.find_elements_by_accessibility_id()
131130
"""
132-
return self.find_elements(by=By.ACCESSIBILITY_ID, value=id)
131+
return self.find_elements(by=By.ACCESSIBILITY_ID, value=accessibility_id)
133132

134133
def set_text(self, keys=''):
135134
"""Sends text to the element. Previous text is removed.

ci-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
astroid
2+
isort
3+
pylint

0 commit comments

Comments
 (0)