

deps: add `pytest-async`
@9792549096664c6d7c43e81664e07ad3605de1c7
--- pyproject.toml
+++ pyproject.toml
... | ... | @@ -28,7 +28,8 @@ |
28 | 28 |
"webvtt-py==0.5.1", |
29 | 29 |
"srt==3.5.3", |
30 | 30 |
"basedpyright==1.13.0", |
31 |
- "pytest-xdist==3.6.1" |
|
31 |
+ "pytest-xdist==3.6.1", |
|
32 |
+ "pytest-asyncio>=0.24.0", |
|
32 | 33 |
] |
33 | 34 |
|
34 | 35 |
[build-system] |
--- tests/conftest.py
+++ tests/conftest.py
... | ... | @@ -1,13 +1,11 @@ |
1 |
-from collections.abc import Generator |
|
1 |
+from collections.abc import AsyncGenerator, Generator |
|
2 | 2 |
import logging |
3 |
-import os |
|
4 | 3 |
|
5 | 4 |
from fastapi.testclient import TestClient |
5 |
+from httpx import ASGITransport, AsyncClient |
|
6 | 6 |
from openai import OpenAI |
7 | 7 |
import pytest |
8 |
- |
|
9 |
-os.environ["WHISPER__MODEL"] = "Systran/faster-whisper-tiny.en" |
|
10 |
-from faster_whisper_server.main import app |
|
8 |
+import pytest_asyncio |
|
11 | 9 |
|
12 | 10 |
disable_loggers = ["multipart.multipart", "faster_whisper"] |
13 | 11 |
|
... | ... | @@ -20,10 +18,20 @@ |
20 | 18 |
|
21 | 19 |
@pytest.fixture() |
22 | 20 |
def client() -> Generator[TestClient, None, None]: |
21 |
+ from faster_whisper_server.main import app |
|
22 |
+ |
|
23 | 23 |
with TestClient(app) as client: |
24 | 24 |
yield client |
25 | 25 |
|
26 | 26 |
|
27 |
+@pytest_asyncio.fixture() |
|
28 |
+async def aclient() -> AsyncGenerator[AsyncClient, None]: |
|
29 |
+ from faster_whisper_server.main import app |
|
30 |
+ |
|
31 |
+ async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as aclient: |
|
32 |
+ yield aclient |
|
33 |
+ |
|
34 |
+ |
|
27 | 35 |
@pytest.fixture() |
28 | 36 |
def openai_client(client: TestClient) -> OpenAI: |
29 | 37 |
return OpenAI(api_key="cant-be-empty", http_client=client) |
--- tests/sse_test.py
+++ tests/sse_test.py
... | ... | @@ -2,16 +2,15 @@ |
2 | 2 |
import os |
3 | 3 |
|
4 | 4 |
from fastapi.testclient import TestClient |
5 |
+from faster_whisper_server.server_models import ( |
|
6 |
+ TranscriptionJsonResponse, |
|
7 |
+ TranscriptionVerboseJsonResponse, |
|
8 |
+) |
|
5 | 9 |
from httpx_sse import connect_sse |
6 | 10 |
import pytest |
7 | 11 |
import srt |
8 | 12 |
import webvtt |
9 | 13 |
import webvtt.vtt |
10 |
- |
|
11 |
-from faster_whisper_server.server_models import ( |
|
12 |
- TranscriptionJsonResponse, |
|
13 |
- TranscriptionVerboseJsonResponse, |
|
14 |
-) |
|
15 | 14 |
|
16 | 15 |
FILE_PATHS = ["audio.wav"] # HACK |
17 | 16 |
ENDPOINTS = [ |
--- uv.lock
+++ uv.lock
... | ... | @@ -297,6 +297,7 @@ |
297 | 297 |
dev = [ |
298 | 298 |
{ name = "basedpyright" }, |
299 | 299 |
{ name = "pytest" }, |
300 |
+ { name = "pytest-asyncio" }, |
|
300 | 301 |
{ name = "pytest-xdist" }, |
301 | 302 |
{ name = "ruff" }, |
302 | 303 |
{ name = "srt" }, |
... | ... | @@ -318,6 +319,7 @@ |
318 | 319 |
{ name = "pydantic", specifier = "==2.9.0" }, |
319 | 320 |
{ name = "pydantic-settings", specifier = "==2.4.0" }, |
320 | 321 |
{ name = "pytest", marker = "extra == 'dev'", specifier = "==8.3.2" }, |
322 |
+ { name = "pytest-asyncio", marker = "extra == 'dev'", specifier = ">=0.24.0" }, |
|
321 | 323 |
{ name = "pytest-xdist", marker = "extra == 'dev'", specifier = "==3.6.1" }, |
322 | 324 |
{ name = "python-multipart", specifier = "==0.0.9" }, |
323 | 325 |
{ name = "ruff", marker = "extra == 'dev'", specifier = "==0.5.3" }, |
... | ... | @@ -3440,6 +3442,18 @@ |
3440 | 3442 |
] |
3441 | 3443 |
|
3442 | 3444 |
[[package]] |
3445 |
+name = "pytest-asyncio" |
|
3446 |
+version = "0.24.0" |
|
3447 |
+source = { registry = "https://pypi.org/simple" } |
|
3448 |
+dependencies = [ |
|
3449 |
+ { name = "pytest" }, |
|
3450 |
+] |
|
3451 |
+sdist = { url = "https://files.pythonhosted.org/packages/52/6d/c6cf50ce320cf8611df7a1254d86233b3df7cc07f9b5f5cbcb82e08aa534/pytest_asyncio-0.24.0.tar.gz", hash = "sha256:d081d828e576d85f875399194281e92bf8a68d60d72d1a2faf2feddb6c46b276", size = 49855 } |
|
3452 |
+wheels = [ |
|
3453 |
+ { url = "https://files.pythonhosted.org/packages/96/31/6607dab48616902f76885dfcf62c08d929796fc3b2d2318faf9fd54dbed9/pytest_asyncio-0.24.0-py3-none-any.whl", hash = "sha256:a811296ed596b69bf0b6f3dc40f83bcaf341b155a269052d82efa2b25ac7037b", size = 18024 }, |
|
3454 |
+] |
|
3455 |
+ |
|
3456 |
+[[package]] |
|
3443 | 3457 |
name = "pytest-xdist" |
3444 | 3458 |
version = "3.6.1" |
3445 | 3459 |
source = { registry = "https://pypi.org/simple" } |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?