Home / Function/ test_init_from_env() — langchain Function Reference

test_init_from_env() — langchain Function Reference

Architecture documentation for the test_init_from_env() function in chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  c4c17371_4c47_276e_85fe_828398968736["test_init_from_env()"]
  f4b40f56_1158_0e72_1cac_d0121e4eabd8["ChatModelUnitTests"]
  c4c17371_4c47_276e_85fe_828398968736 -->|defined in| f4b40f56_1158_0e72_1cac_d0121e4eabd8
  454c7bc0_b7ba_c01c_6607_87da05bdc994["chat_model_class()"]
  c4c17371_4c47_276e_85fe_828398968736 -->|calls| 454c7bc0_b7ba_c01c_6607_87da05bdc994
  style c4c17371_4c47_276e_85fe_828398968736 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/standard-tests/langchain_tests/unit_tests/chat_models.py lines 943–967

    def test_init_from_env(self) -> None:
        """Test initialization from environment variables.

        Relies on the `init_from_env_params` property. Test is skipped if that
        property is not set.

        ??? question "Troubleshooting"

            If this test fails, ensure that `init_from_env_params` is specified
            correctly and that model parameters are properly set from environment
            variables during initialization.

        """
        env_params, model_params, expected_attrs = self.init_from_env_params
        if not env_params:
            pytest.skip("init_from_env_params not specified.")
        else:
            with mock.patch.dict(os.environ, env_params):
                model = self.chat_model_class(**model_params)
            assert model is not None
            for k, expected in expected_attrs.items():
                actual = getattr(model, k)
                if isinstance(actual, SecretStr):
                    actual = actual.get_secret_value()
                assert actual == expected

Domain

Subdomains

Frequently Asked Questions

What does test_init_from_env() do?
test_init_from_env() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/unit_tests/chat_models.py.
Where is test_init_from_env() defined?
test_init_from_env() is defined in libs/standard-tests/langchain_tests/unit_tests/chat_models.py at line 943.
What does test_init_from_env() call?
test_init_from_env() calls 1 function(s): chat_model_class.

Analyze Your Own Codebase

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

Try Supermodel Free