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>
This commit is contained in:
yucheng 2026-09-18 08:25:54 +00:00
parent 75f926da36
commit 1ccbc51ed8

View file

@ -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)