(request: FixtureRequest)
| 63 | |
| 64 | @pytest.fixture(scope="session") |
| 65 | async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncOpenAI]: |
| 66 | param = getattr(request, "param", True) |
| 67 | |
| 68 | # defaults |
| 69 | strict = True |
| 70 | http_client: None | httpx.AsyncClient = None |
| 71 | |
| 72 | if isinstance(param, bool): |
| 73 | strict = param |
| 74 | elif is_dict(param): |
| 75 | strict = param.get("strict", True) |
| 76 | assert isinstance(strict, bool) |
| 77 | |
| 78 | http_client_type = param.get("http_client", "httpx") |
| 79 | if http_client_type == "aiohttp": |
| 80 | http_client = DefaultAioHttpClient() |
| 81 | else: |
| 82 | raise TypeError(f"Unexpected fixture parameter type {type(param)}, expected bool or dict") |
| 83 | |
| 84 | async with AsyncOpenAI( |
| 85 | base_url=base_url, |
| 86 | api_key=api_key, |
| 87 | admin_api_key=admin_api_key, |
| 88 | _strict_response_validation=strict, |
| 89 | http_client=http_client, |
| 90 | ) as client: |
| 91 | yield client |
nothing calls this directly
no test coverage detected