Skip to content

Commit

Permalink
fix: use raw string in regex to avoid deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rgonalo committed Mar 10, 2021
1 parent 773b0c3 commit 8d9e14f
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion toolium/behave/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def get_jira_key_from_scenario(scenario):
:param scenario: behave scenario
:returns: Jira test case key
"""
jira_regex = re.compile('jira[=\(\']*([A-Z]+\-[0-9]+)[\'\)]*$')
jira_regex = re.compile(r'jira[=\(\']*([A-Z]+\-[0-9]+)[\'\)]*$')
for tag in scenario.tags:
match = jira_regex.search(tag)
if match:
Expand Down
2 changes: 1 addition & 1 deletion toolium/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def deepcopy(self):

# Create a new config object
config_copy = ExtendedConfigParser()
config_copy.readfp(config_string)
config_copy.read_file(config_string)

return config_copy

Expand Down
4 changes: 2 additions & 2 deletions toolium/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ def get_error_message(response_content):
:param response_content: HTTP response from test case execution API
:returns: error message
"""
apache_regex = re.compile('.*<u>(.*)</u></p><p>.*')
apache_regex = re.compile(r'.*<u>(.*)</u></p><p>.*')
match = apache_regex.search(response_content)
if match:
error_message = match.group(1)
else:
local_regex = re.compile('.*<title>(.*)</title>.*')
local_regex = re.compile(r'.*<title>(.*)</title>.*')
match = local_regex.search(response_content)
if match:
error_message = match.group(1)
Expand Down
6 changes: 3 additions & 3 deletions toolium/pytest_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ def pytest_runtest_makereport(item):
return


@pytest.yield_fixture(scope='session', autouse=True)
@pytest.fixture(scope='session', autouse=True)
def session_driver_fixture(request):
yield None
DriverWrappersPool.close_drivers(scope='session',
test_name=request.node.name,
test_passed=request.session.testsfailed == 0)


@pytest.yield_fixture(scope='module', autouse=True)
@pytest.fixture(scope='module', autouse=True)
def module_driver_fixture(request):
previous_fails = request.session.testsfailed
yield None
Expand All @@ -46,7 +46,7 @@ def module_driver_fixture(request):
test_passed=request.session.testsfailed == previous_fails)


@pytest.yield_fixture(scope='function', autouse=True)
@pytest.fixture(scope='function', autouse=True)
def driver_wrapper(request):
default_driver_wrapper = DriverWrappersPool.connect_default_driver_wrapper()
yield default_driver_wrapper
Expand Down
2 changes: 1 addition & 1 deletion toolium/test/test_driver_wrapper_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from toolium.driver_wrappers_pool import DriverWrappersPool


@pytest.yield_fixture
@pytest.fixture
def driver_wrapper():
# Create a new wrapper
new_driver_wrapper = DriverWrappersPool.get_default_wrapper()
Expand Down
2 changes: 1 addition & 1 deletion toolium/test/test_driver_wrapper_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from toolium.driver_wrappers_pool import DriverWrappersPool


@pytest.yield_fixture
@pytest.fixture
def driver_wrapper():
# Reset wrappers pool values
DriverWrappersPool._empty_pool()
Expand Down
2 changes: 1 addition & 1 deletion toolium/test/test_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from toolium.driver_wrappers_pool import DriverWrappersPool


@pytest.yield_fixture
@pytest.fixture
def logger():
# Configure logger mock
logger = mock.MagicMock()
Expand Down
2 changes: 1 addition & 1 deletion toolium/test/test_test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def mock_fail(self):
return test


@pytest.yield_fixture
@pytest.fixture
def logger():
# Configure logger mock
logger = mock.MagicMock()
Expand Down
6 changes: 3 additions & 3 deletions toolium/test/test_visual_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
file_ios = os.path.join(root_path, 'resources', 'ios.png')


@pytest.yield_fixture
@pytest.fixture
def driver_wrapper():
# Remove previous visual path
root_path = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -173,14 +173,14 @@ def test_compare_files_size_fail(driver_wrapper):


def test_get_img_element(driver_wrapper):
expected_img = '<img src=".*register_v2.png" title="Baseline image"/>'
expected_img = r'<img src=".*register_v2.png" title="Baseline image"/>'
visual = VisualTest(driver_wrapper)
img = visual._get_img_element('register_v2.png', 'Baseline image')
assert re.compile(expected_img).match(img) is not None


def test_get_html_row(driver_wrapper):
expected_row = '<tr class=diff><td>report_name</td><td><img src=".*register_v2.png" title="Baseline image"/>' \
expected_row = r'<tr class=diff><td>report_name</td><td><img src=".*register_v2.png" title="Baseline image"/>' \
'</td><td><img src=".*register.png" title="Screenshot image"/></td><td></td></tr>'
visual = VisualTest(driver_wrapper)
row = visual._get_html_row('diff', 'report_name', file_v1, file_v2)
Expand Down
6 changes: 3 additions & 3 deletions toolium/visual_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,17 +416,17 @@ def _get_diff_message(message, image_size):
return 'Image dimensions do not match'

# Check pil engine message
m = re.search('\(by a distance of (.*)\)', message)
m = re.search(r'\(by a distance of (.*)\)', message)
if m:
return 'Distance of %0.8f' % (float(m.group(1)) / image_size)

# Check perceptualdiff engine message
m = re.search('([0-9]*) pixels are different', message)
m = re.search(r'([0-9]*) pixels are different', message)
if m:
return 'Distance of %0.8f' % (float(m.group(1)) / image_size)

# Check imagemagick engine message
m = re.search(':[\r\n](\d*\.?\d*) \((\d*\.?\d*)\) @', message)
m = re.search(r':[\r\n](\d*\.?\d*) \((\d*\.?\d*)\) @', message)
if m:
return 'Distance of %0.8f' % float(m.group(2))

Expand Down

0 comments on commit 8d9e14f

Please sign in to comment.