@@ -59,7 +59,7 @@ def test_run_server_with_default_values(
59
59
# Path("."): path to local folder
60
60
# show=True: same as passing the --view option (which defaults to True)
61
61
# 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 )
63
63
64
64
65
65
@mock .patch ("pyscript.plugins.run.start_server" )
@@ -78,25 +78,33 @@ def test_run_server_with_no_view_flag(
78
78
# Path("."): path to local folder
79
79
# show=False: same as passing the --no-view option
80
80
# 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 )
82
82
83
83
84
84
@pytest .mark .parametrize (
85
- "run_args, expected_values " ,
85
+ "run_args, expected_posargs, expected_kwargs " ,
86
86
[
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" )}),
95
103
],
96
104
)
97
105
@mock .patch ("pyscript.plugins.run.start_server" )
98
106
def 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
100
108
):
101
109
"""
102
110
Test that when run is called without arguments the command runs with the
@@ -107,7 +115,7 @@ def test_run_server_with_valid_combinations(
107
115
# EXPECT the command to succeed
108
116
assert result .exit_code == 0
109
117
# 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 )
111
119
112
120
113
121
class TestFolderBasedHTTPRequestHandler :
0 commit comments