Skip to content

Commit 6c198b9

Browse files
author
jc
committed
Parallelizing unit tests
1 parent 3c83000 commit 6c198b9

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ dev = [
4242
"pytest>=8.4.2",
4343
"pytest-asyncio>=1.2.0",
4444
"pytest-cov>=4.0.0",
45+
"pytest-xdist>=3.5.0",
4546
"ruff>=0.1.0",
4647
"mypy>=1.0.0",
4748
"types-authlib>=1.6.2.20250914",
@@ -96,7 +97,7 @@ disallow_incomplete_defs = false
9697

9798
[tool.pytest.ini_options]
9899
minversion = "7.0"
99-
addopts = "-q --tb=short"
100+
addopts = "-q --tb=short -n auto --dist=loadgroup"
100101
python_files = "tests.py test_*.py *_tests.py"
101102
pythonpath = ["."]
102103
testpaths = ["tests"]
@@ -105,4 +106,5 @@ markers = [
105106
"manual: marks tests as requiring manual intervention (deselect with '-m \"not manual\"')",
106107
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
107108
"k8s: marks tests that require Kubernetes cluster",
109+
"serial: marks tests that must run serially (not in parallel)",
108110
]

tests/unit/app/api/test_ratelimit.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
not REDIS_AVAILABLE, reason="Redis is not running or not accessible"
2222
)
2323

24+
# Mark Redis tests to run in same xdist group to avoid shared state issues
25+
redis_xdist_group = pytest.mark.xdist_group("redis_rate_limiter")
26+
2427

2528
class TestRateLimiting:
2629
"""Test rate limiting functionality."""
@@ -37,7 +40,7 @@ def test_config(self) -> ConfigData:
3740
"local",
3841
pytest.param(
3942
"redis",
40-
marks=requires_redis,
43+
marks=[requires_redis, redis_xdist_group],
4144
),
4245
]
4346
)

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)