test_batch() — langchain Function Reference
Architecture documentation for the test_batch() function in test_fallbacks.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 14b0ba24_86ad_edf7_3d03_e8df98f7d29a["test_batch()"] d62d478e_a330_c328_7da4_58e88d780807["test_fallbacks.py"] 14b0ba24_86ad_edf7_3d03_e8df98f7d29a -->|defined in| d62d478e_a330_c328_7da4_58e88d780807 b4df7c29_3d15_7d1f_4ec5_5bcda5d0c06a["_assert_potential_error()"] 14b0ba24_86ad_edf7_3d03_e8df98f7d29a -->|calls| b4df7c29_3d15_7d1f_4ec5_5bcda5d0c06a style 14b0ba24_86ad_edf7_3d03_e8df98f7d29a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_fallbacks.py lines 166–207
def test_batch() -> None:
runnable = RunnableLambda(_runnable)
with pytest.raises(ValueError, match="missing exception"):
runnable.batch([{"text": "foo"}, {"text": "bar"}, {"text": "baz"}])
actual = runnable.batch(
[{"text": "foo"}, {"text": "bar"}, {"text": "baz"}], return_exceptions=True
)
expected = ["first", ValueError(), ValueError()]
_assert_potential_error(actual, expected)
runnable_with_single = runnable.with_fallbacks(
[runnable], exception_key="exception"
)
with pytest.raises(RuntimeError):
runnable_with_single.batch([{"text": "foo"}, {"text": "bar"}, {"text": "baz"}])
actual = runnable_with_single.batch(
[{"text": "foo"}, {"text": "bar"}, {"text": "baz"}], return_exceptions=True
)
expected = ["first", "second", RuntimeError()]
_assert_potential_error(actual, expected)
runnable_with_double = runnable.with_fallbacks(
[runnable, runnable], exception_key="exception"
)
actual = runnable_with_double.batch(
[{"text": "foo"}, {"text": "bar"}, {"text": "baz"}], return_exceptions=True
)
expected = ["first", "second", "third"]
_assert_potential_error(actual, expected)
runnable_with_double = runnable.with_fallbacks(
[runnable, runnable],
exception_key="exception",
exceptions_to_handle=(ValueError,),
)
actual = runnable_with_double.batch(
[{"text": "foo"}, {"text": "bar"}, {"text": "baz"}], return_exceptions=True
)
expected = ["first", "second", RuntimeError()]
_assert_potential_error(actual, expected)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_batch() do?
test_batch() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_fallbacks.py.
Where is test_batch() defined?
test_batch() is defined in libs/core/tests/unit_tests/runnables/test_fallbacks.py at line 166.
What does test_batch() call?
test_batch() calls 1 function(s): _assert_potential_error.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free