Home / Function/ test_get_from_dict_or_env() — langchain Function Reference

test_get_from_dict_or_env() — langchain Function Reference

Architecture documentation for the test_get_from_dict_or_env() function in test_env.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5b399bdf_7f64_2edb_5c19_4915191c94b3["test_get_from_dict_or_env()"]
  cbc4378e_5398_a00f_c635_59e94677ff74["test_env.py"]
  5b399bdf_7f64_2edb_5c19_4915191c94b3 -->|defined in| cbc4378e_5398_a00f_c635_59e94677ff74
  style 5b399bdf_7f64_2edb_5c19_4915191c94b3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/utils/test_env.py lines 6–69

def test_get_from_dict_or_env() -> None:
    assert (
        get_from_dict_or_env(
            {
                "a": "foo",
            },
            ["a"],
            "__SOME_KEY_IN_ENV",
        )
        == "foo"
    )

    assert (
        get_from_dict_or_env(
            {
                "a": "foo",
            },
            ["b", "a"],
            "__SOME_KEY_IN_ENV",
        )
        == "foo"
    )

    assert (
        get_from_dict_or_env(
            {
                "a": "foo",
            },
            "a",
            "__SOME_KEY_IN_ENV",
        )
        == "foo"
    )

    assert (
        get_from_dict_or_env(
            {
                "a": "foo",
            },
            "not exists",
            "__SOME_KEY_IN_ENV",
            default="default",
        )
        == "default"
    )

    # Not the most obvious behavior, but
    # this is how it works right now
    with pytest.raises(
        ValueError,
        match="Did not find not exists, "
        "please add an environment variable `__SOME_KEY_IN_ENV` which contains it, "
        "or pass `not exists` as a named parameter",
    ):
        assert (
            get_from_dict_or_env(
                {
                    "a": "foo",
                },
                "not exists",
                "__SOME_KEY_IN_ENV",
            )
            is None
        )

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free