test_runnable_branch_invoke() — langchain Function Reference
Architecture documentation for the test_runnable_branch_invoke() function in test_runnable.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 14a5c9f2_319d_6f06_7255_d4207d793ac6["test_runnable_branch_invoke()"] 26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"] 14a5c9f2_319d_6f06_7255_d4207d793ac6 -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5 fb618d44_c03b_ea8b_385b_2278dfb173d4["invoke()"] 14a5c9f2_319d_6f06_7255_d4207d793ac6 -->|calls| fb618d44_c03b_ea8b_385b_2278dfb173d4 style 14a5c9f2_319d_6f06_7255_d4207d793ac6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_runnable.py lines 4539–4559
def test_runnable_branch_invoke() -> None:
# Test with single branch
def raise_value_error(_: int) -> int:
"""Raise a value error."""
msg = "x is too large"
raise ValueError(msg)
branch = RunnableBranch[int, int](
(lambda x: x > 100, raise_value_error),
# mypy cannot infer types from the lambda
(lambda x: x > 0 and x < 5, lambda x: x + 1),
(lambda x: x > 5, lambda x: x * 10),
lambda x: x - 1,
)
assert branch.invoke(1) == 2
assert branch.invoke(10) == 100
assert branch.invoke(0) == -1
# Should raise an exception
with pytest.raises(ValueError, match="x is too large"):
branch.invoke(1000)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_runnable_branch_invoke() do?
test_runnable_branch_invoke() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is test_runnable_branch_invoke() defined?
test_runnable_branch_invoke() is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 4539.
What does test_runnable_branch_invoke() call?
test_runnable_branch_invoke() calls 1 function(s): invoke.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free