Home / Function/ test_sha1_warning_emitted_once() — langchain Function Reference

test_sha1_warning_emitted_once() — langchain Function Reference

Architecture documentation for the test_sha1_warning_emitted_once() function in test_caching.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  09a41e33_dd46_fa7a_e5e9_29ca64bec2c8["test_sha1_warning_emitted_once()"]
  6b1a1e58_d1bc_2756_cc7d_9c01f64a73a2["test_caching.py"]
  09a41e33_dd46_fa7a_e5e9_29ca64bec2c8 -->|defined in| 6b1a1e58_d1bc_2756_cc7d_9c01f64a73a2
  style 09a41e33_dd46_fa7a_e5e9_29ca64bec2c8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/embeddings/test_caching.py lines 218–238

def test_sha1_warning_emitted_once() -> None:
    """Test that a warning is emitted when using SHA-1 as the default key encoder."""
    module = importlib.import_module(CacheBackedEmbeddings.__module__)

    # Create a *temporary* MonkeyPatch object whose effects disappear
    # automatically when the with-block exits.
    with pytest.MonkeyPatch.context() as mp:
        # We're monkey patching the module to reset the `_warned_about_sha1` flag
        # which may have been set while testing other parts of the codebase.
        mp.setattr(module, "_warned_about_sha1", False, raising=False)

        store = InMemoryStore()
        emb = MockEmbeddings()

        with warnings.catch_warnings(record=True) as caught:
            warnings.simplefilter("always")
            CacheBackedEmbeddings.from_bytes_store(emb, store)  # triggers warning
            CacheBackedEmbeddings.from_bytes_store(emb, store)  # silent

        sha1_msgs = [w for w in caught if "SHA-1" in str(w.message)]
        assert len(sha1_msgs) == 1

Domain

Subdomains

Frequently Asked Questions

What does test_sha1_warning_emitted_once() do?
test_sha1_warning_emitted_once() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/embeddings/test_caching.py.
Where is test_sha1_warning_emitted_once() defined?
test_sha1_warning_emitted_once() is defined in libs/langchain/tests/unit_tests/embeddings/test_caching.py at line 218.

Analyze Your Own Codebase

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

Try Supermodel Free