Files
quercus/tests/conftest.py
T
Mike-Solar e0db5ab2cf P1: host-agnostic quercus-core with agent loop, providers, and tool schemas
- Core types: Rational time, EntityId, ActionBatch, PngBytes (no Pillow dep)
- Config: ~/.quercus/config.toml with 0600 perms, env var override for CI
- LLMProvider: Claude (anthropic SDK) and OpenAI-compatible endpoint
  (covers custom gateways and llama.cpp server mode); graceful degradation
  without API keys
- Tool schemas: 26 curated tools with JSON Schema and read_only flags
- AgentLoop: sync dialogue loop with confirmation gate (read-only batches
  bypass, rejected mutations are reported back to the LLM), PNG frame
  feedback for multimodal providers
- Session log: JSONL recording with frame sha256 hashes, replayable
- HostAdapter ABC (signatures only, aligned with OPP/1 method families)
- Mock LLM provider (scripted/replay/record) for network-free CI

Tests: 69 passed via uv run pytest (no network access)
2026-08-25 02:06:10 +08:00

26 lines
706 B
Python

"""pytest 全局配置:把 tests/ 加入 sys.path(供 ``import mock_llm``)与共享 fixtures。"""
from __future__ import annotations
import sys
from pathlib import Path
import pytest
_TESTS_DIR = Path(__file__).resolve().parent
if str(_TESTS_DIR) not in sys.path:
sys.path.insert(0, str(_TESTS_DIR))
@pytest.fixture
def tmp_home(tmp_path, monkeypatch):
"""把 ~/.quercus 定向到临时目录(经 QUERCUS_HOME 覆盖)。"""
home = tmp_path / "home"
monkeypatch.setenv("QUERCUS_HOME", str(home))
return home
@pytest.fixture
def fake_png():
"""最小 PNG 头 + 填充字节;core 只流转字节,不解码。"""
return b"\x89PNG\r\n\x1a\n" + bytes(range(64))