@@ -59,7 +59,7 @@ def test_run_server_with_default_values(
5959 # Path("."): path to local folder
6060 # show=True: same as passing the --view option (which defaults to True)
6161 # port=8000: that is the default port
62- start_server_mock .assert_called_once_with (Path ("." ), True , 8000 )
62+ start_server_mock .assert_called_once_with (Path ("." ), True , 8000 , default_file = None )
6363
6464
6565@mock .patch ("pyscript.plugins.run.start_server" )
@@ -78,25 +78,33 @@ def test_run_server_with_no_view_flag(
7878 # Path("."): path to local folder
7979 # show=False: same as passing the --no-view option
8080 # port=8000: that is the default port
81- start_server_mock .assert_called_once_with (Path ("." ), False , 8000 )
81+ start_server_mock .assert_called_once_with (Path ("." ), False , 8000 , default_file = None )
8282
8383
8484@pytest .mark .parametrize (
85- "run_args, expected_values " ,
85+ "run_args, expected_posargs, expected_kwargs " ,
8686 [
87- (("--no-view" ,), (Path ("." ), False , 8000 )),
88- ((BASEPATH ,), (Path (BASEPATH ), True , 8000 )),
89- (("--port=8001" ,), (Path ("." ), True , 8001 )),
90- (("--no-view" , "--port=8001" ), (Path ("." ), False , 8001 )),
91- ((BASEPATH , "--no-view" ), (Path (BASEPATH ), False , 8000 )),
92- ((BASEPATH , "--port=8001" ), (Path (BASEPATH ), True , 8001 )),
93- ((BASEPATH , "--no-view" , "--port=8001" ), (Path (BASEPATH ), False , 8001 )),
94- ((BASEPATH , "--port=8001" ), (Path (BASEPATH ), True , 8001 )),
87+ (("--no-view" ,), (Path ("." ), False , 8000 ), {"default_file" : None }),
88+ ((BASEPATH ,), (Path (BASEPATH ), True , 8000 ), {"default_file" : None }),
89+ (("--port=8001" ,), (Path ("." ), True , 8001 ), {"default_file" : None }),
90+ (("--no-view" , "--port=8001" ), (Path ("." ), False , 8001 ), {"default_file" : None }),
91+ ((BASEPATH , "--no-view" ), (Path (BASEPATH ), False , 8000 ), {"default_file" : None }),
92+ ((BASEPATH , "--port=8001" ), (Path (BASEPATH ), True , 8001 ), {"default_file" : None }),
93+ ((BASEPATH , "--no-view" , "--port=8001" ), (Path (BASEPATH ), False , 8001 ), {"default_file" : None }),
94+ ((BASEPATH , "--port=8001" ), (Path (BASEPATH ), True , 8001 ), {"default_file" : None }),
95+ (("--no-view" , "--default-file=index.html" ), (Path ("." ), False , 8000 ), {"default_file" : Path ("index.html" )}),
96+ ((BASEPATH , "--default-file=index.html" ), (Path (BASEPATH ), True , 8000 ), {"default_file" : Path ("index.html" )}),
97+ (("--port=8001" , "--default-file=index.html" ), (Path ("." ), True , 8001 ), {"default_file" : Path ("index.html" )}),
98+ (("--no-view" , "--port=8001" , "--default-file=index.html" ), (Path ("." ), False , 8001 ), {"default_file" : Path ("index.html" )}),
99+ ((BASEPATH , "--no-view" , "--default-file=index.html" ), (Path (BASEPATH ), False , 8000 ), {"default_file" : Path ("index.html" )}),
100+ ((BASEPATH , "--port=8001" , "--default-file=index.html" ), (Path (BASEPATH ), True , 8001 ), {"default_file" : Path ("index.html" )}),
101+ ((BASEPATH , "--no-view" , "--port=8001" , "--default-file=index.html" ), (Path (BASEPATH ), False , 8001 ), {"default_file" : Path ("index.html" )}),
102+ ((BASEPATH , "--port=8001" , "--default-file=index.html" ), (Path (BASEPATH ), True , 8001 ), {"default_file" : Path ("index.html" )}),
95103 ],
96104)
97105@mock .patch ("pyscript.plugins.run.start_server" )
98106def test_run_server_with_valid_combinations (
99- start_server_mock , invoke_cli : CLIInvoker , run_args , expected_values # noqa: F811
107+ start_server_mock , invoke_cli : CLIInvoker , run_args , expected_posargs , expected_kwargs # noqa: F811
100108):
101109 """
102110 Test that when run is called without arguments the command runs with the
@@ -107,7 +115,7 @@ def test_run_server_with_valid_combinations(
107115 # EXPECT the command to succeed
108116 assert result .exit_code == 0
109117 # EXPECT start_server_mock function to be called with the expected values
110- start_server_mock .assert_called_once_with (* expected_values )
118+ start_server_mock .assert_called_once_with (* expected_posargs , ** expected_kwargs )
111119
112120
113121class TestFolderBasedHTTPRequestHandler :
0 commit comments