Home / Function/ test_path_prefix_enforcement() — langchain Function Reference

test_path_prefix_enforcement() — langchain Function Reference

Architecture documentation for the test_path_prefix_enforcement() function in test_anthropic_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  47d36c15_194f_1061_2468_8b8b12b3e13a["test_path_prefix_enforcement()"]
  6ec57bb9_6c88_435d_d3c5_ccf498cb814d["TestFileOperations"]
  47d36c15_194f_1061_2468_8b8b12b3e13a -->|defined in| 6ec57bb9_6c88_435d_d3c5_ccf498cb814d
  style 47d36c15_194f_1061_2468_8b8b12b3e13a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/middleware/test_anthropic_tools.py lines 147–159

    def test_path_prefix_enforcement(self) -> None:
        """Test that path prefixes are enforced."""
        middleware = StateClaudeTextEditorMiddleware(
            allowed_path_prefixes=["/workspace"]
        )

        state: AnthropicToolsState = {"messages": []}

        # Should fail with /etc/passwd
        args = {"command": "create", "path": "/etc/passwd", "file_text": "test"}

        with pytest.raises(ValueError, match="Path must start with"):
            middleware._handle_create(args, state, "test_id")

Domain

Subdomains

Frequently Asked Questions

What does test_path_prefix_enforcement() do?
test_path_prefix_enforcement() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/middleware/test_anthropic_tools.py.
Where is test_path_prefix_enforcement() defined?
test_path_prefix_enforcement() is defined in libs/partners/anthropic/tests/unit_tests/middleware/test_anthropic_tools.py at line 147.

Analyze Your Own Codebase

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

Try Supermodel Free