Skip to content

Commit

Permalink
fix: update deprecated warn method and update flake8 configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
rgonalo committed Mar 21, 2021
1 parent 7f5e862 commit 2269ea2
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 36 deletions.
45 changes: 26 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ jobs:
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest and coverage
run: |
coverage run --source=toolium -m pytest toolium/test
Expand All @@ -44,16 +38,29 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade coveralls
- name: Finalize publishing on coveralls.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coveralls --finish
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade coveralls
- name: Finalize publishing on coveralls.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coveralls --finish
lint:
needs: test
runs-on: ubuntu-latest
steps:
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# stop the build if there are any syntax error
flake8 . --count --max-complexity=10 --max-line-length=121 --show-source --statistics
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def get_long_description():
url='https://github.com/telefonica/toolium',
description='Wrapper tool of Selenium and Appium libraries to test web and mobile applications in a single project',
long_description=get_long_description(),
keywords='selenium appium webdriver web_automation mobile_automation page_object visual_testing bdd lettuce behave pytest',
keywords='selenium appium webdriver web_automation mobile_automation page_object visual_testing bdd lettuce behave'
' pytest',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down
2 changes: 1 addition & 1 deletion toolium/behave/env_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def warn(self, exc):
msg = 'trying to execute a step in the environment: \n' \
' - Exception: %s' % exc
if self.logger is not None:
self.logger.warn(msg)
self.logger.warning(msg)
self.by_console(' WARN - %s' % msg)

def error(self, exc):
Expand Down
2 changes: 1 addition & 1 deletion toolium/driver_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def get_config_window_bounds(self):
bounds_x += monitor.x
bounds_y += monitor.y
except NotImplementedError:
self.logger.warn('Current environment doesn\'t support get_monitors')
self.logger.warning('Current environment doesn\'t support get_monitors')

return bounds_x, bounds_y

Expand Down
6 changes: 3 additions & 3 deletions toolium/driver_wrappers_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def stop_drivers(cls, maintain_default=False):
try:
driver_wrapper.driver.quit()
except Exception as e:
driver_wrapper.logger.warn(
driver_wrapper.logger.warning(
"Capture exceptions to avoid errors in teardown method due to session timeouts: \n %s" % e)

@classmethod
Expand Down Expand Up @@ -200,7 +200,7 @@ def download_videos(cls, name, test_passed=True, maintain_default=False):
video_name.format(name, driver_index))
except Exception as exc:
# Capture exceptions to avoid errors in teardown method due to session timeouts
driver_wrapper.logger.warn('Error downloading videos: %s' % exc)
driver_wrapper.logger.warning('Error downloading videos: %s' % exc)
driver_index += 1

@classmethod
Expand Down Expand Up @@ -250,7 +250,7 @@ def save_all_webdriver_or_ggr_logs(cls, test_name, test_passed, ggr=False):
driver_wrapper.utils.save_webdriver_logs(log_file_name)
except Exception as exc:
# Capture exceptions to avoid errors in teardown method due to session timeouts
driver_wrapper.logger.warn('Error downloading webdriver logs: %s' % exc)
driver_wrapper.logger.warning('Error downloading webdriver logs: %s' % exc)
driver_index += 1

@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion toolium/pageelements/page_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def _android_automatic_context_selection(self):
if self.webview_context_selection_callback:
context, window_handle = self.webview_context_selection_callback(*self.webview_csc_args)
else:
app_web_context = "{}_{}".format(PageElement.webview_context_prefix, self.driver.capabilities['appPackage'])
app_web_context = "{}_{}".format(PageElement.webview_context_prefix,
self.driver.capabilities['appPackage'])
contexts = self.driver.execute_script('mobile: getContexts')
context_dict = next(
(item for item in contexts if 'webviewName' in item and item['webviewName'] == app_web_context),
Expand Down
12 changes: 6 additions & 6 deletions toolium/selenoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
"""

import os
import time

import requests
import time

from toolium.utils.path_utils import makedirs_safe

Expand Down Expand Up @@ -104,9 +103,10 @@ def __download_file(self, url, path_file, timeout):
'seconds' % (path_file, took))
return True
except IOError as e:
self.driver_wrapper.logger.warn('Error writing downloaded file in "%s":\n %s' % (path_file, e))
self.driver_wrapper.logger.warning('Error writing downloaded file in "%s":\n %s' % (path_file, e))
else:
self.driver_wrapper.logger.warn('File "%s" does not exist in the server after %s seconds' % (url, timeout))
self.driver_wrapper.logger.warning('File "%s" does not exist in the server after %s seconds' % (url,
timeout))
return False

def __remove_file(self, url):
Expand Down Expand Up @@ -202,8 +202,8 @@ def is_the_session_still_active(self):
try:
response = requests.get(host_url).json()['browsers'][self.browser]
except Exception as e:
self.driver_wrapper.logger.warn('the GGR status request has failed: \nResponse: %s \n'
'Error message: %s\n' % (response.content, e))
self.driver_wrapper.logger.warning('the GGR status request has failed: \nResponse: %s \n'
'Error message: %s\n' % (response.content, e))
return None
for browser in response:
if response[browser] != {}:
Expand Down
8 changes: 4 additions & 4 deletions toolium/utils/driver_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def _expected_condition_find_element_clickable(self, element):
return False

def _expected_condition_find_element_stopped(self, element_times):
"""Tries to find the element and checks that it has stopped moving, but does not thrown an exception if the element
is not found
"""Tries to find the element and checks that it has stopped moving, but does not thrown an exception if the
element is not found
:param element_times: Tuple with 2 items where:
[0] element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
Expand All @@ -257,8 +257,8 @@ def _expected_condition_find_element_stopped(self, element_times):
return False

def _expected_condition_find_element_containing_text(self, element_text_pair):
"""Tries to find the element and checks that it contains the specified text, but does not thrown an exception if the element is
not found
"""Tries to find the element and checks that it contains the specified text, but does not thrown an exception if
the element is not found
:param element_text_pair: Tuple with 2 items where:
[0] element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
Expand Down

0 comments on commit 2269ea2

Please sign in to comment.