Home / Class/ ToolsTests Class — langchain Architecture

ToolsTests Class — langchain Architecture

Architecture documentation for the ToolsTests class in tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  98288f9f_1f36_11e6_3122_c061243aebd9["ToolsTests"]
  2d95e59f_5168_1366_c8c2_e21e157938b5["BaseStandardTests"]
  98288f9f_1f36_11e6_3122_c061243aebd9 -->|extends| 2d95e59f_5168_1366_c8c2_e21e157938b5
  5ebe56ae_0ac8_cb13_b5a9_ee567b924009["BaseTool"]
  98288f9f_1f36_11e6_3122_c061243aebd9 -->|extends| 5ebe56ae_0ac8_cb13_b5a9_ee567b924009
  c7851a8c_0dc1_c211_50a5_ab8ccadfe0bb["tools.py"]
  98288f9f_1f36_11e6_3122_c061243aebd9 -->|defined in| c7851a8c_0dc1_c211_50a5_ab8ccadfe0bb
  1ce69191_e8e4_cee2_7983_356285bf3529["tool_constructor()"]
  98288f9f_1f36_11e6_3122_c061243aebd9 -->|method| 1ce69191_e8e4_cee2_7983_356285bf3529
  b5247608_a342_759e_7661_768029418c10["tool_constructor_params()"]
  98288f9f_1f36_11e6_3122_c061243aebd9 -->|method| b5247608_a342_759e_7661_768029418c10
  16dca8b7_86ca_7096_170e_852f94cf5cc9["tool_invoke_params_example()"]
  98288f9f_1f36_11e6_3122_c061243aebd9 -->|method| 16dca8b7_86ca_7096_170e_852f94cf5cc9
  60d38341_1724_84aa_ce57_d57cbc254a37["tool()"]
  98288f9f_1f36_11e6_3122_c061243aebd9 -->|method| 60d38341_1724_84aa_ce57_d57cbc254a37

Relationship Graph

Source Code

libs/standard-tests/langchain_tests/unit_tests/tools.py lines 17–55

class ToolsTests(BaseStandardTests):
    """Base class for testing tools.

    This won't show in the documentation, but the docstrings will be inherited by
    subclasses.
    """

    @property
    @abstractmethod
    def tool_constructor(self) -> type[BaseTool] | BaseTool:
        """Returns a class or instance of a tool to be tested."""
        ...

    @property
    def tool_constructor_params(self) -> dict[str, Any]:
        """Returns a dictionary of parameters to pass to the tool constructor."""
        return {}

    @property
    def tool_invoke_params_example(self) -> dict[str, Any]:
        """Returns a dictionary representing the "args" of an example tool call.

        This should NOT be a `ToolCall` dict - it should not have
        `{"name", "id", "args"}` keys.
        """
        return {}

    @pytest.fixture
    def tool(self) -> BaseTool:
        """Tool fixture."""
        if isinstance(self.tool_constructor, BaseTool):
            if self.tool_constructor_params != {}:
                msg = (
                    "If tool_constructor is an instance of BaseTool, "
                    "tool_constructor_params must be empty"
                )
                raise ValueError(msg)
            return self.tool_constructor
        return self.tool_constructor(**self.tool_constructor_params)

Frequently Asked Questions

What is the ToolsTests class?
ToolsTests is a class in the langchain codebase, defined in libs/standard-tests/langchain_tests/unit_tests/tools.py.
Where is ToolsTests defined?
ToolsTests is defined in libs/standard-tests/langchain_tests/unit_tests/tools.py at line 17.
What does ToolsTests extend?
ToolsTests extends BaseStandardTests, BaseTool.

Analyze Your Own Codebase

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

Try Supermodel Free