File size: 994 Bytes
f3d078e
313814b
81fa68b
 
f3d078e
5aa421e
dc4f25f
f3d078e
313814b
 
 
 
dc4f25f
313814b
 
 
81fa68b
 
 
 
f3d078e
 
81fa68b
 
5aa421e
 
f3d078e
 
 
 
 
 
 
 
5aa421e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from collections.abc import AsyncGenerator, Generator
import logging

from fastapi.testclient import TestClient
from httpx import ASGITransport, AsyncClient
from openai import OpenAI
import pytest
import pytest_asyncio

disable_loggers = ["multipart.multipart", "faster_whisper"]


def pytest_configure() -> None:
    for logger_name in disable_loggers:
        logger = logging.getLogger(logger_name)
        logger.disabled = True


@pytest.fixture()
def client() -> Generator[TestClient, None, None]:
    from faster_whisper_server.main import app

    with TestClient(app) as client:
        yield client


@pytest_asyncio.fixture()
async def aclient() -> AsyncGenerator[AsyncClient, None]:
    from faster_whisper_server.main import app

    async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as aclient:
        yield aclient


@pytest.fixture()
def openai_client(client: TestClient) -> OpenAI:
    return OpenAI(api_key="cant-be-empty", http_client=client)