File tree Expand file tree Collapse file tree 4 files changed +54
-1
lines changed Expand file tree Collapse file tree 4 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,6 @@ coverage.xml
1818junit /
1919htmldocs /
2020utils /docker /dist /
21+ Pipfile
22+ Pipfile.lock
23+ .venv /
Original file line number Diff line number Diff line change @@ -246,7 +246,11 @@ def locals_to_params(args: Dict) -> Dict:
246246 if key == "self" :
247247 continue
248248 if args [key ] is not None :
249- copy [key ] = args [key ]
249+ copy [key ] = (
250+ args [key ]
251+ if not isinstance (args [key ], Dict )
252+ else locals_to_params (args [key ])
253+ )
250254 return copy
251255
252256
Original file line number Diff line number Diff line change @@ -48,6 +48,29 @@ async def test_should_use_proxy(
4848 assert await page .title () == "Served by the proxy"
4949
5050
51+ async def test_proxy_should_allow_none_for_optional_settings (
52+ context_factory : "Callable[..., asyncio.Future[BrowserContext]]" , server : Server
53+ ) -> None :
54+ server .set_route (
55+ "/target.html" ,
56+ lambda r : (
57+ r .write (b"<html><title>Served by the proxy</title></html>" ),
58+ r .finish (),
59+ ),
60+ )
61+ context = await context_factory (
62+ proxy = {
63+ "server" : f"localhost:{ server .PORT } " ,
64+ "username" : None ,
65+ "password" : None ,
66+ "bypass" : None ,
67+ }
68+ )
69+ page = await context .new_page ()
70+ await page .goto ("http://non-existent.com/target.html" )
71+ assert await page .title () == "Served by the proxy"
72+
73+
5174async def test_should_use_proxy_for_second_page (
5275 context_factory : "Callable[..., Awaitable[BrowserContext]]" , server : Server
5376) -> None :
Original file line number Diff line number Diff line change @@ -46,6 +46,29 @@ async def test_should_use_proxy(
4646 assert await page .title () == "Served by the proxy"
4747
4848
49+ async def test_proxy_should_allow_none_for_optional_settings (
50+ browser_factory : "Callable[..., asyncio.Future[Browser]]" , server : Server
51+ ) -> None :
52+ server .set_route (
53+ "/target.html" ,
54+ lambda r : (
55+ r .write (b"<html><title>Served by the proxy</title></html>" ),
56+ r .finish (),
57+ ),
58+ )
59+ browser = await browser_factory (
60+ proxy = {
61+ "server" : f"localhost:{ server .PORT } " ,
62+ "username" : None ,
63+ "password" : None ,
64+ "bypass" : None ,
65+ }
66+ )
67+ page = await browser .new_page ()
68+ await page .goto ("http://non-existent.com/target.html" )
69+ assert await page .title () == "Served by the proxy"
70+
71+
4972async def test_should_use_proxy_for_second_page (
5073 browser_factory : "Callable[..., asyncio.Future[Browser]]" , server : Server
5174) -> None :
You can’t perform that action at this time.
0 commit comments