Test task-bench's docker calls, command line and planter where mutants survived
CI / tests (pull_request) Successful in 4m38s

This commit is contained in:
2026-11-21 01:39:12 +01:00
parent fed84cc510
commit ebbe926ab7
7 changed files with 316 additions and 35 deletions
+17 -1
View File
@@ -6,9 +6,9 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from claude_code.tokens import Tokens
from failure import Failure
from task_bench.figures import Figures, figures, Result, table
from claude_code.tokens import Tokens
INIT = {"type": "system", "subtype": "init", "cwd": "/work", "model": "claude-haiku-5-5", "claude_code_version": "2.1.330"}
USAGE = {"input_tokens": 40, "cache_creation_input_tokens": 9000, "cache_read_input_tokens": 52000, "output_tokens": 800, "cache_creation": {"ephemeral_1h_input_tokens": 9000, "ephemeral_5m_input_tokens": 0}}
@@ -53,6 +53,18 @@ class FiguresTest(unittest.TestCase):
self.assertIsNone(figures(stream(INIT, call("Read", file_path="/work/calc.go")), "/work/calc.go"))
self.assertIsNone(figures(b"", "/work/calc.go"))
def test_a_result_without_turns_or_a_duration_counts_none(self):
found = figures(stream(INIT, {"type": "result", "usage": USAGE}), "/work/calc.go")
self.assertEqual((found.turns, found.seconds), (0, 0))
def test_a_stream_without_an_init_names_no_version_or_model(self):
found = figures(stream(RESULT), "/work/calc.go")
self.assertEqual((found.version, found.model), ("", ""))
def test_a_shell_command_that_reads_under_the_runs_home_reads_no_file_of_the_code(self):
found = figures(stream(INIT, call("Bash", command="cat ~/calc.go"), call("Read", file_path="/work/calc.go"), RESULT), "/work/calc.go")
self.assertEqual(found.reads, 1)
def test_a_run_the_api_refused_is_a_failure_that_quotes_claude(self):
refused = {**RESULT, "is_error": True, "api_error_status": 401, "result": "Failed to authenticate. API Error: 401 OAuth access token is invalid."}
self.assertEqual(figures(stream(INIT, refused), "/work/calc.go"), Failure("claude could not use the API: Failed to authenticate. API Error: 401 OAuth access token is invalid."))
@@ -86,6 +98,10 @@ class TableTest(unittest.TestCase):
"| All | change | +2 | -50 % | 0 % | 0 % | 0 % | -3.5 | -50 % | -2.5 |",
])
def test_the_change_is_a_dash_where_the_base_measured_zero_and_signed_where_it_rose(self):
results = [run(1, "base", 1, True, input_=0, turns=10, seconds=60, reads=0), run(1, "head", 1, False, input_=50, turns=12, seconds=90, reads=2)]
self.assertEqual(table(results, {1: "calc.go:4:7 ARITHMETIC_BASE"})[-1], "| All | change | -1 | - | 0 % | 0 % | 0 % | +2 | +50 % | +2 |")
def test_a_run_without_figures_counts_as_not_passed_and_a_side_without_any_shows_a_dash(self):
results = [Result(1, "base", 1, False, None), run(1, "head", 1, True)]
self.assertEqual(table(results, {1: "calc.go:4:7 ARITHMETIC_BASE"})[2:], [