11from __future__ import annotations
22
33from pathlib import Path
4- from typing import TYPE_CHECKING , Callable , Optional
4+ from typing import TYPE_CHECKING , Callable
55
66import pytest
77from mypy_extensions import VarArg
@@ -29,7 +29,7 @@ def app_details_args():
2929
3030
3131@pytest .fixture ()
32- def invoke_cli (tmp_path : Path , monkeypatch : " MonkeyPatch" ) -> CLIInvoker :
32+ def invoke_cli (tmp_path : Path , monkeypatch : MonkeyPatch ) -> CLIInvoker :
3333 """Returns a function, which can be used to call the CLI from within a temporary directory."""
3434 runner = CliRunner ()
3535
@@ -48,6 +48,30 @@ def test_version() -> None:
4848 assert f"PyScript CLI version: { __version__ } " in result .stdout
4949
5050
51+ def test_create_command (
52+ invoke_cli : CLIInvoker , tmp_path : Path , app_details_args : list [str ], auto_enter
53+ ) -> None :
54+ result = invoke_cli ("create" , "myapp" )
55+ assert result .exit_code == 0
56+
57+ expected_path = tmp_path / "myapp"
58+ assert expected_path .exists ()
59+
60+ expected_main_py_path = expected_path / "main.py"
61+ assert expected_main_py_path .exists ()
62+
63+ expected_config_path = expected_path / config ["project_config_filename" ]
64+ assert expected_config_path .exists ()
65+ with expected_config_path .open () as fp :
66+ config_text = fp .read ()
67+
68+ assert 'name = "myapp' in config_text
69+ # Assert that description, author name and email are empty
70+ assert 'description = ""' in config_text
71+ assert 'author_name = ""' in config_text
72+ assert 'author_email = ""' in config_text
73+
74+
5175@pytest .mark .parametrize ("flag" , ["-c" , "--command" ])
5276def test_wrap_command (
5377 invoke_cli : CLIInvoker , tmp_path : Path , flag : str , app_details_args : list [str ]
@@ -116,7 +140,7 @@ def test_wrap_file(
116140)
117141def test_wrap_pyscript_version (
118142 invoke_cli : CLIInvoker ,
119- version : Optional [ str ] ,
143+ version : str | None ,
120144 expected_version : str ,
121145 tmp_path : Path ,
122146 app_details_args : list [str ],
@@ -166,7 +190,7 @@ def test_wrap_pyscript_version(
166190)
167191def test_wrap_pyscript_version_file (
168192 invoke_cli : CLIInvoker ,
169- version : Optional [ str ] ,
193+ version : str | None ,
170194 expected_version : str ,
171195 tmp_path : Path ,
172196 app_details_args : list [str ],
0 commit comments