Home / File/ test_tools.py — langchain Source File

test_tools.py — langchain Source File

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

File python CoreAbstractions RunnableInterface 30 imports 135 functions 53 classes

Entity Profile

Dependency Diagram

graph LR
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2["test_tools.py"]
  614e7b9f_ed51_0780_749c_ff40b74963fc["inspect"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> 614e7b9f_ed51_0780_749c_ff40b74963fc
  7025b240_fdc3_cf68_b72f_f41dac94566b["json"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> 7025b240_fdc3_cf68_b72f_f41dac94566b
  d76a28c2_c3ab_00a8_5208_77807a49449d["sys"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> d76a28c2_c3ab_00a8_5208_77807a49449d
  243100a0_4629_4394_a66b_1f67b00ce784["textwrap"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> 243100a0_4629_4394_a66b_1f67b00ce784
  242d0b7d_a8ef_b66d_169b_c791b32a9cc9["threading"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> 242d0b7d_a8ef_b66d_169b_c791b32a9cc9
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  aac5f8ad_7f2a_3a8e_3b4b_b07d681cbdcf["dataclasses"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> aac5f8ad_7f2a_3a8e_3b4b_b07d681cbdcf
  af34f08b_0ede_2b87_0db6_983d74ed0249["datetime"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> af34f08b_0ede_2b87_0db6_983d74ed0249
  b188e880_71c6_b93e_127d_c22666293d37["enum"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> b188e880_71c6_b93e_127d_c22666293d37
  c990f2d7_9509_7cea_ca95_51ad57dbe5c6["functools"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> c990f2d7_9509_7cea_ca95_51ad57dbe5c6
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7
  63ae09a2_4a67_3eaf_7888_b0fd11776a0e["pydantic.v1"]
  e870136a_4fe1_4e00_2c09_1d4f86a16ff2 --> 63ae09a2_4a67_3eaf_7888_b0fd11776a0e
  style e870136a_4fe1_4e00_2c09_1d4f86a16ff2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Test the base tool implementation."""

import inspect
import json
import sys
import textwrap
import threading
from collections.abc import Callable
from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from functools import partial
from typing import (
    Annotated,
    Any,
    Generic,
    Literal,
    TypeVar,
    cast,
    get_type_hints,
)

import pytest
from pydantic import BaseModel, ConfigDict, Field, ValidationError
from pydantic.v1 import BaseModel as BaseModelV1
from pydantic.v1 import ValidationError as ValidationErrorV1
from typing_extensions import TypedDict, override

from langchain_core import tools
from langchain_core.callbacks import (
    AsyncCallbackManagerForToolRun,
    CallbackManagerForToolRun,
)
from langchain_core.callbacks.manager import (
    CallbackManagerForRetrieverRun,
)
from langchain_core.documents import Document
from langchain_core.messages import ToolCall, ToolMessage
from langchain_core.messages.tool import ToolOutputMixin
from langchain_core.retrievers import BaseRetriever
from langchain_core.runnables import (
    RunnableConfig,
    RunnableLambda,
    ensure_config,
)
from langchain_core.tools import (
    BaseTool,
    StructuredTool,
    Tool,
    ToolException,
    tool,
)
from langchain_core.tools.base import (
    TOOL_MESSAGE_BLOCK_TYPES,
    ArgsSchema,
    InjectedToolArg,
    InjectedToolCallId,
    SchemaAnnotationError,
    _DirectlyInjectedToolArg,
    _is_message_content_block,
// ... (3574 more lines)

Subdomains

Functions

Dependencies

  • collections.abc
  • dataclasses
  • datetime
  • enum
  • functools
  • inspect
  • json
  • langchain_core
  • langchain_core.callbacks
  • langchain_core.callbacks.manager
  • langchain_core.documents
  • langchain_core.messages
  • langchain_core.messages.tool
  • langchain_core.retrievers
  • langchain_core.runnables
  • langchain_core.tools
  • langchain_core.tools.base
  • langchain_core.utils.function_calling
  • langchain_core.utils.pydantic
  • langgraph.prebuilt
  • pydantic
  • pydantic.v1
  • pytest
  • sys
  • tests.unit_tests.fake.callbacks
  • tests.unit_tests.pydantic_utils
  • textwrap
  • threading
  • typing
  • typing_extensions

Frequently Asked Questions

What does test_tools.py do?
test_tools.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_tools.py?
test_tools.py defines 135 function(s): HAS_LANGGRAPH, TEST_MODELS, _get_parametrized_tools, _get_tool_call_json_schema, _mock_structured_tool_with_artifact, _tool_func_annotated_injected, _tool_func_directly_injected, afoo, asimple_foo, assert_bar, and 125 more.
What does test_tools.py depend on?
test_tools.py imports 30 module(s): collections.abc, dataclasses, datetime, enum, functools, inspect, json, langchain_core, and 22 more.
Where is test_tools.py in the architecture?
test_tools.py is located at libs/core/tests/unit_tests/test_tools.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/core/tests/unit_tests).

Analyze Your Own Codebase

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

Try Supermodel Free