Skip to content

Commit 3de2af9

Browse files
committed
[py] fix pytest warning capture
1 parent 2d712da commit 3de2af9

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

py/test/selenium/webdriver/common/devtools_tests.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222
@pytest.mark.xfail_safari
2323
@pytest.mark.xfail_firefox
2424
@pytest.mark.xfail_remote
25-
def test_check_console_messages(driver, pages):
26-
with pytest.warns(None) as record:
27-
devtools, connection = driver.start_devtools()
25+
def test_check_console_messages(driver, pages, recwarn):
26+
devtools, connection = driver.start_devtools()
2827
console_api_calls = []
2928

30-
assert len(record) == 0
29+
assert len(recwarn) == 0
3130

3231
connection.execute(devtools.runtime.enable())
3332
connection.on(devtools.runtime.ConsoleAPICalled, console_api_calls.append)

py/test/selenium/webdriver/firefox/firefox_service_tests.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@
2727
from selenium.webdriver.firefox.service import Service
2828

2929

30-
def test_log_output_as_filename() -> None:
30+
def test_log_output_as_filename(recwarn) -> None:
3131
log_file = "geckodriver.log"
3232
service = Service(log_output=log_file)
3333
try:
34-
with pytest.warns(None) as record:
35-
driver = Firefox(service=service)
36-
assert len(record) == 0
34+
driver = Firefox(service=service)
35+
assert len(recwarn) == 0
3736
with open(log_file) as fp:
3837
assert "geckodriver\tINFO\tListening" in fp.readline()
3938
finally:

py/test/unit/selenium/webdriver/remote/remote_connection_tests.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ def test_get_remote_connection_headers_defaults():
6767
assert headers.get("User-Agent").split(" ")[-1] in {"windows)", "mac)", "linux)", "mac", "windows", "linux"}
6868

6969

70-
def test_get_remote_connection_headers_adds_auth_header_if_pass():
70+
def test_get_remote_connection_headers_adds_auth_header_if_pass(recwarn):
7171
url = "http://user:pass@remote"
72-
with pytest.warns(None) as record:
73-
headers = RemoteConnection.get_remote_connection_headers(parse.urlparse(url))
72+
headers = RemoteConnection.get_remote_connection_headers(parse.urlparse(url))
7473
assert headers.get("Authorization") == "Basic dXNlcjpwYXNz"
7574
assert (
76-
record[0].message.args[0]
75+
recwarn[0].message.args[0]
7776
== "Embedding username and password in URL could be insecure, use ClientConfig instead"
7877
)
7978

0 commit comments

Comments
 (0)