-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
76 lines (61 loc) · 2.43 KB
/
conftest.py
File metadata and controls
76 lines (61 loc) · 2.43 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""Global pytest configuration."""
import pytest
import os
# Disable Langfuse monitoring for tests to prevent connection errors
# More aggressive - set to empty strings rather than removing
os.environ["LANGFUSE_PUBLIC_KEY"] = ""
os.environ["LANGFUSE_SECRET_KEY"] = ""
os.environ["LANGFUSE_HOST"] = ""
os.environ["LANGFUSE_ENABLED"] = "false"
os.environ["LANGFUSE_RELEASE"] = ""
# Also try to disable via the library if it's imported
try:
import langfuse
langfuse.disabled = True
# Also monkey-patch the Langfuse class to prevent initialization
class DisabledLangfuse:
def __init__(self, *args, **kwargs):
pass
def __getattr__(self, name):
return lambda *args, **kwargs: None
langfuse.Langfuse = DisabledLangfuse
except ImportError:
pass
# Monkey-patch the decorator to do nothing
try:
from langfuse import decorators
decorators.observe = lambda **kwargs: lambda func: func
decorators.langfuse_context = type(
"MockContext",
(),
{"__getattr__": lambda self, name: lambda *args, **kwargs: None},
)()
except ImportError:
pass
def pytest_collection_modifyitems(config, items):
"""Configure test collection and marking."""
# Check if we're running the full test suite
running_full_suite = len(config.args) == 0 or any(
arg.startswith("-") for arg in config.args
)
for item in items:
# Mark slow tests
if "large_dataset" in str(item.fspath) or "performance" in str(item.name):
item.add_marker(pytest.mark.slow)
# Mark integration tests
if "integration" in str(item.fspath):
item.add_marker(pytest.mark.integration)
# Skip problematic tests based on environment variable
if os.environ.get("SKIP_SLOW_TESTS") == "1":
skip_slow = pytest.mark.skip(reason="Skipping slow tests")
for item in items:
if hasattr(item, "get_closest_marker") and item.get_closest_marker("slow"):
item.add_marker(skip_slow)
def pytest_configure(config):
"""Configure pytest with custom markers."""
config.addinivalue_line(
"markers", "slow: marks tests as slow (deselect with '-m \"not slow\"')"
)
config.addinivalue_line("markers", "integration: marks tests as integration tests")
config.addinivalue_line("markers", "unit: marks tests as unit tests")
config.addinivalue_line("markers", "api: marks tests that require API server")