test_stdout.py — langchain Source File
Architecture documentation for test_stdout.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR e88cb48a_5344_bda0_2779_e219af1a998b["test_stdout.py"] feec1ec4_6917_867b_d228_b134d0ff8099["typing"] e88cb48a_5344_bda0_2779_e219af1a998b --> feec1ec4_6917_867b_d228_b134d0ff8099 f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"] e88cb48a_5344_bda0_2779_e219af1a998b --> f69d6389_263d_68a4_7fbf_f14c0602a9ba 17a62cb3_fefd_6320_b757_b53bb4a1c661["langchain_core.callbacks"] e88cb48a_5344_bda0_2779_e219af1a998b --> 17a62cb3_fefd_6320_b757_b53bb4a1c661 f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"] e88cb48a_5344_bda0_2779_e219af1a998b --> f85fae70_1011_eaec_151c_4083140ae9e5 514e0ffc_b989_a1fa_3f1e_84c7ef2702d6["langchain_classic.callbacks"] e88cb48a_5344_bda0_2779_e219af1a998b --> 514e0ffc_b989_a1fa_3f1e_84c7ef2702d6 9a0fc770_8c3f_14bc_3c7d_37852927778e["langchain_classic.chains.base"] e88cb48a_5344_bda0_2779_e219af1a998b --> 9a0fc770_8c3f_14bc_3c7d_37852927778e style e88cb48a_5344_bda0_2779_e219af1a998b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import Any
import pytest
from langchain_core.callbacks import CallbackManagerForChainRun
from typing_extensions import override
from langchain_classic.callbacks import StdOutCallbackHandler
from langchain_classic.chains.base import Chain
class FakeChain(Chain):
"""Fake chain class for testing purposes."""
be_correct: bool = True
the_input_keys: list[str] = ["foo"]
the_output_keys: list[str] = ["bar"]
@property
def input_keys(self) -> list[str]:
"""Input keys."""
return self.the_input_keys
@property
def output_keys(self) -> list[str]:
"""Output key of bar."""
return self.the_output_keys
@override
def _call(
self,
inputs: dict[str, str],
run_manager: CallbackManagerForChainRun | None = None,
) -> dict[str, str]:
return {"bar": "bar"}
def test_stdoutcallback(capsys: pytest.CaptureFixture) -> Any:
"""Test the stdout callback handler."""
chain_test = FakeChain(callbacks=[StdOutCallbackHandler(color="red")])
chain_test.invoke({"foo": "bar"})
# Capture the output
captured = capsys.readouterr()
# Assert the output is as expected
assert captured.out == (
"\n\n\x1b[1m> Entering new FakeChain "
"chain...\x1b[0m\n\n\x1b[1m> Finished chain.\x1b[0m\n"
)
Domain
Subdomains
Functions
Classes
Dependencies
- langchain_classic.callbacks
- langchain_classic.chains.base
- langchain_core.callbacks
- pytest
- typing
- typing_extensions
Source
Frequently Asked Questions
What does test_stdout.py do?
test_stdout.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, ApiManagement subdomain.
What functions are defined in test_stdout.py?
test_stdout.py defines 1 function(s): test_stdoutcallback.
What does test_stdout.py depend on?
test_stdout.py imports 6 module(s): langchain_classic.callbacks, langchain_classic.chains.base, langchain_core.callbacks, pytest, typing, typing_extensions.
Where is test_stdout.py in the architecture?
test_stdout.py is located at libs/langchain/tests/unit_tests/callbacks/test_stdout.py (domain: LangChainCore, subdomain: ApiManagement, directory: libs/langchain/tests/unit_tests/callbacks).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free