1111
1212@pytest .mark .parametrize ("command" , ["" , "localnet" , "testnet" , "mainnet" ])
1313def test_explore (command : str , mocker : MockerFixture ) -> None :
14- launch_mock = mocker .patch ("click.launch " )
14+ launch_mock = mocker .patch ("webbrowser.open " )
1515 result = invoke (f"explore { command } " )
1616
1717 assert result .exit_code == 0
@@ -24,10 +24,22 @@ def test_explore(command: str, mocker: MockerFixture) -> None:
2424def test_explore_wsl_exception (mocker : MockerFixture , caplog : pytest .LogCaptureFixture ) -> None :
2525 command = "localnet"
2626 mocker .patch ("algokit.cli.explore.is_wsl" , return_value = True )
27- mocker .patch ("webbrowser.open" , side_effect = Exception ( "Test Exception" ) )
27+ mocker .patch ("webbrowser.open" , return_value = False )
2828
2929 with caplog .at_level (logging .WARNING ):
3030 result = invoke (f"explore { command } " )
3131
3232 assert result .exit_code == 0
3333 assert any ("Unable to open browser from WSL" in message for message in caplog .messages )
34+
35+
36+ def test_explore_webbrowser_exception (mocker : MockerFixture , caplog : pytest .LogCaptureFixture ) -> None :
37+ command = "localnet"
38+ mocker .patch ("algokit.cli.explore.is_wsl" , return_value = False )
39+ mocker .patch ("webbrowser.open" , side_effect = Exception ("Webbrowser Exception" ))
40+
41+ with caplog .at_level (logging .WARNING ):
42+ result = invoke (f"explore { command } " )
43+
44+ assert result .exit_code == 0
45+ assert any ("Failed to open browser. Please open this URL manually:" in message for message in caplog .messages )
0 commit comments