TestEmailDetection Class — langchain Architecture
Architecture documentation for the TestEmailDetection class in test_pii.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 86da6b6e_fd60_6255_80b9_e736a26b0ee4["TestEmailDetection"] 6dcffc03_fae9_01f8_ed9b_d30d8a73dd13["test_pii.py"] 86da6b6e_fd60_6255_80b9_e736a26b0ee4 -->|defined in| 6dcffc03_fae9_01f8_ed9b_d30d8a73dd13 51fe9c38_aa1b_5f24_a804_bb006c7082a5["test_detect_valid_email()"] 86da6b6e_fd60_6255_80b9_e736a26b0ee4 -->|method| 51fe9c38_aa1b_5f24_a804_bb006c7082a5 021a9b35_7c9d_24d4_1cf2_66a33dbdb49e["test_detect_multiple_emails()"] 86da6b6e_fd60_6255_80b9_e736a26b0ee4 -->|method| 021a9b35_7c9d_24d4_1cf2_66a33dbdb49e 365fb1ce_7cb2_1b8d_2dde_7cf9a2cbfa57["test_no_email()"] 86da6b6e_fd60_6255_80b9_e736a26b0ee4 -->|method| 365fb1ce_7cb2_1b8d_2dde_7cf9a2cbfa57 3804ff1b_db38_8b26_9c0e_fd2628d1f54a["test_invalid_email_format()"] 86da6b6e_fd60_6255_80b9_e736a26b0ee4 -->|method| 3804ff1b_db38_8b26_9c0e_fd2628d1f54a
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py lines 28–58
class TestEmailDetection:
"""Test email detection."""
def test_detect_valid_email(self) -> None:
content = "Contact me at john.doe@example.com for more info."
matches = detect_email(content)
assert len(matches) == 1
assert matches[0]["type"] == "email"
assert matches[0]["value"] == "john.doe@example.com"
assert matches[0]["start"] == 14
assert matches[0]["end"] == 34
def test_detect_multiple_emails(self) -> None:
content = "Email alice@test.com or bob@company.org"
matches = detect_email(content)
assert len(matches) == 2
assert matches[0]["value"] == "alice@test.com"
assert matches[1]["value"] == "bob@company.org"
def test_no_email(self) -> None:
content = "This text has no email addresses."
matches = detect_email(content)
assert len(matches) == 0
def test_invalid_email_format(self) -> None:
content = "Invalid emails: @test.com, user@, user@domain"
matches = detect_email(content)
# Should not match invalid formats
assert len(matches) == 0
Source
Frequently Asked Questions
What is the TestEmailDetection class?
TestEmailDetection is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py.
Where is TestEmailDetection defined?
TestEmailDetection is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py at line 28.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free