11import shutil
2+ from pathlib import Path
3+ from typing import Any
24
35import pytest
46from typer .testing import CliRunner
911
1012
1113@pytest .fixture
12- def temp_project_dir (tmp_path , monkeypatch ) :
14+ def temp_project_dir (tmp_path : Path , monkeypatch : Any ) -> Path :
1315 """Create a temporary directory and cd into it."""
1416 monkeypatch .chdir (tmp_path )
1517 return tmp_path
1618
1719
1820@pytest .fixture (autouse = True )
19- def check_uv_installed ():
21+ def check_uv_installed () -> None :
2022 """Skip tests if uv is not installed."""
2123 if not shutil .which ("uv" ):
2224 pytest .skip ("uv is not installed" )
2325
2426
2527class TestNewCommand :
2628
27- def test_creates_project_successfully (self , temp_project_dir ) :
29+ def test_creates_project_successfully (self , temp_project_dir : Path ) -> None :
2830 result = runner .invoke (app , ["new" , "my_fastapi_project" ])
2931
3032 assert result .exit_code == 0
@@ -35,7 +37,7 @@ def test_creates_project_successfully(self, temp_project_dir):
3537 assert "Success!" in result .output
3638 assert "my_fastapi_project" in result .output
3739
38- def test_creates_project_with_python_flag (self , temp_project_dir ) :
40+ def test_creates_project_with_python_flag (self , temp_project_dir : Path ) -> None :
3941 result = runner .invoke (app , ["new" , "my_fastapi_project" , "--python" , "3.12" ])
4042
4143 assert result .exit_code == 0
@@ -47,7 +49,7 @@ def test_creates_project_with_python_flag(self, temp_project_dir):
4749 assert "3.12" in python_version_file
4850 assert "Success!" in result .output
4951
50- def test_creates_project_with_python_flag_short (self , temp_project_dir ) :
52+ def test_creates_project_with_python_flag_short (self , temp_project_dir : Path ) -> None :
5153 result = runner .invoke (app , ["new" , "another_project" , "-p" , "3.9" ])
5254 assert result .exit_code == 0
5355 project_path = temp_project_dir / "another_project"
@@ -56,7 +58,7 @@ def test_creates_project_with_python_flag_short(self, temp_project_dir):
5658 assert "3.9" in python_version_file
5759
5860
59- def test_creates_project_with_multiple_flags (self , temp_project_dir ) :
61+ def test_creates_project_with_multiple_flags (self , temp_project_dir : Path ) -> None :
6062 result = runner .invoke (app , ["new" , "my_fastapi_project" , "--python" , "3.12" , "--lib" ])
6163
6264 assert result .exit_code == 0
@@ -67,14 +69,14 @@ def test_creates_project_with_multiple_flags(self, temp_project_dir):
6769 assert (project_path / "main.py" ).exists ()
6870 assert (project_path / "README.md" ).exists ()
6971
70- def test_rejects_python_below_3_8 (self , temp_project_dir ) :
72+ def test_rejects_python_below_3_8 (self , temp_project_dir : Path ) -> None :
7173 result = runner .invoke (app , ["new" , "my_fastapi_project" , "--python" , "3.7" ])
7274
7375 assert result .exit_code == 1
7476 assert "Python 3.7 is not supported" in result .output
7577 assert "FastAPI requires Python 3.8" in result .output
7678
77- def test_rejects_existing_directory (self , temp_project_dir ) :
79+ def test_rejects_existing_directory (self , temp_project_dir : Path ) -> None :
7880 existing_dir = temp_project_dir / "existing_project"
7981 existing_dir .mkdir ()
8082
@@ -83,7 +85,7 @@ def test_rejects_existing_directory(self, temp_project_dir):
8385 assert result .exit_code == 1
8486 assert f"Directory 'existing_project' already exists." in result .output
8587
86- def test_initializes_in_current_directory_when_no_name_provided (self , temp_project_dir ) :
88+ def test_initializes_in_current_directory_when_no_name_provided (self , temp_project_dir : Path ) -> None :
8789 result = runner .invoke (app , ["new" ])
8890
8991 assert result .exit_code == 0
@@ -97,7 +99,7 @@ def test_initializes_in_current_directory_when_no_name_provided(self, temp_proje
9799 assert (temp_project_dir / "README.md" ).exists ()
98100 assert (temp_project_dir / "pyproject.toml" ).exists ()
99101
100- def test_validate_file_contents (self , temp_project_dir ) :
102+ def test_validate_file_contents (self , temp_project_dir : Path ) -> None :
101103 result = runner .invoke (app , ["new" , "sample_project" ])
102104
103105 assert result .exit_code == 0
@@ -111,7 +113,7 @@ def test_validate_file_contents(self, temp_project_dir):
111113 assert "# sample_project" in readme_content
112114 assert "A project created with FastAPI Cloud CLI." in readme_content
113115
114- def test_validate_pyproject_toml_contents (self , temp_project_dir ) :
116+ def test_validate_pyproject_toml_contents (self , temp_project_dir : Path ) -> None :
115117 result = runner .invoke (app , ["new" , "test_project" ])
116118
117119 assert result .exit_code == 0
0 commit comments