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 embeddings.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  7b41c4ce_7317_0b7b_c521_a2b37ceb175b["test_init_from_env()"]
  9eb1f026_8568_b7aa_2028_9c6b8a5f914d["EmbeddingsUnitTests"]
  7b41c4ce_7317_0b7b_c521_a2b37ceb175b -->|defined in| 9eb1f026_8568_b7aa_2028_9c6b8a5f914d
  3c2f6df8_ce40_53d4_f729_e7c457285a51["embeddings_class()"]
  7b41c4ce_7317_0b7b_c521_a2b37ceb175b -->|calls| 3c2f6df8_ce40_53d4_f729_e7c457285a51
  style 7b41c4ce_7317_0b7b_c521_a2b37ceb175b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/standard-tests/langchain_tests/unit_tests/embeddings.py lines 116–137

    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.

        ??? note "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, embeddings_params, expected_attrs = self.init_from_env_params
        if env_params:
            with mock.patch.dict(os.environ, env_params):
                model = self.embeddings_class(**embeddings_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/embeddings.py.
Where is test_init_from_env() defined?
test_init_from_env() is defined in libs/standard-tests/langchain_tests/unit_tests/embeddings.py at line 116.
What does test_init_from_env() call?
test_init_from_env() calls 1 function(s): embeddings_class.

Analyze Your Own Codebase

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

Try Supermodel Free