Home / Function/ test_import_all_using_dir() — langchain Function Reference

test_import_all_using_dir() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/test_imports.py lines 35–56

def test_import_all_using_dir() -> None:
    """Generate the public API for this package."""
    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]

        try:
            mod = importlib.import_module(module_name)
        except ModuleNotFoundError as e:
            msg = f"Could not import {module_name}"
            raise ModuleNotFoundError(msg) from e
        attributes = dir(mod)

        for name in attributes:
            if name.strip().startswith("_"):
                continue
            # Attempt to import the name from the module
            getattr(mod, name)

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free