Home / File/ test_multi_query.py — langchain Source File

test_multi_query.py — langchain Source File

Architecture documentation for test_multi_query.py, a python file in the langchain codebase. 3 imports, 0 dependents.

File python LangChainCore Runnables 3 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  16e2aeee_9b1d_795d_9b71_7e897721e99e["test_multi_query.py"]
  f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"]
  16e2aeee_9b1d_795d_9b71_7e897721e99e --> f69d6389_263d_68a4_7fbf_f14c0602a9ba
  6a98b0a5_5607_0043_2e22_a46a464c2d62["langchain_core.documents"]
  16e2aeee_9b1d_795d_9b71_7e897721e99e --> 6a98b0a5_5607_0043_2e22_a46a464c2d62
  29c10e23_03f2_3fd5_5f43_f41cca6219e2["langchain_classic.retrievers.multi_query"]
  16e2aeee_9b1d_795d_9b71_7e897721e99e --> 29c10e23_03f2_3fd5_5f43_f41cca6219e2
  style 16e2aeee_9b1d_795d_9b71_7e897721e99e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import pytest
from langchain_core.documents import Document

from langchain_classic.retrievers.multi_query import (
    LineListOutputParser,
    _unique_documents,
)


@pytest.mark.parametrize(
    ("documents", "expected"),
    [
        ([], []),
        ([Document(page_content="foo")], [Document(page_content="foo")]),
        ([Document(page_content="foo")] * 2, [Document(page_content="foo")]),
        (
            [Document(page_content="foo", metadata={"bar": "baz"})] * 2,
            [Document(page_content="foo", metadata={"bar": "baz"})],
        ),
        (
            [Document(page_content="foo", metadata={"bar": [1, 2]})] * 2,
            [Document(page_content="foo", metadata={"bar": [1, 2]})],
        ),
        (
            [Document(page_content="foo", metadata={"bar": {1, 2}})] * 2,
            [Document(page_content="foo", metadata={"bar": {1, 2}})],
        ),
        (
            [
                Document(page_content="foo", metadata={"bar": [1, 2]}),
                Document(page_content="foo", metadata={"bar": [2, 1]}),
            ],
            [
                Document(page_content="foo", metadata={"bar": [1, 2]}),
                Document(page_content="foo", metadata={"bar": [2, 1]}),
            ],
        ),
    ],
)
def test__unique_documents(documents: list[Document], expected: list[Document]) -> None:
    assert _unique_documents(documents) == expected


@pytest.mark.parametrize(
    ("text", "expected"),
    [
        ("foo\nbar\nbaz", ["foo", "bar", "baz"]),
        ("foo\nbar\nbaz\n", ["foo", "bar", "baz"]),
        ("foo\n\nbar", ["foo", "bar"]),
    ],
)
def test_line_list_output_parser(text: str, expected: list[str]) -> None:
    parser = LineListOutputParser()
    assert parser.parse(text) == expected

Domain

Subdomains

Dependencies

  • langchain_classic.retrievers.multi_query
  • langchain_core.documents
  • pytest

Frequently Asked Questions

What does test_multi_query.py do?
test_multi_query.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What functions are defined in test_multi_query.py?
test_multi_query.py defines 2 function(s): test__unique_documents, test_line_list_output_parser.
What does test_multi_query.py depend on?
test_multi_query.py imports 3 module(s): langchain_classic.retrievers.multi_query, langchain_core.documents, pytest.
Where is test_multi_query.py in the architecture?
test_multi_query.py is located at libs/langchain/tests/unit_tests/retrievers/test_multi_query.py (domain: LangChainCore, subdomain: Runnables, directory: libs/langchain/tests/unit_tests/retrievers).

Analyze Your Own Codebase

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

Try Supermodel Free