mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-15 18:30:47 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
36
tests/conftest.py
Normal file
36
tests/conftest.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _normalize_sys_path_for_repo_layout() -> None:
|
||||
"""
|
||||
Allow running pytest from the ``oclaw`` subdirectory.
|
||||
|
||||
When cwd is ``.../chatgpt/oclaw``, Python may resolve ``import platform``
|
||||
to ``oclaw/platform`` instead of stdlib ``platform``. We force sys.path to
|
||||
prefer repository root (which contains the ``oclaw`` package directory).
|
||||
"""
|
||||
this_file = Path(__file__).resolve()
|
||||
oclaw_dir = this_file.parents[1]
|
||||
repo_root = oclaw_dir.parent
|
||||
|
||||
oclaw_dir_str = str(oclaw_dir)
|
||||
repo_root_str = str(repo_root)
|
||||
|
||||
sys.path[:] = [p for p in sys.path if p and Path(p).resolve() != oclaw_dir]
|
||||
if repo_root_str not in sys.path:
|
||||
sys.path.insert(0, repo_root_str)
|
||||
|
||||
mod = sys.modules.get("platform")
|
||||
if mod is not None:
|
||||
mod_file = str(getattr(mod, "__file__", "") or "")
|
||||
if "oclaw\\platform" in mod_file.replace("/", "\\"):
|
||||
sys.modules.pop("platform", None)
|
||||
importlib.import_module("platform")
|
||||
|
||||
|
||||
_normalize_sys_path_for_repo_layout()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue