MockTransport Class — anthropic-sdk-python Architecture
Architecture documentation for the MockTransport class in test_client.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 72103bd1_1134_848a_2d3f_c94e278d8ccb["MockTransport"] 9e5c097c_ec73_f29f_5858_a29a8c31dd98["test_client.py"] 72103bd1_1134_848a_2d3f_c94e278d8ccb -->|defined in| 9e5c097c_ec73_f29f_5858_a29a8c31dd98 343e8a08_70f8_ceb1_6827_099af28b5310["__init__()"] 72103bd1_1134_848a_2d3f_c94e278d8ccb -->|method| 343e8a08_70f8_ceb1_6827_099af28b5310 72bd3ada_1caa_bf9c_d186_08e28236ae48["handle_request()"] 72103bd1_1134_848a_2d3f_c94e278d8ccb -->|method| 72bd3ada_1caa_bf9c_d186_08e28236ae48 8c513383_0748_b093_2fa8_39ad8f9086ce["handle_async_request()"] 72103bd1_1134_848a_2d3f_c94e278d8ccb -->|method| 8c513383_0748_b093_2fa8_39ad8f9086ce
Relationship Graph
Source Code
tests/test_client.py lines 62–85
class MockTransport(httpx.BaseTransport, httpx.AsyncBaseTransport):
def __init__(
self,
handler: Callable[[httpx.Request], httpx.Response]
| Callable[[httpx.Request], Coroutine[Any, Any, httpx.Response]],
) -> None:
self.handler = handler
@override
def handle_request(
self,
request: httpx.Request,
) -> httpx.Response:
assert not inspect.iscoroutinefunction(self.handler), "handler must not be a coroutine function"
assert inspect.isfunction(self.handler), "handler must be a function"
return self.handler(request)
@override
async def handle_async_request(
self,
request: httpx.Request,
) -> httpx.Response:
assert inspect.iscoroutinefunction(self.handler), "handler must be a coroutine function"
return await self.handler(request)
Domain
Defined In
Source
Frequently Asked Questions
What is the MockTransport class?
MockTransport is a class in the anthropic-sdk-python codebase, defined in tests/test_client.py.
Where is MockTransport defined?
MockTransport is defined in tests/test_client.py at line 62.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free