mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
fix: isolate test_skip_server_startup from CI environment
Remove mix_stderr=False (unsupported in some Click versions). Strip DATABASE_URL/DIRECT_URL from environment during the test to prevent real prisma operations when these are set in CI.
This commit is contained in:
parent
e19458a421
commit
25759952d4
1 changed files with 8 additions and 3 deletions
|
|
@ -233,7 +233,7 @@ class TestProxyInitializationHelpers:
|
|||
|
||||
from litellm.proxy.proxy_cli import run_server
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
mock_proxy_module = MagicMock(
|
||||
app=MagicMock(),
|
||||
|
|
@ -241,7 +241,12 @@ class TestProxyInitializationHelpers:
|
|||
KeyManagementSettings=MagicMock(),
|
||||
save_worker_config=MagicMock(),
|
||||
)
|
||||
# Remove DATABASE_URL/DIRECT_URL so the CLI doesn't attempt
|
||||
# real prisma operations when these are set in CI.
|
||||
clean_env = {k: v for k, v in os.environ.items() if k not in ("DATABASE_URL", "DIRECT_URL")}
|
||||
with patch.dict(
|
||||
os.environ, clean_env, clear=True,
|
||||
), patch.dict(
|
||||
"sys.modules",
|
||||
{
|
||||
"proxy_server": mock_proxy_module,
|
||||
|
|
@ -262,7 +267,7 @@ class TestProxyInitializationHelpers:
|
|||
# --- skip startup ---
|
||||
result = runner.invoke(run_server, ["--local", "--skip_server_startup"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert result.exit_code == 0, f"exit_code={result.exit_code}, output={result.output}"
|
||||
assert "Skipping server startup" in result.output
|
||||
mock_uvicorn_run.assert_not_called()
|
||||
|
||||
|
|
@ -271,7 +276,7 @@ class TestProxyInitializationHelpers:
|
|||
|
||||
result = runner.invoke(run_server, ["--local"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert result.exit_code == 0, f"exit_code={result.exit_code}, output={result.output}"
|
||||
mock_uvicorn_run.assert_called_once()
|
||||
|
||||
@patch("uvicorn.run")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue