mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-09 02:24:40 +00:00
Merge pull request #21434 from BerriAI/fix/langfuse-otel-sys-modules-leak
fix: restore sys.modules after stub injection in langfuse otel test
This commit is contained in:
@@ -157,8 +157,12 @@ class TestLangfuseOtelIntegration:
|
||||
|
||||
stub_module.LangFuseLogger = StubLFLogger # type: ignore
|
||||
|
||||
# Register stub in sys.modules so import inside method succeeds
|
||||
sys.modules["litellm.integrations.langfuse.langfuse"] = stub_module # type: ignore
|
||||
# Register stub in sys.modules so import inside method succeeds.
|
||||
# Use monkeypatch so the real module is restored after the test runs,
|
||||
# preventing sys.modules corruption that would break patch() targets in
|
||||
# later tests (the patch would hit the stub while the real module's
|
||||
# globals remain unpatch-ed).
|
||||
monkeypatch.setitem(sys.modules, "litellm.integrations.langfuse.langfuse", stub_module) # type: ignore
|
||||
|
||||
kwargs = {"litellm_params": {"metadata": {"foo": "bar"}}}
|
||||
extracted = LangfuseOtelLogger._extract_langfuse_metadata(kwargs)
|
||||
|
||||
Reference in New Issue
Block a user