Fedir Zadniprovskyi commited on
Commit
f3d078e
·
1 Parent(s): c22dada

deps: add `pytest-async`

Browse files
Files changed (4) hide show
  1. pyproject.toml +2 -1
  2. tests/conftest.py +13 -5
  3. tests/sse_test.py +4 -5
  4. uv.lock +14 -0
pyproject.toml CHANGED
@@ -28,7 +28,8 @@ dev = [
28
  "webvtt-py==0.5.1",
29
  "srt==3.5.3",
30
  "basedpyright==1.13.0",
31
- "pytest-xdist==3.6.1"
 
32
  ]
33
 
34
  [build-system]
 
28
  "webvtt-py==0.5.1",
29
  "srt==3.5.3",
30
  "basedpyright==1.13.0",
31
+ "pytest-xdist==3.6.1",
32
+ "pytest-asyncio>=0.24.0",
33
  ]
34
 
35
  [build-system]
tests/conftest.py CHANGED
@@ -1,13 +1,11 @@
1
- from collections.abc import Generator
2
  import logging
3
- import os
4
 
5
  from fastapi.testclient import TestClient
 
6
  from openai import OpenAI
7
  import pytest
8
-
9
- os.environ["WHISPER__MODEL"] = "Systran/faster-whisper-tiny.en"
10
- from faster_whisper_server.main import app
11
 
12
  disable_loggers = ["multipart.multipart", "faster_whisper"]
13
 
@@ -20,10 +18,20 @@ def pytest_configure() -> None:
20
 
21
  @pytest.fixture()
22
  def client() -> Generator[TestClient, None, None]:
 
 
23
  with TestClient(app) as client:
24
  yield client
25
 
26
 
 
 
 
 
 
 
 
 
27
  @pytest.fixture()
28
  def openai_client(client: TestClient) -> OpenAI:
29
  return OpenAI(api_key="cant-be-empty", http_client=client)
 
1
+ from collections.abc import AsyncGenerator, Generator
2
  import logging
 
3
 
4
  from fastapi.testclient import TestClient
5
+ from httpx import ASGITransport, AsyncClient
6
  from openai import OpenAI
7
  import pytest
8
+ import pytest_asyncio
 
 
9
 
10
  disable_loggers = ["multipart.multipart", "faster_whisper"]
11
 
 
18
 
19
  @pytest.fixture()
20
  def client() -> Generator[TestClient, None, None]:
21
+ from faster_whisper_server.main import app
22
+
23
  with TestClient(app) as client:
24
  yield client
25
 
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
+
35
  @pytest.fixture()
36
  def openai_client(client: TestClient) -> OpenAI:
37
  return OpenAI(api_key="cant-be-empty", http_client=client)
tests/sse_test.py CHANGED
@@ -2,17 +2,16 @@ import json
2
  import os
3
 
4
  from fastapi.testclient import TestClient
 
 
 
 
5
  from httpx_sse import connect_sse
6
  import pytest
7
  import srt
8
  import webvtt
9
  import webvtt.vtt
10
 
11
- from faster_whisper_server.server_models import (
12
- TranscriptionJsonResponse,
13
- TranscriptionVerboseJsonResponse,
14
- )
15
-
16
  FILE_PATHS = ["audio.wav"] # HACK
17
  ENDPOINTS = [
18
  "/v1/audio/transcriptions",
 
2
  import os
3
 
4
  from fastapi.testclient import TestClient
5
+ from faster_whisper_server.server_models import (
6
+ TranscriptionJsonResponse,
7
+ TranscriptionVerboseJsonResponse,
8
+ )
9
  from httpx_sse import connect_sse
10
  import pytest
11
  import srt
12
  import webvtt
13
  import webvtt.vtt
14
 
 
 
 
 
 
15
  FILE_PATHS = ["audio.wav"] # HACK
16
  ENDPOINTS = [
17
  "/v1/audio/transcriptions",
uv.lock CHANGED
@@ -297,6 +297,7 @@ client = [
297
  dev = [
298
  { name = "basedpyright" },
299
  { name = "pytest" },
 
300
  { name = "pytest-xdist" },
301
  { name = "ruff" },
302
  { name = "srt" },
@@ -318,6 +319,7 @@ requires-dist = [
318
  { name = "pydantic", specifier = "==2.9.0" },
319
  { name = "pydantic-settings", specifier = "==2.4.0" },
320
  { name = "pytest", marker = "extra == 'dev'", specifier = "==8.3.2" },
 
321
  { name = "pytest-xdist", marker = "extra == 'dev'", specifier = "==3.6.1" },
322
  { name = "python-multipart", specifier = "==0.0.9" },
323
  { name = "ruff", marker = "extra == 'dev'", specifier = "==0.5.3" },
@@ -3439,6 +3441,18 @@ wheels = [
3439
  { url = "https://files.pythonhosted.org/packages/0f/f9/cf155cf32ca7d6fa3601bc4c5dd19086af4b320b706919d48a4c79081cf9/pytest-8.3.2-py3-none-any.whl", hash = "sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5", size = 341802 },
3440
  ]
3441
 
 
 
 
 
 
 
 
 
 
 
 
 
3442
  [[package]]
3443
  name = "pytest-xdist"
3444
  version = "3.6.1"
 
297
  dev = [
298
  { name = "basedpyright" },
299
  { name = "pytest" },
300
+ { name = "pytest-asyncio" },
301
  { name = "pytest-xdist" },
302
  { name = "ruff" },
303
  { name = "srt" },
 
319
  { name = "pydantic", specifier = "==2.9.0" },
320
  { name = "pydantic-settings", specifier = "==2.4.0" },
321
  { name = "pytest", marker = "extra == 'dev'", specifier = "==8.3.2" },
322
+ { name = "pytest-asyncio", marker = "extra == 'dev'", specifier = ">=0.24.0" },
323
  { name = "pytest-xdist", marker = "extra == 'dev'", specifier = "==3.6.1" },
324
  { name = "python-multipart", specifier = "==0.0.9" },
325
  { name = "ruff", marker = "extra == 'dev'", specifier = "==0.5.3" },
 
3441
  { url = "https://files.pythonhosted.org/packages/0f/f9/cf155cf32ca7d6fa3601bc4c5dd19086af4b320b706919d48a4c79081cf9/pytest-8.3.2-py3-none-any.whl", hash = "sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5", size = 341802 },
3442
  ]
3443
 
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]]
3457
  name = "pytest-xdist"
3458
  version = "3.6.1"