From a5ba1caac5c312ff2189b1200d1eda54b5cac8e6 Mon Sep 17 00:00:00 2001 From: Tin Chi Lo Date: Tue, 21 Jul 2026 21:06:41 -0700 Subject: [PATCH] test(helicone): stub the anthropic module unconditionally An import probe proves nothing about the real SDK: it may be absent (it lives in the proxy-runtime extra) and the tests/test_litellm/llms/anthropic test package can shadow it once collection puts that path on sys.path, which made the test order-sensitive across collection sets --- tests/test_litellm/integrations/test_helicone.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_litellm/integrations/test_helicone.py b/tests/test_litellm/integrations/test_helicone.py index eeef6fadbe5..da07fa1a9bf 100644 --- a/tests/test_litellm/integrations/test_helicone.py +++ b/tests/test_litellm/integrations/test_helicone.py @@ -13,13 +13,15 @@ def _claude_mapping(messages, response_obj): def test_claude_mapping_serializes_custom_tool_calls(monkeypatch): - try: - import anthropic # noqa: F401 - except ImportError: - stub = types.ModuleType("anthropic") - stub.HUMAN_PROMPT = "\n\nHuman:" - stub.AI_PROMPT = "\n\nAssistant:" - monkeypatch.setitem(sys.modules, "anthropic", stub) + """ + Stub the anthropic module unconditionally: the SDK may be absent (it lives in the + proxy-runtime extra), and the tests/test_litellm/llms/anthropic test package can + shadow it on sys.path, so an import probe proves nothing about the real SDK. + """ + stub = types.ModuleType("anthropic") + stub.HUMAN_PROMPT = "\n\nHuman:" + stub.AI_PROMPT = "\n\nAssistant:" + monkeypatch.setitem(sys.modules, "anthropic", stub) response_obj = { "id": "chatcmpl-1", "choices": [