2026-07-14 18:20:32 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2026-07-24 16:32:33 +08:00
|
|
|
from plyngent.tools.context import InstanceState, bind_instance
|
2026-07-18 18:16:06 +08:00
|
|
|
from plyngent.tools.workspace import (
|
|
|
|
|
clear_workspace_allowlist,
|
|
|
|
|
clear_workspace_root,
|
|
|
|
|
set_workspace_root,
|
|
|
|
|
)
|
2026-07-14 18:20:32 +08:00
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from collections.abc import Iterator
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def workspace(tmp_path: Path) -> Iterator[Path]:
|
2026-07-24 16:32:33 +08:00
|
|
|
"""Bind an InstanceState workspace for tool tests (no process globals)."""
|
|
|
|
|
instance = InstanceState(workspace_root=tmp_path.resolve())
|
|
|
|
|
with bind_instance(instance):
|
|
|
|
|
clear_workspace_allowlist()
|
|
|
|
|
root = set_workspace_root(tmp_path)
|
|
|
|
|
yield root
|
|
|
|
|
clear_workspace_allowlist()
|
|
|
|
|
clear_workspace_root()
|