-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
58 lines (49 loc) · 1.74 KB
/
conftest.py
File metadata and controls
58 lines (49 loc) · 1.74 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
import os, pytest, pathlib
HEAVY_KEYWORDS = [
"integration",
"performance",
"conversation",
"advanced_workflow",
"revision_loops",
"state_manager",
"portfolio",
"planning",
]
def pytest_collection_modifyitems(config, items): # noqa: D401
if os.getenv("ESSAY_AGENT_OFFLINE_TEST") != "1":
return
skip_mark = pytest.mark.skip(reason="Skipped heavy or external-dependency tests in offline mode")
for item in items:
path = pathlib.Path(str(item.fspath))
# Skip heavy files or anything outside ./tests directory when offline
if any(kw in str(path) for kw in HEAVY_KEYWORDS) or path.parts and "tests" not in path.parts:
item.add_marker(skip_mark)
def pytest_ignore_collect(path, config): # noqa: D401
"""Prevent importing heavy or unset modules during offline mode.
This runs *before* the test module is imported so we can skip any files
whose path contains heavy keywords. It avoids ImportError crashes when
optional sub-systems (state manager, planner v2, etc.) are not available
in lightweight offline testing.
"""
import os, pathlib
if os.getenv("ESSAY_AGENT_OFFLINE_TEST") != "1":
return False
path_str = str(path)
# Skip anything outside tests/ dir or any heavy keyword match
if "tests/" not in path_str:
return True
heavy_keywords = HEAVY_KEYWORDS + [
"state_manager",
"conversation_cli",
"planner_executor",
"planning_integration",
"smart_planner",
"bug_fixes",
"phase2_integration",
"polish_display_fix",
"response_parser",
"cli_verbose",
"cli",
"workflow",
]
return any(kw in path_str for kw in heavy_keywords)