Skip to content

Commit 408e407

Browse files
committed
Add missing test
1 parent 71c980b commit 408e407

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_cli.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ def test_dev() -> None:
4545
assert "🐍 single_file_app.py" in result.output
4646

4747

48+
def test_dev_no_args_auto_discovery() -> None:
49+
"""Test that auto-discovery works when no args and no pyproject.toml entrypoint"""
50+
with changing_dir(assets_path / "default_files" / "default_main"):
51+
with patch.object(uvicorn, "run") as mock_run:
52+
result = runner.invoke(app, ["dev"]) # No path argument
53+
assert result.exit_code == 0, result.output
54+
assert mock_run.called
55+
assert mock_run.call_args
56+
assert mock_run.call_args.kwargs["app"] == "main:app"
57+
assert mock_run.call_args.kwargs["host"] == "127.0.0.1"
58+
assert mock_run.call_args.kwargs["port"] == 8000
59+
assert mock_run.call_args.kwargs["reload"] is True
60+
assert "Using import string: main:app" in result.output
61+
62+
4863
def test_dev_package() -> None:
4964
with changing_dir(assets_path):
5065
with patch.object(uvicorn, "run") as mock_run:

0 commit comments

Comments
 (0)