Home / Function/ test_secret_from_env_with_custom_error_message() — langchain Function Reference

test_secret_from_env_with_custom_error_message() — langchain Function Reference

Architecture documentation for the test_secret_from_env_with_custom_error_message() function in test_utils.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  64ac79e8_bf97_0bd3_6fca_b1329d2155d3["test_secret_from_env_with_custom_error_message()"]
  76328b48_c466_d255_3e8f_a315858c4c02["test_utils.py"]
  64ac79e8_bf97_0bd3_6fca_b1329d2155d3 -->|defined in| 76328b48_c466_d255_3e8f_a315858c4c02
  style 64ac79e8_bf97_0bd3_6fca_b1329d2155d3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/utils/test_utils.py lines 330–343

def test_secret_from_env_with_custom_error_message(
    monkeypatch: pytest.MonkeyPatch,
) -> None:
    # Unset the environment variable
    monkeypatch.delenv("TEST_KEY", raising=False)

    # Get the function without a default value but with a custom error message
    get_secret: Callable[[], SecretStr] = secret_from_env(
        "TEST_KEY", error_message="Custom error message"
    )

    # Assert that it raises a ValueError with the custom message
    with pytest.raises(ValueError, match="Custom error message"):
        get_secret()

Domain

Subdomains

Frequently Asked Questions

What does test_secret_from_env_with_custom_error_message() do?
test_secret_from_env_with_custom_error_message() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/utils/test_utils.py.
Where is test_secret_from_env_with_custom_error_message() defined?
test_secret_from_env_with_custom_error_message() is defined in libs/core/tests/unit_tests/utils/test_utils.py at line 330.

Analyze Your Own Codebase

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

Try Supermodel Free