test_list_parser.py — langchain Source File
Architecture documentation for test_list_parser.py, a python file in the langchain codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8ae9f33a_614d_1533_e9a3_2a17ed09b1eb["test_list_parser.py"] cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] 8ae9f33a_614d_1533_e9a3_2a17ed09b1eb --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 8ae9f33a_614d_1533_e9a3_2a17ed09b1eb --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 e2506531_acbb_2ada_3335_6574849e4389["langchain_core.output_parsers.list"] 8ae9f33a_614d_1533_e9a3_2a17ed09b1eb --> e2506531_acbb_2ada_3335_6574849e4389 81c04601_d095_a27d_4af1_55e771bb2b6b["langchain_core.runnables.utils"] 8ae9f33a_614d_1533_e9a3_2a17ed09b1eb --> 81c04601_d095_a27d_4af1_55e771bb2b6b style 8ae9f33a_614d_1533_e9a3_2a17ed09b1eb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from collections.abc import AsyncIterator, Iterable
from typing import TypeVar
from langchain_core.output_parsers.list import (
CommaSeparatedListOutputParser,
MarkdownListOutputParser,
NumberedListOutputParser,
)
from langchain_core.runnables.utils import aadd, add
def test_single_item() -> None:
"""Test that a string with a single item is parsed to a list with that item."""
parser = CommaSeparatedListOutputParser()
text = "foo"
expected = ["foo"]
assert parser.parse(text) == expected
assert add(parser.transform(t for t in text)) == expected
assert list(parser.transform(t for t in text)) == [[a] for a in expected]
assert list(parser.transform(t for t in text.splitlines(keepends=True))) == [
[a] for a in expected
]
assert list(
parser.transform(" " + t if i > 0 else t for i, t in enumerate(text.split(" ")))
) == [[a] for a in expected]
assert list(parser.transform(iter([text]))) == [[a] for a in expected]
def test_multiple_items_with_spaces() -> None:
"""Test multiple items with spaces.
Test that a string with multiple comma-separated items
with spaces is parsed to a list.
"""
parser = CommaSeparatedListOutputParser()
text = "foo, bar, baz"
expected = ["foo", "bar", "baz"]
assert parser.parse(text) == expected
assert add(parser.transform(t for t in text)) == expected
assert list(parser.transform(t for t in text)) == [[a] for a in expected]
assert list(parser.transform(t for t in text.splitlines(keepends=True))) == [
[a] for a in expected
]
assert list(
parser.transform(" " + t if i > 0 else t for i, t in enumerate(text.split(" ")))
) == [[a] for a in expected]
assert list(parser.transform(iter([text]))) == [[a] for a in expected]
def test_multiple_items() -> None:
"""Test that a string with multiple comma-separated items is parsed to a list."""
parser = CommaSeparatedListOutputParser()
text = "foo,bar,baz"
expected = ["foo", "bar", "baz"]
assert parser.parse(text) == expected
assert add(parser.transform(t for t in text)) == expected
assert list(parser.transform(t for t in text)) == [[a] for a in expected]
// ... (255 more lines)
Domain
Subdomains
Functions
Dependencies
- collections.abc
- langchain_core.output_parsers.list
- langchain_core.runnables.utils
- typing
Source
Frequently Asked Questions
What does test_list_parser.py do?
test_list_parser.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in test_list_parser.py?
test_list_parser.py defines 11 function(s): aiter_from_iter, test_markdown_list, test_markdown_list_async, test_multiple_items, test_multiple_items_async, test_multiple_items_with_comma, test_multiple_items_with_spaces, test_numbered_list, test_numbered_list_async, test_single_item, and 1 more.
What does test_list_parser.py depend on?
test_list_parser.py imports 4 module(s): collections.abc, langchain_core.output_parsers.list, langchain_core.runnables.utils, typing.
Where is test_list_parser.py in the architecture?
test_list_parser.py is located at libs/core/tests/unit_tests/output_parsers/test_list_parser.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/core/tests/unit_tests/output_parsers).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free