Home / File/ test_base.py — langchain Source File

test_base.py — langchain Source File

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

File python LangChainCore LanguageModelBase 11 imports 18 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  cbc5b920_9825_eac5_8cc4_bc8187fb214c["test_base.py"]
  b7996424_637b_0b54_6edf_2e18e9c1a8bf["re"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> b7996424_637b_0b54_6edf_2e18e9c1a8bf
  02f66451_d2a9_e7c3_9765_c3a7594721ad["uuid"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> 02f66451_d2a9_e7c3_9765_c3a7594721ad
  feec1ec4_6917_867b_d228_b134d0ff8099["typing"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> feec1ec4_6917_867b_d228_b134d0ff8099
  f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> f69d6389_263d_68a4_7fbf_f14c0602a9ba
  e61aa479_9dc0_09a0_8864_cbf23b8b506c["langchain_core.callbacks.manager"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> e61aa479_9dc0_09a0_8864_cbf23b8b506c
  e591872a_3e49_bc45_c0f0_f1901792a836["langchain_core.tracers.context"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> e591872a_3e49_bc45_c0f0_f1901792a836
  f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> f85fae70_1011_eaec_151c_4083140ae9e5
  8d1ab66e_47c1_1140_c3a5_5112af3b1cac["langchain_classic.base_memory"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> 8d1ab66e_47c1_1140_c3a5_5112af3b1cac
  9a0fc770_8c3f_14bc_3c7d_37852927778e["langchain_classic.chains.base"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> 9a0fc770_8c3f_14bc_3c7d_37852927778e
  dd2a6d83_f336_1d7a_768e_6d7de69a6ce3["langchain_classic.schema"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> dd2a6d83_f336_1d7a_768e_6d7de69a6ce3
  1546e955_88c9_055e_7a67_db109de543dc["tests.unit_tests.callbacks.fake_callback_handler"]
  cbc5b920_9825_eac5_8cc4_bc8187fb214c --> 1546e955_88c9_055e_7a67_db109de543dc
  style cbc5b920_9825_eac5_8cc4_bc8187fb214c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Test logic on base chain class."""

import re
import uuid
from typing import Any

import pytest
from langchain_core.callbacks.manager import CallbackManagerForChainRun
from langchain_core.tracers.context import collect_runs
from typing_extensions import override

from langchain_classic.base_memory import BaseMemory
from langchain_classic.chains.base import Chain
from langchain_classic.schema import RUN_KEY
from tests.unit_tests.callbacks.fake_callback_handler import FakeCallbackHandler


class FakeMemory(BaseMemory):
    """Fake memory class for testing purposes."""

    @property
    def memory_variables(self) -> list[str]:
        """Return baz variable."""
        return ["baz"]

    @override
    def load_memory_variables(
        self,
        inputs: dict[str, Any] | None = None,
    ) -> dict[str, str]:
        """Return baz variable."""
        return {"baz": "foo"}

    def save_context(self, inputs: dict[str, Any], outputs: dict[str, str]) -> None:
        """Pass."""

    def clear(self) -> None:
        """Pass."""


class FakeChain(Chain):
    """Fake chain class for testing purposes."""

    be_correct: bool = True
    the_input_keys: list[str] = ["foo"]
    the_output_keys: list[str] = ["bar"]

    @property
    def input_keys(self) -> list[str]:
        """Input keys."""
        return self.the_input_keys

    @property
    def output_keys(self) -> list[str]:
        """Output key of bar."""
        return self.the_output_keys

    @override
    def _call(
        self,
// ... (186 more lines)

Domain

Subdomains

Dependencies

  • langchain_classic.base_memory
  • langchain_classic.chains.base
  • langchain_classic.schema
  • langchain_core.callbacks.manager
  • langchain_core.tracers.context
  • pytest
  • re
  • tests.unit_tests.callbacks.fake_callback_handler
  • typing
  • typing_extensions
  • uuid

Frequently Asked Questions

What does test_base.py do?
test_base.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, LanguageModelBase subdomain.
What functions are defined in test_base.py?
test_base.py defines 18 function(s): test_bad_inputs, test_bad_outputs, test_correct_call, test_manually_specify_rid, test_manually_specify_rid_async, test_multiple_output_keys_error, test_run_arg_with_memory, test_run_args_and_kwargs_error, test_run_info, test_run_kwargs, and 8 more.
What does test_base.py depend on?
test_base.py imports 11 module(s): langchain_classic.base_memory, langchain_classic.chains.base, langchain_classic.schema, langchain_core.callbacks.manager, langchain_core.tracers.context, pytest, re, tests.unit_tests.callbacks.fake_callback_handler, and 3 more.
Where is test_base.py in the architecture?
test_base.py is located at libs/langchain/tests/unit_tests/chains/test_base.py (domain: LangChainCore, subdomain: LanguageModelBase, directory: libs/langchain/tests/unit_tests/chains).

Analyze Your Own Codebase

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

Try Supermodel Free