Skip to content

Commit

Permalink
Merge 88ad8c1 into 761da58
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenramper1 committed Mar 15, 2023
2 parents 761da58 + 88ad8c1 commit 84b6ef3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
fail-fast: false

steps:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -9,6 +9,11 @@ target
# VSCode IDE
.vscode

# virtualenv
venv/
VENV/
ENV/

# Packages
*.egg
*.egg-info
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -6,6 +6,7 @@ v3.0.0

*Release date: In development*

- Add support for Python 3.11
- Add support for Selenium 4
- Add support for Appium-Python-Client 2
- Remove support for lettuce tests
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -67,6 +67,7 @@ def get_long_description():
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Software Development :: Testing',
Expand Down
16 changes: 16 additions & 0 deletions toolium/config_driver.py
Expand Up @@ -19,6 +19,7 @@
import ast
import logging
import os
import re

from appium import webdriver as appiumdriver
from appium.options.common.base import AppiumOptions
Expand Down Expand Up @@ -48,6 +49,21 @@ def get_error_message_from_exception(exception):
return ''


def get_error_message_from_traceback(traceback):
"""Extract first line of exception message inside traceback
:param traceback: exception traceback
:returns: first line of exception message
"""
# The second line not tabbed of the traceback is the exception message
lines = traceback.split('\n')[1:]
for line in lines:
match = re.match('\\S+: (.*)', line)
if match:
return match.group(1)
return ''


class ConfigDriver(object):
def __init__(self, config, utils=None):
self.logger = logging.getLogger(__name__)
Expand Down
12 changes: 9 additions & 3 deletions toolium/test_cases.py
Expand Up @@ -19,7 +19,7 @@
import logging
import unittest

from toolium.config_driver import get_error_message_from_exception
from toolium.config_driver import get_error_message_from_exception, get_error_message_from_traceback
from toolium.config_files import ConfigFiles
from toolium.driver_wrappers_pool import DriverWrappersPool
from toolium.jira import change_all_jira_status
Expand Down Expand Up @@ -64,15 +64,21 @@ def setUp(self):

def tearDown(self):
# Get unit test exception
exception_info = self._outcome.errors[-1][1] if len(self._outcome.errors) > 0 else None
if hasattr(self._outcome, 'errors'):
exception_info = self._outcome.errors[-1][1] if len(self._outcome.errors) > 0 else None
else:
exception_info = self._outcome.result.failures[0] if len(self._outcome.result.failures) > 0 else None
exception = exception_info[1] if exception_info else None

if not exception:
self._test_passed = True
self.logger.info("The test '%s' has passed", self.get_subclassmethod_name())
else:
self._test_passed = False
error_message = get_error_message_from_exception(exception)
if hasattr(self._outcome, 'errors'):
error_message = get_error_message_from_exception(exception)
else:
error_message = get_error_message_from_traceback(exception)
self.logger.error("The test '%s' has failed: %s", self.get_subclassmethod_name(), error_message)


Expand Down

0 comments on commit 84b6ef3

Please sign in to comment.