MockAsyncContextManager Class — langchain Architecture
Architecture documentation for the MockAsyncContextManager class in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD af82a5fb_17e6_2ea7_6022_f5b70af353d2["MockAsyncContextManager"] 48232d20_f8c1_b597_14fa_7dc407e9bfe5["test_base.py"] af82a5fb_17e6_2ea7_6022_f5b70af353d2 -->|defined in| 48232d20_f8c1_b597_14fa_7dc407e9bfe5 b2f91b35_f79c_36e9_6d18_34b13fce8041["__init__()"] af82a5fb_17e6_2ea7_6022_f5b70af353d2 -->|method| b2f91b35_f79c_36e9_6d18_34b13fce8041 9fc74cb5_c544_235e_c406_f6ef97bc9ea7["__aenter__()"] af82a5fb_17e6_2ea7_6022_f5b70af353d2 -->|method| 9fc74cb5_c544_235e_c406_f6ef97bc9ea7 4db11622_a7dc_cf09_7def_77d68ea4f769["__aexit__()"] af82a5fb_17e6_2ea7_6022_f5b70af353d2 -->|method| 4db11622_a7dc_cf09_7def_77d68ea4f769 a58b8d8d_2411_aa29_2e19_d2a33e18b204["__aiter__()"] af82a5fb_17e6_2ea7_6022_f5b70af353d2 -->|method| a58b8d8d_2411_aa29_2e19_d2a33e18b204 4b991108_3003_f51c_84df_324fd867ee40["__anext__()"] af82a5fb_17e6_2ea7_6022_f5b70af353d2 -->|method| 4b991108_3003_f51c_84df_324fd867ee40
Relationship Graph
Source Code
libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 317–342
class MockAsyncContextManager:
def __init__(self, chunk_list: list) -> None:
self.current_chunk = 0
self.chunk_list = chunk_list
self.chunk_num = len(chunk_list)
async def __aenter__(self) -> Self:
return self
async def __aexit__(
self,
exc_type: type[BaseException] | None,
exc: BaseException | None,
tb: TracebackType | None,
) -> None:
pass
def __aiter__(self) -> MockAsyncContextManager:
return self
async def __anext__(self) -> dict:
if self.current_chunk < self.chunk_num:
chunk = self.chunk_list[self.current_chunk]
self.current_chunk += 1
return chunk
raise StopAsyncIteration
Source
Frequently Asked Questions
What is the MockAsyncContextManager class?
MockAsyncContextManager is a class in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py.
Where is MockAsyncContextManager defined?
MockAsyncContextManager is defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py at line 317.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free