From 1ccbc51ed808c61c72ad2a34dfeb5570586fb154 Mon Sep 17 00:00:00 2001 From: yucheng Date: Fri, 18 Sep 2026 08:25:54 +0000 Subject: [PATCH] test(otel v2): clear the cached LITELLM_OTEL_V2 flag after each destination test so it stops leaking into later modules Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../integrations/otel/test_otel_v2_destinations.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_litellm/integrations/otel/test_otel_v2_destinations.py b/tests/test_litellm/integrations/otel/test_otel_v2_destinations.py index c1de5cfc0c3..2f31f6725fd 100644 --- a/tests/test_litellm/integrations/otel/test_otel_v2_destinations.py +++ b/tests/test_litellm/integrations/otel/test_otel_v2_destinations.py @@ -82,6 +82,15 @@ def isolate_published_provider(monkeypatch): monkeypatch.setattr(otel_logger, "_published_v2_provider", None) +@pytest.fixture(autouse=True) +def forget_otel_v2_flag_after_each_test(): + """``is_otel_v2_enabled`` caches its first answer. Tests here flip ``LITELLM_OTEL_V2`` + through monkeypatch, which restores the env but not the cache, so the next module + on the worker would keep seeing v2 on.""" + yield + is_otel_v2_enabled.cache_clear() + + def in_fresh_context(fn, *args): """Run ``fn`` in its own context so one test's destinations never leak.""" return contextvars.copy_context().run(fn, *args)