Home / File/ test_registration.py — langchain Source File

test_registration.py — langchain Source File

Architecture documentation for test_registration.py, a python file in the langchain codebase. 4 imports, 0 dependents.

File python CoreAbstractions MessageSchema 4 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  0f7359fb_a6e5_4609_1723_52437e3c8013["test_registration.py"]
  f7e87ee1_9877_33a0_72c5_d7a9b0e603a3["pkgutil"]
  0f7359fb_a6e5_4609_1723_52437e3c8013 --> f7e87ee1_9877_33a0_72c5_d7a9b0e603a3
  b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8["pathlib"]
  0f7359fb_a6e5_4609_1723_52437e3c8013 --> b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  0f7359fb_a6e5_4609_1723_52437e3c8013 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  23170be8_e8a8_a728_6471_2a7fe6195245["langchain_core.messages.block_translators"]
  0f7359fb_a6e5_4609_1723_52437e3c8013 --> 23170be8_e8a8_a728_6471_2a7fe6195245
  style 0f7359fb_a6e5_4609_1723_52437e3c8013 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import pkgutil
from pathlib import Path

import pytest

from langchain_core.messages.block_translators import PROVIDER_TRANSLATORS


def test_all_providers_registered() -> None:
    """Test that all block translators implemented in langchain-core are registered.

    If this test fails, it is likely that a block translator is implemented but not
    registered on import. Check that the provider is included in
    `langchain_core.messages.block_translators.__init__._register_translators`.
    """
    package_path = (
        Path(__file__).parents[4] / "langchain_core" / "messages" / "block_translators"
    )

    for module_info in pkgutil.iter_modules([str(package_path)]):
        module_name = module_info.name

        # Skip the __init__ module, any private modules, and `langchain_v0`, which is
        # only used to parse v0 multimodal inputs.
        if module_name.startswith("_") or module_name == "langchain_v0":
            continue

        if module_name not in PROVIDER_TRANSLATORS:
            pytest.fail(f"Block translator not registered: {module_name}")

Subdomains

Dependencies

  • langchain_core.messages.block_translators
  • pathlib
  • pkgutil
  • pytest

Frequently Asked Questions

What does test_registration.py do?
test_registration.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_registration.py?
test_registration.py defines 1 function(s): test_all_providers_registered.
What does test_registration.py depend on?
test_registration.py imports 4 module(s): langchain_core.messages.block_translators, pathlib, pkgutil, pytest.
Where is test_registration.py in the architecture?
test_registration.py is located at libs/core/tests/unit_tests/messages/block_translators/test_registration.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/core/tests/unit_tests/messages/block_translators).

Analyze Your Own Codebase

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

Try Supermodel Free