pybot / world /tests /conftest.py
lewtun's picture
lewtun HF Staff
Claude Opus 5.5
world: install legion at a pinned commit instead of vendoring it
5bac4c2 verified
Raw History Blame
1.19 kB
"""Puts the world's modules on sys.path (legion is the installed package, README); test helpers."""
from __future__ import annotations
import shutil
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1] # world/
sys.path.insert(0, str(ROOT))
class FakeBucket:
"""A bucket in a local directory, with the bucket operations snapshot.py uses."""
def __init__(self, root: Path):
self.root = root
self.ops: list[str] = []
def upload(self, files):
self.ops.append("upload")
for local, rel in files:
(self.root / rel).parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(local, self.root / rel)
def list(self, prefix):
return [str(p.relative_to(self.root)) for p in self.root.rglob("*")
if p.is_file() and str(p.relative_to(self.root)).startswith(prefix)]
def download(self, files):
for rel, local in files:
local.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(self.root / rel, local)
def delete(self, paths):
self.ops.append("delete")
for rel in paths:
(self.root / rel).unlink()