Skip to content

Commit b5b495d

Browse files
committed
[py]: format python tests with black
1 parent c686e68 commit b5b495d

File tree

70 files changed

+1099
-1005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1099
-1005
lines changed

py/test/selenium/webdriver/chrome/chrome_execute_cdp_cmd_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020

2121
def test_execute_cdp_cmd():
2222
driver = Chrome()
23-
version_info = driver.execute_cdp_cmd('Browser.getVersion', {})
23+
version_info = driver.execute_cdp_cmd("Browser.getVersion", {})
2424
assert isinstance(version_info, dict)
25-
assert 'userAgent' in version_info
25+
assert "userAgent" in version_info

py/test/selenium/webdriver/chrome/chrome_network_emulation_tests.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@
2222

2323
def test_network_conditions_emulation():
2424
driver = Chrome()
25-
driver.set_network_conditions(
26-
offline=False,
27-
latency=56, # additional latency (ms)
28-
throughput=789)
25+
driver.set_network_conditions(offline=False, latency=56, throughput=789) # additional latency (ms)
2926
conditions = driver.get_network_conditions()
30-
assert conditions['offline'] is False
31-
assert conditions['latency'] == 56
32-
assert conditions['download_throughput'] == 789
33-
assert conditions['upload_throughput'] == 789
27+
assert conditions["offline"] is False
28+
assert conditions["latency"] == 56
29+
assert conditions["download_throughput"] == 789
30+
assert conditions["upload_throughput"] == 789
3431
driver.delete_network_conditions()
3532
with pytest.raises(WebDriverException):
3633
driver.get_network_conditions()

py/test/selenium/webdriver/chrome/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717

1818

1919
def pytest_generate_tests(metafunc):
20-
if 'driver' in metafunc.fixturenames and metafunc.config.option.drivers:
21-
metafunc.parametrize('driver', metafunc.config.option.drivers, indirect=True)
20+
if "driver" in metafunc.fixturenames and metafunc.config.option.drivers:
21+
metafunc.parametrize("driver", metafunc.config.option.drivers, indirect=True)

py/test/selenium/webdriver/chrome/options_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_w3c_true():
2424
options = webdriver.ChromeOptions()
2525
options.add_experimental_option("w3c", True)
2626

27-
chrome_kwargs = {'options': options}
27+
chrome_kwargs = {"options": options}
2828

2929
with pytest.warns(DeprecationWarning, match="Setting 'w3c: True' is redundant"):
3030
driver = webdriver.Chrome(**chrome_kwargs)
@@ -36,7 +36,7 @@ def test_w3c_false():
3636
options = webdriver.ChromeOptions()
3737
options.add_experimental_option("w3c", False)
3838

39-
chrome_kwargs = {'options': options}
39+
chrome_kwargs = {"options": options}
4040

4141
with pytest.raises(AttributeError):
4242
webdriver.Chrome(**chrome_kwargs)

py/test/selenium/webdriver/chrome/proxy_tests.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
def test_bad_proxy_doesnt_interfere():
2626

2727
# these values should be ignored if ignore_local_proxy_environment_variables() is called.
28-
os.environ['https_proxy'] = 'bad'
29-
os.environ['http_proxy'] = 'bad'
28+
os.environ["https_proxy"] = "bad"
29+
os.environ["http_proxy"] = "bad"
3030
options = webdriver.ChromeOptions()
3131

3232
options.ignore_local_proxy_environment_variables()
3333

34-
chrome_kwargs = {'options': options}
34+
chrome_kwargs = {"options": options}
3535
driver = webdriver.Chrome(**chrome_kwargs)
3636

37-
assert hasattr(driver, 'command_executor')
38-
assert hasattr(driver.command_executor, '_proxy_url')
37+
assert hasattr(driver, "command_executor")
38+
assert hasattr(driver.command_executor, "_proxy_url")
3939
assert type(driver.command_executor._conn) == urllib3.PoolManager
40-
os.environ.pop('https_proxy')
41-
os.environ.pop('http_proxy')
40+
os.environ.pop("https_proxy")
41+
os.environ.pop("http_proxy")
4242
driver.quit()

py/test/selenium/webdriver/common/alerts_tests.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ def close_alert(driver):
3838

3939
def test_should_be_able_to_override_the_window_alert_method(driver, pages):
4040
pages.load("alerts.html")
41-
driver.execute_script(
42-
"window.alert = function(msg) { document.getElementById('text').innerHTML = msg; }")
41+
driver.execute_script("window.alert = function(msg) { document.getElementById('text').innerHTML = msg; }")
4342
driver.find_element(by=By.ID, value="alert").click()
4443
try:
45-
assert driver.find_element(By.ID, 'text').text == "cheese"
44+
assert driver.find_element(By.ID, "text").text == "cheese"
4645
except Exception as e:
4746
# if we're here, likely the alert is displayed
4847
# not dismissing it will affect other tests
@@ -140,13 +139,11 @@ def test_setting_the_value_of_an_alert_throws(driver, pages):
140139

141140

142141
@pytest.mark.xfail_chrome(
143-
condition=sys.platform == 'darwin',
144-
reason='https://bugs.chromium.org/p/chromedriver/issues/detail?id=26',
145-
run=False)
142+
condition=sys.platform == "darwin", reason="https://bugs.chromium.org/p/chromedriver/issues/detail?id=26", run=False
143+
)
146144
@pytest.mark.xfail_chromiumedge(
147-
condition=sys.platform == 'darwin',
148-
reason='https://bugs.chromium.org/p/chromedriver/issues/detail?id=26',
149-
run=False)
145+
condition=sys.platform == "darwin", reason="https://bugs.chromium.org/p/chromedriver/issues/detail?id=26", run=False
146+
)
150147
def test_alert_should_not_allow_additional_commands_if_dimissed(driver, pages):
151148
pages.load("alerts.html")
152149
driver.find_element(By.ID, "alert").click()
@@ -158,8 +155,8 @@ def test_alert_should_not_allow_additional_commands_if_dimissed(driver, pages):
158155
alert.text
159156

160157

161-
@pytest.mark.xfail_firefox(reason='Fails on travis')
162-
@pytest.mark.xfail_remote(reason='Fails on travis')
158+
@pytest.mark.xfail_firefox(reason="Fails on travis")
159+
@pytest.mark.xfail_remote(reason="Fails on travis")
163160
@pytest.mark.xfail_safari
164161
def test_should_allow_users_to_accept_an_alert_in_aframe(driver, pages):
165162
pages.load("alerts.html")
@@ -172,8 +169,8 @@ def test_should_allow_users_to_accept_an_alert_in_aframe(driver, pages):
172169
assert "Testing Alerts" == driver.title
173170

174171

175-
@pytest.mark.xfail_firefox(reason='Fails on travis')
176-
@pytest.mark.xfail_remote(reason='Fails on travis')
172+
@pytest.mark.xfail_firefox(reason="Fails on travis")
173+
@pytest.mark.xfail_remote(reason="Fails on travis")
177174
@pytest.mark.xfail_safari
178175
def test_should_allow_users_to_accept_an_alert_in_anested_frame(driver, pages):
179176
pages.load("alerts.html")
@@ -247,11 +244,13 @@ def test_should_handle_alert_on_page_load_using_get(driver, pages):
247244
alert.accept()
248245

249246
assert "onload" == value
250-
WebDriverWait(driver, 3).until(EC.text_to_be_present_in_element((By.TAG_NAME, "p"), "Page with onload event handler"))
247+
WebDriverWait(driver, 3).until(
248+
EC.text_to_be_present_in_element((By.TAG_NAME, "p"), "Page with onload event handler")
249+
)
251250

252251

253-
@pytest.mark.xfail_chrome(reason='Non W3C conformant')
254-
@pytest.mark.xfail_chromiumedge(reason='Non W3C conformant')
252+
@pytest.mark.xfail_chrome(reason="Non W3C conformant")
253+
@pytest.mark.xfail_chromiumedge(reason="Non W3C conformant")
255254
def test_should_handle_alert_on_page_before_unload(driver, pages):
256255
pages.load("pageWithOnBeforeUnloadMessage.html")
257256

@@ -291,10 +290,8 @@ def test_alert_should_not_allow_additional_commands_if_dismissed(driver, pages):
291290
alert.text
292291

293292

294-
@pytest.mark.xfail_firefox(
295-
reason='https://bugzilla.mozilla.org/show_bug.cgi?id=1279211')
296-
@pytest.mark.xfail_remote(
297-
reason='https://bugzilla.mozilla.org/show_bug.cgi?id=1279211')
293+
@pytest.mark.xfail_firefox(reason="https://bugzilla.mozilla.org/show_bug.cgi?id=1279211")
294+
@pytest.mark.xfail_remote(reason="https://bugzilla.mozilla.org/show_bug.cgi?id=1279211")
298295
@pytest.mark.xfail_chrome
299296
def test_unexpected_alert_present_exception_contains_alert_text(driver, pages):
300297
pages.load("alerts.html")

py/test/selenium/webdriver/common/api_example_tests.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_get_title(driver, pages):
3434
def test_get_current_url(driver, pages, webserver):
3535
pages.load("simpleTest.html")
3636
url = driver.current_url
37-
assert webserver.where_is('simpleTest.html') == url
37+
assert webserver.where_is("simpleTest.html") == url
3838

3939

4040
def test_find_element_by_xpath(driver, pages):
@@ -161,11 +161,11 @@ def test_navigate(driver, pages):
161161

162162

163163
def test_get_attribute(driver, pages):
164-
url = pages.url('xhtmlTest.html')
164+
url = pages.url("xhtmlTest.html")
165165
driver.get(url)
166166
elem = driver.find_element(By.ID, "id1")
167167
attr = elem.get_attribute("href")
168-
assert f'{url}#' == attr
168+
assert f"{url}#" == attr
169169

170170

171171
def test_get_implicit_attribute(driver, pages):
@@ -177,15 +177,15 @@ def test_get_implicit_attribute(driver, pages):
177177

178178

179179
def test_get_dom_attribute(driver, pages):
180-
url = pages.url('formPage.html')
180+
url = pages.url("formPage.html")
181181
driver.get(url)
182182
elem = driver.find_element(By.ID, "vsearchGadget")
183183
attr = elem.get_dom_attribute("accesskey")
184184
assert "4" == attr
185185

186186

187187
def test_get_property(driver, pages):
188-
url = pages.url('formPage.html')
188+
url = pages.url("formPage.html")
189189
driver.get(url)
190190
elem = driver.find_element(By.ID, "withText")
191191
prop = elem.get_property("value")
@@ -212,15 +212,16 @@ def test_execute_script_with_args(driver, pages):
212212

213213
def test_execute_script_with_multiple_args(driver, pages):
214214
pages.load("xhtmlTest.html")
215-
result = driver.execute_script(
216-
"return arguments[0] + arguments[1]", 1, 2)
215+
result = driver.execute_script("return arguments[0] + arguments[1]", 1, 2)
217216
assert 3 == result
218217

219218

220219
def test_execute_script_with_element_args(driver, pages):
221220
pages.load("javascriptPage.html")
222221
button = driver.find_element(By.ID, "plainButton")
223-
result = driver.execute_script("arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];", button)
222+
result = driver.execute_script(
223+
"arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];", button
224+
)
224225
assert "plainButton" == result
225226

226227

@@ -246,28 +247,28 @@ def test_move_window_position(driver, pages):
246247
# because of system toolbars
247248
new_x = 50
248249
new_y = 50
249-
if loc['x'] == new_x:
250+
if loc["x"] == new_x:
250251
new_x += 10
251-
if loc['y'] == new_y:
252+
if loc["y"] == new_y:
252253
new_y += 10
253254
driver.set_window_position(new_x, new_y)
254255
loc = driver.get_window_position()
255-
assert loc['x'] == new_x
256-
assert loc['y'] == new_y
256+
assert loc["x"] == new_x
257+
assert loc["y"] == new_y
257258

258259

259260
def test_change_window_size(driver, pages):
260261
pages.load("blank.html")
261262
size = driver.get_window_size()
262263
newSize = [600, 600]
263-
if size['width'] == 600:
264+
if size["width"] == 600:
264265
newSize[0] = 500
265-
if size['height'] == 600:
266+
if size["height"] == 600:
266267
newSize[1] = 500
267268
driver.set_window_size(newSize[0], newSize[1])
268269
size = driver.get_window_size()
269-
assert size['width'] == newSize[0]
270-
assert size['height'] == newSize[1]
270+
assert size["width"] == newSize[0]
271+
assert size["height"] == newSize[1]
271272

272273

273274
@pytest.mark.xfail_firefox(raises=WebDriverException)

py/test/selenium/webdriver/common/bidi_tests.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ async def test_check_console_messages(driver, pages):
2929
log = Log(driver, session)
3030
pages.load("javascriptPage.html")
3131
from selenium.webdriver.common.bidi.console import Console
32+
3233
async with log.add_listener(Console.ALL) as messages:
3334
driver.execute_script("console.log('I love cheese')")
3435
assert messages["message"] == "I love cheese"
@@ -40,8 +41,9 @@ async def test_check_error_console_messages(driver, pages):
4041
log = Log(driver, session)
4142
pages.load("javascriptPage.html")
4243
from selenium.webdriver.common.bidi.console import Console
44+
4345
async with log.add_listener(Console.ERROR) as messages:
44-
driver.execute_script("console.error(\"I don't cheese\")")
46+
driver.execute_script('console.error("I don\'t cheese")')
4547
driver.execute_script("console.log('I love cheese')")
4648
assert messages["message"] == "I don't cheese"
4749

@@ -68,8 +70,9 @@ async def test_collect_log_mutations(driver, pages):
6870
async with log.mutation_events() as event:
6971
pages.load("dynamic.html")
7072
driver.find_element(By.ID, "reveal").click()
71-
WebDriverWait(driver, 5, ignored_exceptions=InvalidSelectorException)\
72-
.until(EC.visibility_of(driver.find_element(By.ID, "revealed")))
73+
WebDriverWait(driver, 5, ignored_exceptions=InvalidSelectorException).until(
74+
EC.visibility_of(driver.find_element(By.ID, "revealed"))
75+
)
7376

7477
assert event["attribute_name"] == "style"
7578
assert event["current_value"] == ""

py/test/selenium/webdriver/common/click_scrolling_tests.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ def test_should_scroll_overflow_elements_if_click_point_is_out_of_view_but_eleme
110110
assert "clicked" == driver.find_element(By.ID, "clicked").text
111111

112112

113-
@pytest.mark.xfail_firefox(
114-
reason='https://github.com/w3c/webdriver/issues/408')
115-
@pytest.mark.xfail_remote(
116-
reason='https://github.com/w3c/webdriver/issues/408')
113+
@pytest.mark.xfail_firefox(reason="https://github.com/w3c/webdriver/issues/408")
114+
@pytest.mark.xfail_remote(reason="https://github.com/w3c/webdriver/issues/408")
117115
@pytest.mark.xfail_safari
118116
def test_should_be_able_to_click_element_in_aframe_that_is_out_of_view(driver, pages):
119117
pages.load("scrolling_tests/page_with_frame_out_of_view.html")

py/test/selenium/webdriver/common/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717

1818

1919
def pytest_generate_tests(metafunc):
20-
if 'driver' in metafunc.fixturenames and metafunc.config.option.drivers:
21-
metafunc.parametrize('driver', metafunc.config.option.drivers, indirect=True)
20+
if "driver" in metafunc.fixturenames and metafunc.config.option.drivers:
21+
metafunc.parametrize("driver", metafunc.config.option.drivers, indirect=True)

0 commit comments

Comments
 (0)