Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions engine/hooks/llm-judge/tests/test_inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import cursor_session # noqa: E402
import inbox # noqa: E402
import judge # noqa: E402
from judge_test_base import JudgeTestCase # noqa: E402

PY = sys.executable
ON_HIT = "demo-hook: the last reply took back an earlier check; run reflect on it"
Expand All @@ -26,25 +27,20 @@
MISSING = ["ghost", ["catstack-llm-judge-no-such-binary", "{prompt}"]]


class InboxTestCase(unittest.TestCase):
class InboxTestCase(JudgeTestCase):
def setUp(self):
self.state = tempfile.TemporaryDirectory()
super().setUp()
self.work = tempfile.TemporaryDirectory()
self.env = patch.dict(os.environ, {judge.STATE_ENV: self.state.name})
self.env.start()
os.environ.pop(judge.CHILD_ENV, None)
os.environ.pop(judge.RUNNERS_ENV, None)
self.transcript = os.path.join(self.work.name, "session.jsonl")
with open(self.transcript, "w", encoding="utf-8") as handle:
handle.write("{}\n")

def tearDown(self):
self.env.stop()
self.state.cleanup()
self.work.cleanup()
super().tearDown()

def seed(self, *runner_entries, job_id="job-1"):
os.environ[judge.RUNNERS_ENV] = json.dumps(list(runner_entries))
self.use_runners(*runner_entries)
job_path = os.path.join(self.state.name, "jobs", f"{job_id}.json")
judge.write_json_atomic(job_path, {
"id": job_id,
Expand Down
13 changes: 5 additions & 8 deletions engine/hooks/llm-judge/tests/test_post_tool_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,29 @@
import sys
import tempfile
import unittest
from unittest.mock import patch

LIB_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, LIB_DIR)

import judge
from judge_test_base import JudgeTestCase

PY = sys.executable
ON_HIT = "judge hit text"


class PostToolUseTestCase(unittest.TestCase):
class PostToolUseTestCase(JudgeTestCase):
def setUp(self):
self.state = tempfile.TemporaryDirectory()
super().setUp()
self.work = tempfile.TemporaryDirectory()
self.patch_env = patch.dict(os.environ, {judge.STATE_ENV: self.state.name})
self.patch_env.start()
self.transcript = os.path.join(self.work.name, "session.jsonl")
with open(self.transcript, "w", encoding="utf-8") as handle:
handle.write("{}\n")
self.env = dict(os.environ, **{judge.STATE_ENV: self.state.name})
self.env = dict(os.environ)

def tearDown(self):
self.patch_env.stop()
self.state.cleanup()
self.work.cleanup()
super().tearDown()

def plant_hit(self):
judge.write_json_atomic(os.path.join(judge.verdict_dir(self.transcript), "hit.json"), {
Expand Down
Loading