TestBlockStrategy Class — langchain Architecture
Architecture documentation for the TestBlockStrategy class in test_pii.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5ff24760_234b_79ca_abb8_c2089bbd6343["TestBlockStrategy"] 2664a7f2_5314_35a9_a86d_2fce142dd0cf["PIIDetectionError"] 5ff24760_234b_79ca_abb8_c2089bbd6343 -->|extends| 2664a7f2_5314_35a9_a86d_2fce142dd0cf 6dcffc03_fae9_01f8_ed9b_d30d8a73dd13["test_pii.py"] 5ff24760_234b_79ca_abb8_c2089bbd6343 -->|defined in| 6dcffc03_fae9_01f8_ed9b_d30d8a73dd13 24f999e9_9704_8e67_cf20_15013ccdc1dc["test_block_raises_exception()"] 5ff24760_234b_79ca_abb8_c2089bbd6343 -->|method| 24f999e9_9704_8e67_cf20_15013ccdc1dc 8134a015_17c4_136e_ac67_700cff1eec15["test_block_with_multiple_matches()"] 5ff24760_234b_79ca_abb8_c2089bbd6343 -->|method| 8134a015_17c4_136e_ac67_700cff1eec15
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py lines 325–346
class TestBlockStrategy:
"""Test block strategy."""
def test_block_raises_exception(self) -> None:
middleware = PIIMiddleware("email", strategy="block")
state = AgentState[Any](messages=[HumanMessage("Email: test@example.com")])
with pytest.raises(PIIDetectionError) as exc_info:
middleware.before_model(state, Runtime())
assert exc_info.value.pii_type == "email"
assert len(exc_info.value.matches) == 1
assert "test@example.com" in exc_info.value.matches[0]["value"]
def test_block_with_multiple_matches(self) -> None:
middleware = PIIMiddleware("email", strategy="block")
state = AgentState[Any](messages=[HumanMessage("Emails: alice@test.com and bob@test.com")])
with pytest.raises(PIIDetectionError) as exc_info:
middleware.before_model(state, Runtime())
assert len(exc_info.value.matches) == 2
Extends
Source
Frequently Asked Questions
What is the TestBlockStrategy class?
TestBlockStrategy is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py.
Where is TestBlockStrategy defined?
TestBlockStrategy is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py at line 325.
What does TestBlockStrategy extend?
TestBlockStrategy extends PIIDetectionError.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free