tests: write the offered-models list beside every models table fixture
Adds an offered(data_dir, text) helper, called from Core.table() and from each direct models.md write in the store; pops CLAUDE_CODE_ENTRYPOINT in the test env. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3a349a3859
commit
8c4fdf944e
2 files changed
+24
-2
No files matched your search
+12
-1
@@ -59,6 +59,15 @@ def tree():
|
||||
REAL_HOME = os.path.expanduser("~")
|
||||
|
||||
|
||||
def offered(data_dir, text):
|
||||
"""The offered-models list for the current harness, written beside models.md: pick refuses without it."""
|
||||
path = os.path.join(data_dir, "offered", "unknown.txt")
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write("listed %s by harness unknown\n%s" % (time.strftime("%Y-%m-%dT%H:%M:%S"), text))
|
||||
return path
|
||||
|
||||
|
||||
class Core(unittest.TestCase):
|
||||
ENFORCE = False
|
||||
|
||||
@@ -83,7 +92,7 @@ class Core(unittest.TestCase):
|
||||
self.env = dict(os.environ, HOME=self.tmp, SISI_DATA=self.data, SISI_STATE=os.path.join(self.tmp, "state"),
|
||||
SISI_LIB=os.path.join(self.tmp, "lib"), CLAUDE_CONFIG_DIR=os.path.join(self.tmp, "claude"),
|
||||
PYTHONPATH=py + (os.pathsep + os.environ["PYTHONPATH"] if os.environ.get("PYTHONPATH") else ""))
|
||||
for name in ("SISI_SESSION_ID", "CLAUDE_ENV_FILE", "XDG_DATA_HOME", "XDG_STATE_HOME", "CODEX_HOME"):
|
||||
for name in ("SISI_SESSION_ID", "CLAUDE_ENV_FILE", "XDG_DATA_HOME", "XDG_STATE_HOME", "CODEX_HOME", "CLAUDE_CODE_ENTRYPOINT"):
|
||||
self.env.pop(name, None)
|
||||
self.proj = self.project("alpha")
|
||||
if not self.ENFORCE: # these tests hold the reminders; tests/test_plan.py holds the denials
|
||||
@@ -125,6 +134,7 @@ class Core(unittest.TestCase):
|
||||
def table(self, text):
|
||||
self.write(os.path.join(self.data, "models.md"), text) if os.path.isdir(self.data) else (
|
||||
os.makedirs(self.data), self.write(os.path.join(self.data, "models.md"), text))
|
||||
offered(self.data, text)
|
||||
|
||||
def state(self, sid="s1"):
|
||||
return json.loads(self.read(self.tmp, "state", "core-sessions", sid + ".json"))
|
||||
@@ -2712,6 +2722,7 @@ cli.main(["tick"])
|
||||
self.assertEqual(self.read(self.env["SISI_LIB"], "current", "SOURCE").split("\n")[0], src)
|
||||
self.sisi("learn", "--level", "user", "Always keep what the person wrote")
|
||||
self.write(os.path.join(self.data, "models.md"), WORKERS)
|
||||
offered(self.data, WORKERS)
|
||||
self.write(os.path.join(self.data, "retro.jsonl"), '{"gap": "g"}\n')
|
||||
keep = {n: self.read(self.data, n) for n in ("models.md", "retro.jsonl", "rules/user.md")}
|
||||
self.source("2.0.0")
|
||||
|
||||
Reference in new issue
Block a user