Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: fix tests
  • Loading branch information
rasputyashka committed Sep 24, 2025
commit 6f3ef3e78e786ef16a57a317284a3ec2d222a976
12 changes: 12 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_dev() -> None:
"proxy_headers": True,
"forwarded_allow_ips": None,
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: single_file_app:app" in result.output
assert "Starting development server 🚀" in result.output
Expand Down Expand Up @@ -62,6 +63,7 @@ def test_dev_package() -> None:
"proxy_headers": True,
"forwarded_allow_ips": None,
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: nested_package.package:app" in result.output
assert "Starting development server 🚀" in result.output
Expand Down Expand Up @@ -111,6 +113,7 @@ def test_dev_args() -> None:
"proxy_headers": False,
"forwarded_allow_ips": None,
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: single_file_app:api" in result.output
assert "Starting development server 🚀" in result.output
Expand Down Expand Up @@ -141,6 +144,7 @@ def test_dev_env_vars() -> None:
"proxy_headers": True,
"forwarded_allow_ips": None,
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: single_file_app:app" in result.output
assert "Starting development server 🚀" in result.output
Expand Down Expand Up @@ -178,6 +182,7 @@ def test_dev_env_vars_and_args() -> None:
"proxy_headers": True,
"forwarded_allow_ips": None,
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: single_file_app:app" in result.output
assert "Starting development server 🚀" in result.output
Expand Down Expand Up @@ -206,6 +211,7 @@ def test_run() -> None:
"proxy_headers": True,
"forwarded_allow_ips": None,
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: single_file_app:app" in result.output
assert "Starting production server 🚀" in result.output
Expand All @@ -232,6 +238,7 @@ def test_run_trust_proxy() -> None:
"proxy_headers": True,
"forwarded_allow_ips": "*",
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: single_file_app:app" in result.output
assert "Starting production server 🚀" in result.output
Expand Down Expand Up @@ -278,6 +285,7 @@ def test_run_args() -> None:
"proxy_headers": False,
"forwarded_allow_ips": None,
"log_config": get_uvicorn_log_config(),
"factory": False,
}

assert "Using import string: single_file_app:api" in result.output
Expand Down Expand Up @@ -309,6 +317,7 @@ def test_run_env_vars() -> None:
"proxy_headers": True,
"forwarded_allow_ips": None,
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: single_file_app:app" in result.output
assert "Starting production server 🚀" in result.output
Expand Down Expand Up @@ -342,6 +351,7 @@ def test_run_env_vars_and_args() -> None:
"proxy_headers": True,
"forwarded_allow_ips": None,
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: single_file_app:app" in result.output
assert "Starting production server 🚀" in result.output
Expand Down Expand Up @@ -428,6 +438,7 @@ def test_dev_with_import_string() -> None:
"root_path": "",
"proxy_headers": True,
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: single_file_app:api" in result.output

Expand All @@ -449,6 +460,7 @@ def test_run_with_import_string() -> None:
"root_path": "",
"proxy_headers": True,
"log_config": get_uvicorn_log_config(),
"factory": False,
}
assert "Using import string: single_file_app:app" in result.output

Expand Down
2 changes: 1 addition & 1 deletion tests/test_discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_get_import_data_from_import_string_valid() -> None:
result = get_import_data_from_import_string("module.submodule:app")

assert isinstance(result, ImportData)
assert result.app_name == "app"
assert result.candidate_name == "app"
assert result.import_string == "module.submodule:app"
assert result.module_data.module_import_str == "module.submodule"
assert result.module_data.extra_sys_path == Path(".").resolve()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_utils_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ def test_package_dir_no_app() -> None:
with pytest.raises(FastAPICLIException) as e:
get_import_data(path=Path("package/core/utils.py"))
assert (
"Could not find FastAPI app in module, try using --app" in e.value.args[0]
"Could not find FastAPI app or app factory in module, try using --app"
in e.value.args[0]
)


Expand Down