Home / Function/ test_anthropic_proxy_from_environment() — langchain Function Reference

test_anthropic_proxy_from_environment() — langchain Function Reference

Architecture documentation for the test_anthropic_proxy_from_environment() function in test_chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  59b4a34c_62d8_6692_771b_1f6d7a9cc52d["test_anthropic_proxy_from_environment()"]
  18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"]
  59b4a34c_62d8_6692_771b_1f6d7a9cc52d -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311
  style 59b4a34c_62d8_6692_771b_1f6d7a9cc52d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 98–117

def test_anthropic_proxy_from_environment() -> None:
    """Test that proxy can be set from ANTHROPIC_PROXY environment variable."""
    proxy_url = "http://env-proxy.example.com:8080"

    # Test with environment variable set
    with patch.dict(os.environ, {"ANTHROPIC_PROXY": proxy_url}):
        llm = ChatAnthropic(model=MODEL_NAME)
        assert llm.anthropic_proxy == proxy_url

        # Should be able to create clients successfully
        sync_client = llm._client
        async_client = llm._async_client
        assert sync_client is not None
        assert async_client is not None

    # Test that explicit parameter overrides environment variable
    with patch.dict(os.environ, {"ANTHROPIC_PROXY": "http://env-proxy.com"}):
        explicit_proxy = "http://explicit-proxy.com"
        llm = ChatAnthropic(model=MODEL_NAME, anthropic_proxy=explicit_proxy)
        assert llm.anthropic_proxy == explicit_proxy

Domain

Subdomains

Frequently Asked Questions

What does test_anthropic_proxy_from_environment() do?
test_anthropic_proxy_from_environment() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test_anthropic_proxy_from_environment() defined?
test_anthropic_proxy_from_environment() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 98.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free