Home / Function/ test_basic_function_schema_conversion() — anthropic-sdk-python Function Reference

test_basic_function_schema_conversion() — anthropic-sdk-python Function Reference

Architecture documentation for the test_basic_function_schema_conversion() function in test_functions.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  70d32c37_63f2_d6f3_31a1_1c2453475a94["test_basic_function_schema_conversion()"]
  e25ad18d_e1f6_726f_20bc_ac8e568d4e63["TestFunctionTool"]
  70d32c37_63f2_d6f3_31a1_1c2453475a94 -->|defined in| e25ad18d_e1f6_726f_20bc_ac8e568d4e63
  style 70d32c37_63f2_d6f3_31a1_1c2453475a94 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/lib/tools/test_functions.py lines 16–39

    def test_basic_function_schema_conversion(self) -> None:
        """Test basic function schema conversion with simple types."""

        def get_weather(location: str, unit: str = "celsius") -> str:
            """Get the weather for a specific location."""
            return f"Weather in {location} is 20 degrees {unit}"

        function_tool = beta_tool(get_weather)

        assert function_tool.name == "get_weather"
        assert function_tool.description == "Get the weather for a specific location."
        assert function_tool.input_schema == {
            "additionalProperties": False,
            "type": "object",
            "properties": {
                "location": {"title": "Location", "type": "string"},
                "unit": {"title": "Unit", "type": "string", "default": "celsius"},
            },
            "required": ["location"],
        }
        assert function_tool(location="CA") == "Weather in CA is 20 degrees celsius"

        # invalid types should be allowed because __call__ should just be the original function
        assert function_tool(location=cast(Any, 1)) == "Weather in 1 is 20 degrees celsius"

Subdomains

Frequently Asked Questions

What does test_basic_function_schema_conversion() do?
test_basic_function_schema_conversion() is a function in the anthropic-sdk-python codebase, defined in tests/lib/tools/test_functions.py.
Where is test_basic_function_schema_conversion() defined?
test_basic_function_schema_conversion() is defined in tests/lib/tools/test_functions.py at line 16.

Analyze Your Own Codebase

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

Try Supermodel Free