@@ -93,26 +93,28 @@ def test_other(self, monkeypatch: pytest.MonkeyPatch):
9393 assert ChromiumWebbrowser .fallback_paths () == []
9494
9595
96- class TestLaunchArgs :
97- def test_launch_args (self ):
98- webbrowser = ChromiumWebbrowser ()
99- assert "--password-store=basic" in webbrowser .arguments
100- assert "--use-mock-keychain" in webbrowser .arguments
101- assert "--headless=new" not in webbrowser .arguments
102- assert not any (arg .startswith ("--remote-debugging-host" ) for arg in webbrowser .arguments )
103- assert not any (arg .startswith ("--remote-debugging-port" ) for arg in webbrowser .arguments )
104- assert not any (arg .startswith ("--user-data-dir" ) for arg in webbrowser .arguments )
105-
106- @pytest .mark .parametrize ("headless" , [True , False ])
107- def test_headless (self , headless : bool ):
108- webbrowser = ChromiumWebbrowser (headless = headless )
109- assert ("--headless=new" in webbrowser .arguments ) is headless
96+ def test_default_args ():
97+ webbrowser = ChromiumWebbrowser ()
98+ assert "--password-store=basic" in webbrowser .arguments
99+ assert "--use-mock-keychain" in webbrowser .arguments
100+ assert "--headless=new" not in webbrowser .arguments
101+ assert not any (arg .startswith ("--remote-debugging-host" ) for arg in webbrowser .arguments )
102+ assert not any (arg .startswith ("--remote-debugging-port" ) for arg in webbrowser .arguments )
103+ assert not any (arg .startswith ("--user-data-dir" ) for arg in webbrowser .arguments )
110104
111105
112106@pytest .mark .trio ()
113- @pytest .mark .parametrize ("host" , ["127.0.0.1" , "::1" ])
114- @pytest .mark .parametrize ("port" , [None , 1234 ])
115- async def test_launch (monkeypatch : pytest .MonkeyPatch , mock_clock , webbrowser_launch , host , port ):
107+ @pytest .mark .parametrize ("host" , [pytest .param ("127.0.0.1" , id = "ipv4" ), pytest .param ("::1" , id = "ipv6" )])
108+ @pytest .mark .parametrize ("port" , [pytest .param (None , id = "default-port" ), pytest .param (1234 , id = "custom-port" )])
109+ @pytest .mark .parametrize ("headless" , [pytest .param (True , id = "headless" ), pytest .param (False , id = "not-headless" )])
110+ async def test_launch (
111+ monkeypatch : pytest .MonkeyPatch ,
112+ mock_clock ,
113+ webbrowser_launch ,
114+ host : str ,
115+ port : Optional [int ],
116+ headless : bool ,
117+ ):
116118 async def fake_find_free_port (_ ):
117119 await trio .sleep (0 )
118120 return 1234
@@ -123,10 +125,11 @@ async def fake_find_free_port(_):
123125 webbrowser = ChromiumWebbrowser (host = host , port = port )
124126
125127 process : trio .Process
126- async with webbrowser_launch (webbrowser = webbrowser , timeout = 999 ) as (_nursery , process ):
128+ async with webbrowser_launch (webbrowser = webbrowser , headless = headless , timeout = 999 ) as (_nursery , process ):
127129 assert process .poll () is None , "process is still running"
128130 assert f"--remote-debugging-host={ host } " in process .args
129131 assert "--remote-debugging-port=1234" in process .args
132+ assert ("--headless=new" in process .args ) is headless
130133 param_user_data_dir = next ( # pragma: no branch
131134 (arg for arg in process .args if arg .startswith ("--user-data-dir=" )),
132135 None ,
0 commit comments