Tool unit tests¶
ToolsUnitTests
¶
Bases: ToolsTests
Base class for tools unit tests.
| METHOD | DESCRIPTION |
|---|---|
test_no_overrides_DO_NOT_OVERRIDE |
Test that no standard tests are overridden. |
tool |
Tool fixture. |
test_init |
Test init. |
test_init_from_env |
Test that the tool can be initialized from environment variables. |
test_has_name |
Tests that the tool has a name attribute to pass to chat models. |
test_has_input_schema |
Tests that the tool has an input schema. |
test_input_schema_matches_invoke_params |
Tests that the provided example params match the declared input schema. |
tool_constructor
abstractmethod
property
¶
Returns a class or instance of a tool to be tested.
tool_constructor_params
property
¶
tool_constructor_params: dict
Returns a dictionary of parameters to pass to the tool constructor.
tool_invoke_params_example
property
¶
tool_invoke_params_example: dict
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.
init_from_env_params
property
¶
Init from env params.
Return env vars, init args, and expected instance attrs for initializing from env vars.
test_no_overrides_DO_NOT_OVERRIDE
¶
Test that no standard tests are overridden.
test_init
¶
Test init.
Test that the tool can be initialized with tool_constructor and
tool_constructor_params. If this fails, check that the
keyword args defined in tool_constructor_params are valid.
test_init_from_env
¶
Test that the tool can be initialized from environment variables.
test_has_name
¶
test_has_name(tool: BaseTool) -> None
Tests that the tool has a name attribute to pass to chat models.
If this fails, add a name parameter to your tool.
test_has_input_schema
¶
test_has_input_schema(tool: BaseTool) -> None
Tests that the tool has an input schema.
If this fails, add an args_schema to your tool.
See this guide
and see how CalculatorInput is configured in the
CustomCalculatorTool.args_schema attribute