Skip to content

Commit 5c5be0e

Browse files
dosasichdosas
authored
Fix failing tests (#261)
* 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 <[email protected]>
1 parent 9f6c21e commit 5c5be0e

File tree

5 files changed

+43
-35
lines changed

5 files changed

+43
-35
lines changed

pytest_selenium/pytest_selenium.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646

4747

4848
def _merge(a, b):
49-
""" merges b and a configurations.
50-
Based on http://bit.ly/2uFUHgb
49+
"""merges b and a configurations.
50+
Based on http://bit.ly/2uFUHgb
5151
"""
5252
for key in b:
5353
if key in a:

testing/test_driver.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5+
from contextlib import ExitStack as does_not_raise
56
from functools import partial
67

78
import pytest_selenium
@@ -107,10 +108,13 @@ def test_pass(driver_kwargs):
107108

108109

109110
@pytest.mark.parametrize(
110-
("host_arg_name", "port_arg_name"),
111-
[("--selenium-host", "--selenium-port"), ("--host", "--port")],
111+
("host_arg_name", "port_arg_name", "context"),
112+
[
113+
("--selenium-host", "--selenium-port", does_not_raise()),
114+
("--host", "--port", pytest.warns(DeprecationWarning)),
115+
],
112116
)
113-
def test_arguments_order(testdir, host_arg_name, port_arg_name):
117+
def test_arguments_order(testdir, host_arg_name, port_arg_name, context):
114118
host = "notlocalhost"
115119
port = "4441"
116120
file_test = testdir.makepyfile(
@@ -123,16 +127,17 @@ def test_pass(driver_kwargs):
123127
host, port
124128
)
125129
)
126-
testdir.quick_qa(
127-
"--driver",
128-
"Remote",
129-
host_arg_name,
130-
host,
131-
port_arg_name,
132-
port,
133-
file_test,
134-
passed=1,
135-
)
130+
with context:
131+
testdir.quick_qa(
132+
"--driver",
133+
"Remote",
134+
host_arg_name,
135+
host,
136+
port_arg_name,
137+
port,
138+
file_test,
139+
passed=1,
140+
)
136141

137142

138143
def test_arguments_order_random(testdir):

testing/test_metadata.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5+
from contextlib import ExitStack as does_not_raise
6+
57
import pytest
68

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

2527

2628
@pytest.mark.parametrize(
27-
("host_arg_name", "port_arg_name"),
28-
[("--selenium-host", "--selenium-port"), ("--host", "--port")],
29+
("host_arg_name", "port_arg_name", "context"),
30+
[
31+
("--selenium-host", "--selenium-port", does_not_raise()),
32+
("--host", "--port", pytest.warns(DeprecationWarning)),
33+
],
2934
)
30-
def test_metadata_host_port(testdir, host_arg_name, port_arg_name):
35+
def test_metadata_host_port(testdir, host_arg_name, port_arg_name, context):
3136
host = "notlocalhost"
3237
port = "4441"
3338
file_test = testdir.makepyfile(
@@ -40,13 +45,14 @@ def test_pass(metadata):
4045
host, port
4146
)
4247
)
43-
testdir.quick_qa(
44-
"--driver",
45-
"Remote",
46-
host_arg_name,
47-
host,
48-
port_arg_name,
49-
port,
50-
file_test,
51-
passed=1,
52-
)
48+
with context:
49+
testdir.quick_qa(
50+
"--driver",
51+
"Remote",
52+
host_arg_name,
53+
host,
54+
port_arg_name,
55+
port,
56+
file_test,
57+
passed=1,
58+
)

testing/test_report.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
SCREENSHOT_LINK_REGEX = '<a class="image" href=".*" target="_blank">Screenshot</a>'
1919
SCREENSHOT_REGEX = '<div class="image"><a href=".*"><img src=".*"/></a></div>'
2020
else:
21-
SCREENSHOT_LINK_REGEX = '<a class="image" href=".*" target="_blank"></a>'
22-
SCREENSHOT_REGEX = (
23-
'<div class="image"><a class="image" href=".*" target="_blank"></a></div>'
21+
SCREENSHOT_LINK_REGEX = (
22+
'<a class="image" href=".*" target="_blank"><img src=".*"/></a>'
2423
)
24+
SCREENSHOT_REGEX = '<div class="image"><a class="image" href=".*" target="_blank">'
25+
'<img src=".*"/></a></div>'
2526

2627
LOGS_REGEX = '<a class="text" href=".*" target="_blank">.* Log</a>'
2728
HTML_REGEX = '<a class="text" href=".*" target="_blank">HTML</a>'

tox.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,3 @@ markers =
4343
chrome
4444
skip_selenium
4545
nondestructive
46-
# TODO: Temporary hack until they fix
47-
# https://github.com/pytest-dev/pytest/issues/6936
48-
filterwarnings =
49-
ignore:.*TerminalReporter.writer attribute is deprecated.*:pytest.PytestDeprecationWarning

0 commit comments

Comments
 (0)