Skip to content

Commit

Permalink
address flake8 findings
Browse files Browse the repository at this point in the history
flake8 --append-config=tools/flake8.ini webdriver/tests/bidi                                                                                                                                                 :
  • Loading branch information
Thiago Perrotta committed Nov 12, 2023
1 parent 7e26d8c commit ac91346
Show file tree
Hide file tree
Showing 31 changed files with 445 additions and 322 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from . import (
get_element_coordinates,
get_page_y_offset,
get_physical_element_dimensions,
get_reference_screenshot,
)
Expand Down Expand Up @@ -176,7 +175,7 @@ async def test_clip_viewport_scroll_to(

element = await bidi_session.script.call_function(
await_promise=False,
function_declaration=f"""() => {{
function_declaration="""() => {{
const element = document.querySelector('div');
const rect = element.getBoundingClientRect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def on_event(_, data):

remove_listener = bidi_session.add_event_listener(CONTEXT_DESTROYED_EVENT, on_event)

url = inline(f"<div>test</div>", domain=domain)
url = inline("<div>test</div>", domain=domain)
await bidi_session.browsing_context.navigate(
url=url, context=new_tab["context"], wait="complete"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

from .. import assert_browsing_context
from webdriver.bidi.modules.script import ContextTarget

pytestmark = pytest.mark.asyncio

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from webdriver.bidi.modules.script import ContextTarget
from webdriver.error import TimeoutException

from ... import any_int, any_string, recursive_compare, int_interval
from ... import any_int, recursive_compare, int_interval
from .. import assert_navigation_info

pytestmark = pytest.mark.asyncio
Expand Down Expand Up @@ -90,7 +90,7 @@ async def test_navigation_id(

on_frame_navigated = wait_for_event(FRAGMENT_NAVIGATED_EVENT)

target_url = url(EMPTY_PAGE + '#foo');
target_url = url(EMPTY_PAGE + '#foo')
result = await bidi_session.browsing_context.navigate(
context=new_tab["context"], url=target_url, wait="complete")

Expand All @@ -113,7 +113,7 @@ async def test_url_with_base_tag(bidi_session, subscribe_events, inline, new_tab

on_frame_navigated = wait_for_event(FRAGMENT_NAVIGATED_EVENT)

target_url = url + '#foo';
target_url = url + '#foo'
await bidi_session.browsing_context.navigate(context=new_tab["context"], url=target_url, wait="complete")

recursive_compare(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import asyncio

import pytest
from tests.support.sync import AsyncPoll

Expand Down Expand Up @@ -377,14 +375,14 @@ async def on_event(method, data):
http_equiv_url = url(PAGE_REDIRECT_HTTP_EQUIV)
redirected_url = url(PAGE_REDIRECTED_HTML)

result = await bidi_session.browsing_context.navigate(
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=http_equiv_url,
wait="complete",
)

# Wait until we receive two events, one for the initial navigation and one for
# the http-equiv "redirect".
# Wait until we receive two events, one for the initial navigation and one
# for the http-equiv "redirect".
wait = AsyncPoll(bidi_session, timeout=2)
await wait.until(lambda _: len(events) >= 2)

Expand All @@ -404,6 +402,8 @@ async def on_event(method, data):
},
)

remove_listener()


async def test_redirect_navigation(
bidi_session, subscribe_events, top_context, url
Expand All @@ -425,7 +425,7 @@ async def on_event(method, data):
f"/webdriver/tests/support/http_handlers/redirect.py?location={html_url}"
)

result = await bidi_session.browsing_context.navigate(
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=redirect_url,
wait="complete",
Expand All @@ -440,6 +440,8 @@ async def on_event(method, data):
},
)

remove_listener()


async def test_navigate_history_pushstate(
bidi_session, inline, new_tab, subscribe_events, wait_for_event
Expand Down
4 changes: 2 additions & 2 deletions webdriver/tests/bidi/browsing_context/print/margin.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ async def test_margin_minimum_page_size(

# Check that margins don't affect page dimensions and equal defaults.
await assert_pdf_dimensions(value, {
"width": expected_width,
"height": expected_height,
"width": expected_width,
"height": expected_height,
})


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ async def test_set_viewport_reset(bidi_session, new_tab):
assert await get_viewport_dimensions(bidi_session, new_tab) != test_viewport

await bidi_session.browsing_context.set_viewport(
context=new_tab["context"],
viewport=test_viewport)
context=new_tab["context"],
viewport=test_viewport
)

assert await get_viewport_dimensions(bidi_session, new_tab) == test_viewport

await bidi_session.browsing_context.set_viewport(
context=new_tab["context"],
viewport=None)
context=new_tab["context"],
viewport=None
)
assert await get_viewport_dimensions(bidi_session, new_tab) == original_viewport


Expand All @@ -64,8 +66,9 @@ async def test_set_viewport_affects_specific_context(bidi_session, top_context,
assert await get_viewport_dimensions(bidi_session, new_tab) != test_viewport

await bidi_session.browsing_context.set_viewport(
context=new_tab["context"],
viewport=test_viewport)
context=new_tab["context"],
viewport=test_viewport
)

assert await get_viewport_dimensions(bidi_session, new_tab) == test_viewport
assert await get_viewport_dimensions(bidi_session, top_context) == original_viewport
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import pytest
from tests.support.sync import AsyncPoll
from webdriver.error import TimeoutException
Expand Down Expand Up @@ -189,7 +188,7 @@ async def on_event(method, data):
# Open a prompt in the different context.
await bidi_session.browsing_context.navigate(
context=another_new_context["context"],
url=inline(f"<script>window.alert('second tab')</script>"),
url=inline("<script>window.alert('second tab')</script>"),
)

await on_prompt_opened
Expand All @@ -209,7 +208,7 @@ async def on_event(method, data):
# Open a prompt in the subscribed context.
await bidi_session.browsing_context.navigate(
context=new_context["context"],
url=inline(f"<script>window.alert('first tab')</script>"),
url=inline("<script>window.alert('first tab')</script>"),
)

await on_prompt_opened
Expand Down
2 changes: 1 addition & 1 deletion webdriver/tests/bidi/input/perform_actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ async def record_pointer_events(bidi_session, context, container, selector):
await_promise=False,
)

return target
return target
Loading

0 comments on commit ac91346

Please sign in to comment.