mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-11-16 21:37:01 +00:00
A plain pytest run was interrupted by 127 import errors before any test executed, because pytest prepended api/ and plugin api/ directories to sys.path so api/plugins.py shadowed the plugins namespace package, and because two test files reimported project modules under stubs and repointed files._base_dir into temporary trees while leaving extension and plugin caches warm for later files. Root pytest.ini now pins testpaths with importlib import mode, root conftest.py keeps tests importable and ignores handler modules named like test_*.py or *_test.py, and tests/test_model_config_project_presets.py and tests/test_tool_action_contracts.py restore sys.modules and runtime caches in autouse fixtures. The tests directory is appended rather than prepended to sys.path so sibling test imports keep working without shadowing same-named project modules, the tool action contracts fixture also restores reimported extension modules and a trailing test guards that no message_loop_prompts_after module keeps a stubbed helper, and the root AGENTS.md project section names the new pytest.ini and conftest.py owners. Validation: pytest --collect-only completes with no collection errors; pytest tests/test_tool_action_contracts.py (42 passed); tests/test_tool_action_policy.py (87 passed); full suite in a nested dev checkout fails 32, passes 3029, skips 7, the failures spanning the time travel and commands path cases the next commit unblocks plus the stub and assertion mismatches the commit after that fixes.
9 lines
313 B
Python
9 lines
313 B
Python
import sys
|
|
from pathlib import Path
|
|
|
|
# pytest prepends test dirs to sys.path, so api/plugins.py shadows the plugins namespace package
|
|
collect_ignore_glob = ["api/*_test.py", "plugins/*/api/test_*.py"]
|
|
|
|
_tests = str(Path(__file__).resolve().parent / "tests")
|
|
if _tests not in sys.path:
|
|
sys.path.append(_tests)
|