Home / File/ test_formatting.py — langchain Source File

test_formatting.py — langchain Source File

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

File python CoreAbstractions MessageSchema 2 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  a6a847ed_f3e0_21e9_ab65_842ce3840099["test_formatting.py"]
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  a6a847ed_f3e0_21e9_ab65_842ce3840099 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  f4d905c6_a2b2_eb8f_be9b_7808b72f6a16["langchain_core.utils"]
  a6a847ed_f3e0_21e9_ab65_842ce3840099 --> f4d905c6_a2b2_eb8f_be9b_7808b72f6a16
  style a6a847ed_f3e0_21e9_ab65_842ce3840099 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Test formatting functionality."""

import pytest
from langchain_core.utils import formatter


def test_valid_formatting() -> None:
    """Test formatting works as expected."""
    template = "This is a {foo} test."
    output = formatter.format(template, foo="good")
    expected_output = "This is a good test."
    assert output == expected_output


def test_does_not_allow_args() -> None:
    """Test formatting raises error when args are provided."""
    template = "This is a {} test."
    with pytest.raises(
        ValueError,
        match="No arguments should be provided, "
        "everything should be passed as keyword arguments",
    ):
        formatter.format(template, "good")


def test_allows_extra_kwargs() -> None:
    """Test formatting allows extra keyword arguments."""
    template = "This is a {foo} test."
    output = formatter.format(template, foo="good", bar="oops")
    expected_output = "This is a good test."
    assert output == expected_output

Subdomains

Dependencies

  • langchain_core.utils
  • pytest

Frequently Asked Questions

What does test_formatting.py do?
test_formatting.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_formatting.py?
test_formatting.py defines 3 function(s): test_allows_extra_kwargs, test_does_not_allow_args, test_valid_formatting.
What does test_formatting.py depend on?
test_formatting.py imports 2 module(s): langchain_core.utils, pytest.
Where is test_formatting.py in the architecture?
test_formatting.py is located at libs/langchain/tests/unit_tests/test_formatting.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/langchain/tests/unit_tests).

Analyze Your Own Codebase

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

Try Supermodel Free