Skip to content

Commit

Permalink
chore: unskip tests / unignore linting in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Nov 30, 2023
1 parent 248f3ec commit 544b4aa
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 24 deletions.
1 change: 1 addition & 0 deletions playwright/_impl/_api_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Cookie(TypedDict, total=False):
sameSite: Literal["Lax", "None", "Strict"]


# TODO: We are waiting for PEP705 so SetCookieParam can be readonly and matches Cookie.
class SetCookieParam(TypedDict, total=False):
name: str
value: str
Expand Down
12 changes: 1 addition & 11 deletions scripts/generate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,7 @@
import re
import sys
from types import FunctionType
from typing import ( # type: ignore
Any,
Dict,
List,
Match,
Optional,
Union,
cast,
get_args,
get_origin,
)
from typing import Any, Dict, List, Match, Optional, Union, cast, get_args, get_origin
from typing import get_type_hints as typing_get_type_hints

from playwright._impl._accessibility import Accessibility
Expand Down
1 change: 1 addition & 0 deletions tests/async/test_browsercontext_add_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async def test_should_roundtrip_cookie(
cookies = await context.cookies()
await context.clear_cookies()
assert await context.cookies() == []
# TODO: We are waiting for PEP705 so SetCookieParam can be readonly and matches the Cookie type.
await context.add_cookies(cookies) # type: ignore
assert await context.cookies() == cookies

Expand Down
2 changes: 1 addition & 1 deletion tests/async/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async def test_browser_launch_should_return_background_pages(
f"--disable-extensions-except={extension_path}",
f"--load-extension={extension_path}",
],
}, # type: ignore
},
)
background_page = None
if len(context.background_pages):
Expand Down
8 changes: 2 additions & 6 deletions tests/sync/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ def test_assertions_locator_to_contain_text(page: Page, server: Server) -> None:
expect(page.locator("div#foobar")).to_contain_text("bar", timeout=100)

page.set_content("<div>Text \n1</div><div>Text2</div><div>Text3</div>")
expect(page.locator("div")).to_contain_text(
["ext 1", re.compile("ext3")] # type: ignore
)
expect(page.locator("div")).to_contain_text(["ext 1", re.compile("ext3")])


def test_assertions_locator_to_have_attribute(page: Page, server: Server) -> None:
Expand Down Expand Up @@ -244,9 +242,7 @@ def test_assertions_locator_to_have_text(page: Page, server: Server) -> None:

page.set_content("<div>Text \n1</div><div>Text 2a</div>")
# Should only normalize whitespace in the first item.
expect(page.locator("div")).to_have_text(
["Text 1", re.compile(r"Text \d+a")] # type: ignore
)
expect(page.locator("div")).to_have_text(["Text 1", re.compile(r"Text \d+a")])


@pytest.mark.parametrize(
Expand Down
3 changes: 2 additions & 1 deletion tests/sync/test_browsercontext_request_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def capture_and_continue(route: Route, request: Request) -> None:

def delete_foo_header(route: Route, request: Request) -> None:
headers = request.all_headers()
route.fallback(headers={**headers, "foo": None}) # type: ignore
del headers["foo"]
route.fallback(headers=headers)

context.route(server.PREFIX + "/something", delete_foo_header)
with server.expect_request("/something") as server_req_info:
Expand Down
11 changes: 6 additions & 5 deletions tests/sync/test_fetch_browser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from playwright.sync_api import BrowserContext, Error, FilePayload, Page
from tests.server import Server
from tests.utils import must


def test_get_should_work(context: BrowserContext, server: Server) -> None:
Expand Down Expand Up @@ -150,11 +151,11 @@ def support_post_data(fetch_data: Any, request_post_data: Any) -> None:
server.PREFIX + "/simple.json", data=fetch_data
)
assert request.value.method.decode() == method.upper()
assert request.value.post_body == request_post_data # type: ignore
assert request.value.post_body == request_post_data
assert response.status == 200
assert response.url == server.PREFIX + "/simple.json"
assert request.value.getHeader("Content-Length") == str(
len(request.value.post_body) # type: ignore
len(must(request.value.post_body))
)

support_post_data("My request", "My request".encode())
Expand Down Expand Up @@ -182,9 +183,9 @@ def test_should_support_application_x_www_form_urlencoded(
server_req.value.getHeader("Content-Type")
== "application/x-www-form-urlencoded"
)
body = server_req.value.post_body.decode() # type: ignore
body = must(server_req.value.post_body).decode()
assert server_req.value.getHeader("Content-Length") == str(len(body))
params: Dict[bytes, List[bytes]] = parse_qs(server_req.value.post_body) # type: ignore
params: Dict[bytes, List[bytes]] = parse_qs(server_req.value.post_body)
assert params[b"firstName"] == [b"John"]
assert params[b"lastName"] == [b"Doe"]
assert params[b"file"] == [b"f.js"]
Expand Down Expand Up @@ -212,7 +213,7 @@ def test_should_support_multipart_form_data(
assert content_type
assert content_type.startswith("multipart/form-data; ")
assert server_req.value.getHeader("Content-Length") == str(
len(server_req.value.post_body) # type: ignore
len(must(server_req.value.post_body))
)
assert server_req.value.args[b"firstName"] == [b"John"]
assert server_req.value.args[b"lastName"] == [b"Doe"]
Expand Down

0 comments on commit 544b4aa

Please sign in to comment.