Home / Function/ test_import_all() — langchain Function Reference

test_import_all() — langchain Function Reference

Architecture documentation for the test_import_all() function in test_imports.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  f98b3768_2860_282b_04a2_d5c856773ae6["test_import_all()"]
  dede4bfb_94e2_8402_e3b8_00bd399e7446["test_imports.py"]
  f98b3768_2860_282b_04a2_d5c856773ae6 -->|defined in| dede4bfb_94e2_8402_e3b8_00bd399e7446
  style f98b3768_2860_282b_04a2_d5c856773ae6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/test_imports.py lines 9–32

def test_import_all() -> None:
    """Generate the public API for this package."""
    with warnings.catch_warnings():
        warnings.filterwarnings(action="ignore", category=UserWarning)
        library_code = PKG_ROOT / "langchain"
        for path in library_code.rglob("*.py"):
            # Calculate the relative path to the module
            module_name = path.relative_to(PKG_ROOT).with_suffix("").as_posix().replace("/", ".")
            if module_name.endswith("__init__"):
                # Without init
                module_name = module_name.rsplit(".", 1)[0]

            mod = importlib.import_module(module_name)

            all_attrs = getattr(mod, "__all__", [])

            for name in all_attrs:
                # Attempt to import the name from the module
                try:
                    obj = getattr(mod, name)
                    assert obj is not None
                except Exception as e:
                    msg = f"Could not import {module_name}.{name}"
                    raise AssertionError(msg) from e

Domain

Subdomains

Frequently Asked Questions

What does test_import_all() do?
test_import_all() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/test_imports.py.
Where is test_import_all() defined?
test_import_all() is defined in libs/langchain_v1/tests/unit_tests/test_imports.py at line 9.

Analyze Your Own Codebase

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

Try Supermodel Free