Skip to content

Commit

Permalink
fix: patch bug in locals_to_params (#2300)
Browse files Browse the repository at this point in the history
  • Loading branch information
danphenderson authored Sep 6, 2024
1 parent 04b7851 commit bc88ac9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ coverage.xml
junit/
htmldocs/
utils/docker/dist/
Pipfile
Pipfile.lock
.venv/
6 changes: 5 additions & 1 deletion playwright/_impl/_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ def locals_to_params(args: Dict) -> Dict:
if key == "self":
continue
if args[key] is not None:
copy[key] = args[key]
copy[key] = (
args[key]
if not isinstance(args[key], Dict)
else locals_to_params(args[key])
)
return copy


Expand Down
23 changes: 23 additions & 0 deletions tests/async/test_browsercontext_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ async def test_should_use_proxy(
assert await page.title() == "Served by the proxy"


async def test_proxy_should_allow_none_for_optional_settings(
context_factory: "Callable[..., asyncio.Future[BrowserContext]]", server: Server
) -> None:
server.set_route(
"/target.html",
lambda r: (
r.write(b"<html><title>Served by the proxy</title></html>"),
r.finish(),
),
)
context = await context_factory(
proxy={
"server": f"localhost:{server.PORT}",
"username": None,
"password": None,
"bypass": None,
}
)
page = await context.new_page()
await page.goto("http://non-existent.com/target.html")
assert await page.title() == "Served by the proxy"


async def test_should_use_proxy_for_second_page(
context_factory: "Callable[..., Awaitable[BrowserContext]]", server: Server
) -> None:
Expand Down
23 changes: 23 additions & 0 deletions tests/async/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ async def test_should_use_proxy(
assert await page.title() == "Served by the proxy"


async def test_proxy_should_allow_none_for_optional_settings(
browser_factory: "Callable[..., asyncio.Future[Browser]]", server: Server
) -> None:
server.set_route(
"/target.html",
lambda r: (
r.write(b"<html><title>Served by the proxy</title></html>"),
r.finish(),
),
)
browser = await browser_factory(
proxy={
"server": f"localhost:{server.PORT}",
"username": None,
"password": None,
"bypass": None,
}
)
page = await browser.new_page()
await page.goto("http://non-existent.com/target.html")
assert await page.title() == "Served by the proxy"


async def test_should_use_proxy_for_second_page(
browser_factory: "Callable[..., asyncio.Future[Browser]]", server: Server
) -> None:
Expand Down

0 comments on commit bc88ac9

Please sign in to comment.