Skip to content

Commit a80cea9

Browse files
Even more tests
1 parent f504fbf commit a80cea9

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

tests/test_cli_new.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def temp_project_dir(tmp_path: Path, monkeypatch: Any) -> Path:
2222
def check_uv_installed() -> None:
2323
"""Skip tests if uv is not installed."""
2424
if not shutil.which("uv"):
25-
pytest.skip("uv is not installed")
25+
pytest.skip("uv is not installed") # pragma: no cover
2626

2727

2828
class TestNewCommand:
@@ -118,6 +118,27 @@ def test_passes_single_digit_python_version_to_uv(
118118
project_path = temp_project_dir / "test_project"
119119
self._assert_project_created(project_path)
120120

121+
def test_passes_malformed_python_version_to_uv(
122+
self, temp_project_dir: Path
123+
) -> None:
124+
result = runner.invoke(app, ["new", "test_project", "--python", "abc.def"])
125+
# uv will reject this, we just verify we don't crash during validation
126+
assert result.exit_code == 1
127+
128+
def test_creates_project_without_python_flag(self, temp_project_dir: Path) -> None:
129+
result = runner.invoke(app, ["new", "test_project"])
130+
assert result.exit_code == 0
131+
project_path = temp_project_dir / "test_project"
132+
self._assert_project_created(project_path)
133+
134+
def test_creates_project_with_other_uv_flags_no_python(
135+
self, temp_project_dir: Path
136+
) -> None:
137+
result = runner.invoke(app, ["new", "test_project", "--lib"])
138+
assert result.exit_code == 0
139+
project_path = temp_project_dir / "test_project"
140+
self._assert_project_created(project_path)
141+
121142

122143
class TestNewCommandUvFailures:
123144
def test_failed_to_initialize_with_uv(self, monkeypatch: Any) -> None:
@@ -154,8 +175,8 @@ def test_file_write_failure(self, temp_project_dir: Path, monkeypatch: Any) -> N
154175
original_write_text = Path.write_text
155176

156177
def mock_write_text(self: Path, *args: Any, **kwargs: Any) -> None:
157-
# Fail when trying to write main.py (our template file)
158-
if self.name == "main.py":
178+
# Fail when trying to write README.md (let main.py succeed first)
179+
if self.name == "README.md":
159180
raise PermissionError("Permission denied")
160181
original_write_text(self, *args, **kwargs)
161182

0 commit comments

Comments
 (0)