oclaw/tests/conftest.py
oliver 420abac9f1 refactor: root-package imports (svc/runtime/interfaces) and fix PYTHONPATH
- Rename platform/ to svc/ to avoid shadowing stdlib platform.
- Replace from oclaw.* with from svc/runtime/interfaces; update -m CLI paths.
- tests/conftest: prepend repo root to sys.path (no parent-folder package name).
- CI: paths and offline_eval script under repo root.
- Ops scripts: PYTHONPATH must be repo root for python -m runtime.* (fixes gateway/WhatsApp sidecar startup).
- Fix default oclaw.json path in tabular/file attachment limits; stabilize attachment test config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 14:51:17 +08:00

21 lines
690 B
Python

from __future__ import annotations
import sys
from pathlib import Path
def _normalize_sys_path_for_repo_layout() -> None:
"""Put the repository root (contains ``svc/``, ``runtime/``, ``interfaces/``) first on ``sys.path``.
First-party imports use top-level packages ``svc``, ``runtime``, and ``interfaces``; they do not
depend on the checkout directory being named ``oclaw``.
"""
this_file = Path(__file__).resolve()
repo_root = this_file.parents[1]
rr = str(repo_root.resolve())
sys.path[:] = [p for p in sys.path if p and Path(p).resolve() != repo_root]
if rr not in sys.path:
sys.path.insert(0, rr)
_normalize_sys_path_for_repo_layout()