Home / Function/ test_markdown_list() — langchain Function Reference

test_markdown_list() — langchain Function Reference

Architecture documentation for the test_markdown_list() function in test_list_parser.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  f9fc4098_1a3a_da03_b7df_51713593318f["test_markdown_list()"]
  8ae9f33a_614d_1533_e9a3_2a17ed09b1eb["test_list_parser.py"]
  f9fc4098_1a3a_da03_b7df_51713593318f -->|defined in| 8ae9f33a_614d_1533_e9a3_2a17ed09b1eb
  style f9fc4098_1a3a_da03_b7df_51713593318f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/output_parsers/test_list_parser.py lines 127–160

def test_markdown_list() -> None:
    parser = MarkdownListOutputParser()
    text1 = (
        "Your response should be a numbered - not a list item - "
        "list with each item on a new line."
        "For example: \n- foo\n- bar\n- baz"
    )

    text2 = "Items:\n- apple\n     - banana\n- cherry"

    text3 = "No items in the list."

    for text, expected in [
        (text1, ["foo", "bar", "baz"]),
        (text2, ["apple", "banana", "cherry"]),
        (text3, []),
    ]:
        expectedlist = [[a] for a in expected]
        assert parser.parse(text) == expected
        assert add(parser.transform(t for t in text)) == (expected or None)
        assert list(parser.transform(t for t in text)) == expectedlist
        assert (
            list(parser.transform(t for t in text.splitlines(keepends=True)))
            == expectedlist
        )
        assert (
            list(
                parser.transform(
                    " " + t if i > 0 else t for i, t in enumerate(text.split(" "))
                )
            )
            == expectedlist
        )
        assert list(parser.transform(iter([text]))) == expectedlist

Subdomains

Frequently Asked Questions

What does test_markdown_list() do?
test_markdown_list() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/output_parsers/test_list_parser.py.
Where is test_markdown_list() defined?
test_markdown_list() is defined in libs/core/tests/unit_tests/output_parsers/test_list_parser.py at line 127.

Analyze Your Own Codebase

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

Try Supermodel Free