test_nonlocals() — langchain Function Reference
Architecture documentation for the test_nonlocals() function in test_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d920bfce_afb1_96b9_1c2c_9f82a02d8e72["test_nonlocals()"] 8cf4d16f_b083_dd60_a3f8_d1616dc49226["test_utils.py"] d920bfce_afb1_96b9_1c2c_9f82a02d8e72 -->|defined in| 8cf4d16f_b083_dd60_a3f8_d1616dc49226 style d920bfce_afb1_96b9_1c2c_9f82a02d8e72 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_utils.py lines 44–75
def test_nonlocals() -> None:
agent = RunnableLambda[str, str](lambda x: x * 2)
def my_func(value: str, agent: dict[str, str]) -> str:
return agent.get("agent_name", value)
def my_func2(value: str) -> str:
return str(agent.get("agent_name", value)) # type: ignore[attr-defined]
def my_func3(value: str) -> str:
return agent.invoke(value)
def my_func4(value: str) -> str:
return global_agent.invoke(value)
def my_func5() -> tuple[Callable[[str], str], RunnableLambda]:
global_agent = RunnableLambda[str, str](lambda x: x * 3)
def my_func6(value: str) -> str:
return global_agent.invoke(value)
return my_func6, global_agent
assert get_function_nonlocals(my_func) == []
assert get_function_nonlocals(my_func2) == []
assert get_function_nonlocals(my_func3) == [agent.invoke]
assert get_function_nonlocals(my_func4) == [global_agent.invoke]
func, nl = my_func5()
assert get_function_nonlocals(func) == [nl.invoke]
assert RunnableLambda(my_func3).deps == [agent]
assert RunnableLambda(my_func4).deps == [global_agent]
assert RunnableLambda(func).deps == [nl]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_nonlocals() do?
test_nonlocals() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_utils.py.
Where is test_nonlocals() defined?
test_nonlocals() is defined in libs/core/tests/unit_tests/runnables/test_utils.py at line 44.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free