Skip to content

Commit

Permalink
Fix failing tests (#261)
Browse files Browse the repository at this point in the history
* Fix failing report tests due to pytest-html release.

* Fix deprecation warnings:

* Remove warning that has been fix
* Ensure pytest-selenium warnings are raised in tests

* Black fix.

Co-authored-by: ich <ich@desktop>
Co-authored-by: dosas <dosas@github.com>
  • Loading branch information
3 people committed Jan 26, 2021
1 parent 9f6c21e commit 5c5be0e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 35 deletions.
4 changes: 2 additions & 2 deletions pytest_selenium/pytest_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@


def _merge(a, b):
""" merges b and a configurations.
Based on http://bit.ly/2uFUHgb
"""merges b and a configurations.
Based on http://bit.ly/2uFUHgb
"""
for key in b:
if key in a:
Expand Down
31 changes: 18 additions & 13 deletions testing/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from contextlib import ExitStack as does_not_raise
from functools import partial

import pytest_selenium
Expand Down Expand Up @@ -107,10 +108,13 @@ def test_pass(driver_kwargs):


@pytest.mark.parametrize(
("host_arg_name", "port_arg_name"),
[("--selenium-host", "--selenium-port"), ("--host", "--port")],
("host_arg_name", "port_arg_name", "context"),
[
("--selenium-host", "--selenium-port", does_not_raise()),
("--host", "--port", pytest.warns(DeprecationWarning)),
],
)
def test_arguments_order(testdir, host_arg_name, port_arg_name):
def test_arguments_order(testdir, host_arg_name, port_arg_name, context):
host = "notlocalhost"
port = "4441"
file_test = testdir.makepyfile(
Expand All @@ -123,16 +127,17 @@ def test_pass(driver_kwargs):
host, port
)
)
testdir.quick_qa(
"--driver",
"Remote",
host_arg_name,
host,
port_arg_name,
port,
file_test,
passed=1,
)
with context:
testdir.quick_qa(
"--driver",
"Remote",
host_arg_name,
host,
port_arg_name,
port,
file_test,
passed=1,
)


def test_arguments_order_random(testdir):
Expand Down
32 changes: 19 additions & 13 deletions testing/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from contextlib import ExitStack as does_not_raise

import pytest

pytestmark = pytest.mark.nondestructive
Expand All @@ -24,10 +26,13 @@ def test_pass(metadata):


@pytest.mark.parametrize(
("host_arg_name", "port_arg_name"),
[("--selenium-host", "--selenium-port"), ("--host", "--port")],
("host_arg_name", "port_arg_name", "context"),
[
("--selenium-host", "--selenium-port", does_not_raise()),
("--host", "--port", pytest.warns(DeprecationWarning)),
],
)
def test_metadata_host_port(testdir, host_arg_name, port_arg_name):
def test_metadata_host_port(testdir, host_arg_name, port_arg_name, context):
host = "notlocalhost"
port = "4441"
file_test = testdir.makepyfile(
Expand All @@ -40,13 +45,14 @@ def test_pass(metadata):
host, port
)
)
testdir.quick_qa(
"--driver",
"Remote",
host_arg_name,
host,
port_arg_name,
port,
file_test,
passed=1,
)
with context:
testdir.quick_qa(
"--driver",
"Remote",
host_arg_name,
host,
port_arg_name,
port,
file_test,
passed=1,
)
7 changes: 4 additions & 3 deletions testing/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
SCREENSHOT_LINK_REGEX = '<a class="image" href=".*" target="_blank">Screenshot</a>'
SCREENSHOT_REGEX = '<div class="image"><a href=".*"><img src=".*"/></a></div>'
else:
SCREENSHOT_LINK_REGEX = '<a class="image" href=".*" target="_blank"></a>'
SCREENSHOT_REGEX = (
'<div class="image"><a class="image" href=".*" target="_blank"></a></div>'
SCREENSHOT_LINK_REGEX = (
'<a class="image" href=".*" target="_blank"><img src=".*"/></a>'
)
SCREENSHOT_REGEX = '<div class="image"><a class="image" href=".*" target="_blank">'
'<img src=".*"/></a></div>'

LOGS_REGEX = '<a class="text" href=".*" target="_blank">.* Log</a>'
HTML_REGEX = '<a class="text" href=".*" target="_blank">HTML</a>'
Expand Down
4 changes: 0 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,3 @@ markers =
chrome
skip_selenium
nondestructive
# TODO: Temporary hack until they fix
# https://github.com/pytest-dev/pytest/issues/6936
filterwarnings =
ignore:.*TerminalReporter.writer attribute is deprecated.*:pytest.PytestDeprecationWarning

0 comments on commit 5c5be0e

Please sign in to comment.