-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
48 lines (36 loc) · 1.41 KB
/
conftest.py
File metadata and controls
48 lines (36 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Pytest configuration and fixtures for the project."""
import asyncio
import pytest
def pytest_configure(config):
"""Configure pytest with custom settings."""
# Ensure agent evaluation tests run sequentially
config.addinivalue_line(
"markers",
"agent_evaluation: marks tests as agent evaluation tests (run sequentially)",
)
def pytest_collection_modifyitems(config, items):
"""Modify test collection to handle agent evaluation tests specially."""
agent_tests = []
other_tests = []
for item in items:
if item.get_closest_marker("agent_evaluation"):
agent_tests.append(item)
else:
other_tests.append(item)
# Run regular tests first, then agent tests sequentially
items[:] = other_tests + agent_tests
@pytest.fixture(scope="session")
def agent_evaluation_lock():
"""Provide a lock to ensure agent evaluation tests run sequentially."""
return asyncio.Lock()
@pytest.fixture
async def agent_evaluation_sequential(request, agent_evaluation_lock):
"""Ensure agent evaluation tests run one at a time."""
if request.node.get_closest_marker("agent_evaluation"):
async with agent_evaluation_lock:
# Add extra delay between agent tests to prevent API rate limiting
await asyncio.sleep(5)
yield
await asyncio.sleep(5) # Extra delay after test completion
else:
yield