From 84e5bf1a0e46e7a79b48f346a2ff0f88f232b0e0 Mon Sep 17 00:00:00 2001 From: Jeff Dupont Date: Wed, 28 Oct 2026 15:18:09 -0700 Subject: [PATCH 1/2] test(client): clear the endpoint variables around the lifecycle tests Two TestInitClientSDKKeyPath tests assert the exact Config call, and init_client passes LD_BASE_URI, LD_STREAM_URI and LD_EVENTS_URI to it. Importing litellm during collection runs load_dotenv(), which walks up from the working directory, so a checkout with a .env setting those variables failed both tests locally while CI passed. An autouse fixture now clears all three, matching clear_endpoint_env in test_skills_fdv2.py. Co-Authored-By: Claude Opus 5.5 --- packages/client/tests/test_lifecycle.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/client/tests/test_lifecycle.py b/packages/client/tests/test_lifecycle.py index 187ca9c5..28af8bbb 100644 --- a/packages/client/tests/test_lifecycle.py +++ b/packages/client/tests/test_lifecycle.py @@ -35,6 +35,20 @@ def reset_singleton() -> None: reset_ai_sdk_info(clear_known=True) +@pytest.fixture(autouse=True) +def clear_endpoint_env(monkeypatch: pytest.MonkeyPatch) -> None: + """ + ``init_client`` passes ``LD_BASE_URI``, ``LD_STREAM_URI`` and + ``LD_EVENTS_URI`` to ``Config``, so tests asserting the exact ``Config`` + call fail when any is set. A developer shell can set them, and so can a + ``.env`` file: importing ``litellm`` during collection runs + ``load_dotenv()``, which walks up from the working directory. All three + are cleared around each test, and restored after. + """ + for name in ("LD_BASE_URI", "LD_STREAM_URI", "LD_EVENTS_URI"): + monkeypatch.delenv(name, raising=False) + + @pytest.fixture def restore_otel_globals() -> Any: """Snapshot and restore the real OTel trace globals around one test. From c247089a440e9e579631188961f65e0a8aba9a05 Mon Sep 17 00:00:00 2001 From: Jeff Dupont Date: Thu, 29 Oct 2026 12:23:14 -0700 Subject: [PATCH 2/2] test(client): say where litellm's .env search starts load_dotenv() searches upward from the calling file, litellm's own install directory, not from the working directory. That is why a .venv inside a checkout finds that checkout's .env. Co-Authored-By: Claude Opus 5.5 --- packages/client/tests/test_lifecycle.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/client/tests/test_lifecycle.py b/packages/client/tests/test_lifecycle.py index adc157ce..e49bba6f 100644 --- a/packages/client/tests/test_lifecycle.py +++ b/packages/client/tests/test_lifecycle.py @@ -41,8 +41,9 @@ def clear_endpoint_env(monkeypatch: pytest.MonkeyPatch) -> None: ``LD_EVENTS_URI`` to ``Config``, so tests asserting the exact ``Config`` call fail when any is set. A developer shell can set them, and so can a ``.env`` file: importing ``litellm`` during collection runs - ``load_dotenv()``, which walks up from the working directory. All three - are cleared around each test, and restored after. + ``load_dotenv()``, which searches upward from litellm's own install + directory, so a ``.venv`` inside a checkout finds that checkout's + ``.env``. All three are cleared around each test, and restored after. """ for name in ("LD_BASE_URI", "LD_STREAM_URI", "LD_EVENTS_URI"): monkeypatch.delenv(name, raising=False)