Skip to content

Commit

Permalink
deps: add pytest-async
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedir Zadniprovskyi committed Sep 8, 2024
1 parent c555fe0 commit d9d5c02
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ dev = [
"webvtt-py==0.5.1",
"srt==3.5.3",
"basedpyright==1.13.0",
"pytest-xdist==3.6.1"
"pytest-xdist==3.6.1",
"pytest-asyncio>=0.24.0",
]

[build-system]
Expand Down
18 changes: 13 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from collections.abc import Generator
from collections.abc import AsyncGenerator, Generator
import logging
import os

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

os.environ["WHISPER__MODEL"] = "Systran/faster-whisper-tiny.en"
from faster_whisper_server.main import app
import pytest_asyncio

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

Expand All @@ -20,10 +18,20 @@ def pytest_configure() -> None:

@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)
9 changes: 4 additions & 5 deletions tests/sse_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
import os

from fastapi.testclient import TestClient
from faster_whisper_server.server_models import (
TranscriptionJsonResponse,
TranscriptionVerboseJsonResponse,
)
from httpx_sse import connect_sse
import pytest
import srt
import webvtt
import webvtt.vtt

from faster_whisper_server.server_models import (
TranscriptionJsonResponse,
TranscriptionVerboseJsonResponse,
)

FILE_PATHS = ["audio.wav"] # HACK
ENDPOINTS = [
"/v1/audio/transcriptions",
Expand Down
14 changes: 14 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d9d5c02

Please sign in to comment.