Skip to content

Commit 1a39bad

Browse files
committed
chore(tests): increase speed by running tests in parallel
1 parent 40c509b commit 1a39bad

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

.github/workflows/cicd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
- uses: astral-sh/setup-uv@v4
2929
with:
3030
enable-cache: true
31-
- run: uv run pytest
31+
- run: uv run pytest -n auto

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"python.testing.pytestArgs": [
3-
"tests"
3+
"tests",
4+
"-n",
5+
"auto"
46
],
57
"python.testing.unittestEnabled": false,
68
"python.testing.pytestEnabled": true

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ dev = [
4545
"pre-commit>=3.5.0",
4646
"pytest-asyncio>=0.25.1",
4747
"pytest-cov>=5.0.0",
48+
"pytest-xdist>=3.6.1",
4849
"pytest>=8.3.3",
4950
"starlette-cramjam>=0.4.0",
5051
]

tests/conftest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Pytest fixtures."""
22

33
import os
4+
import socket
45
import threading
56
from typing import Any, AsyncGenerator
67
from unittest.mock import DEFAULT, AsyncMock, MagicMock, patch
@@ -118,10 +119,14 @@ def source_api():
118119
return app
119120

120121

121-
@pytest.fixture(scope="session")
122+
@pytest.fixture()
122123
def source_api_server(source_api):
123124
"""Run the source API in a background thread."""
124-
host, port = "127.0.0.1", 9119
125+
sock = socket.socket()
126+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
127+
sock.bind(("", 0))
128+
port = sock.getsockname()[1]
129+
host = "127.0.0.1"
125130
server = uvicorn.Server(
126131
uvicorn.Config(
127132
source_api,

uv.lock

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)