test_filecallback() — langchain Function Reference
Architecture documentation for the test_filecallback() function in test_file.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 100acb5f_bd9c_a651_cfbb_009e1e585010["test_filecallback()"] 208c1f71_5b87_0580_ea58_7fe3e9a67452["test_file.py"] 100acb5f_bd9c_a651_cfbb_009e1e585010 -->|defined in| 208c1f71_5b87_0580_ea58_7fe3e9a67452 dbd1329b_a843_29c6_04d5_0d55023c8909["strip_ansi()"] 100acb5f_bd9c_a651_cfbb_009e1e585010 -->|calls| dbd1329b_a843_29c6_04d5_0d55023c8909 style 100acb5f_bd9c_a651_cfbb_009e1e585010 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/tests/unit_tests/callbacks/test_file.py lines 47–71
def test_filecallback(tmp_path: pathlib.Path) -> None:
"""Test the file callback handler."""
log1 = tmp_path / "output.log"
handler = FileCallbackHandler(str(log1))
chain_test = FakeChain(callbacks=[handler])
chain_test.invoke({"foo": "bar"})
handler.close()
# Assert the output is as expected
assert "Entering new FakeChain chain" in strip_ansi(log1.read_text())
# Test using a callback manager
log2 = tmp_path / "output2.log"
with FileCallbackHandler(str(log2)) as handler_cm:
chain_test = FakeChain(callbacks=[handler_cm])
chain_test.invoke({"foo": "bar"})
assert "Entering new FakeChain chain" in strip_ansi(log2.read_text())
# Test passing via invoke callbacks
log3 = tmp_path / "output3.log"
with FileCallbackHandler(str(log3)) as handler_cm:
chain_test.invoke({"foo": "bar"}, {"callbacks": [handler_cm]})
assert "Entering new FakeChain chain" in strip_ansi(log3.read_text())
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_filecallback() do?
test_filecallback() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/callbacks/test_file.py.
Where is test_filecallback() defined?
test_filecallback() is defined in libs/langchain/tests/unit_tests/callbacks/test_file.py at line 47.
What does test_filecallback() call?
test_filecallback() calls 1 function(s): strip_ansi.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free