Answer product-owner round 1: name the figure's new input tokens, label the places' counts, give a usage error one line, and say where the reading-cost item goes
This commit is contained in:
@@ -73,16 +73,16 @@ class Figures(unittest.TestCase):
|
||||
def test_rises_only_above_the_five_before_and_needs_ten(self):
|
||||
flat = [Reading(100, collections.Counter({"a.py": 1}))] * 10
|
||||
self.assertEqual(reading_cost.trend(flat[:9]), "9 chunks measured; the trend needs 10.")
|
||||
self.assertTrue(reading_cost.trend(flat).startswith("Not rising: the last 5 chunks' median is 100 tokens"))
|
||||
self.assertTrue(reading_cost.trend(flat).startswith("Not rising: the last 5 chunks' median is 100 new input tokens"))
|
||||
self.assertTrue(reading_cost.trend(flat[:9] + [Reading(3000000, collections.Counter())]).startswith("Not rising:"))
|
||||
self.assertEqual(reading_cost.trend(flat[:5] + [Reading(101, collections.Counter({"b.py": 2}))] * 5), "Rising: the last 5 chunks' median is 101 tokens read before their first commit, the 5 before them 100.\n\nRead most over the last 5:\n\n- `b.py` 10")
|
||||
self.assertEqual(reading_cost.trend(flat[:5] + [Reading(101, collections.Counter({"b.py": 2}))] * 5), "Rising: the last 5 chunks' median is 101 new input tokens before their first commit, the 5 before them 100.\n\nRead most over the last 5 (opens and searches):\n\n- `b.py` 10")
|
||||
|
||||
def test_a_figure_reads_back_as_the_reading_it_was_written_from_and_a_damaged_one_fails(self):
|
||||
reading = Reading(7, collections.Counter({"b.py": 1, "a.py": 3}))
|
||||
written = reading_cost.figure(FinishedChunk("abcdef0123456789", "t", pathlib.Path(), []), reading)
|
||||
self.assertEqual(written, "## Reading cost, chunk abcdef012345, finished t\n\n7 tokens read before the first commit.\n\nRead most:\n\n- `a.py` 3\n- `b.py` 1\n")
|
||||
self.assertEqual(written, "## Reading cost, chunk abcdef012345, finished t\n\n7 new input tokens before the first commit.\n\nRead most (opens and searches):\n\n- `a.py` 3\n- `b.py` 1\n")
|
||||
self.assertEqual(reading_cost.readings_of(written), [reading])
|
||||
self.assertEqual(reading_cost.readings_of(written.replace("7 tokens", "seven tokens")), Failure('the figure under "## Reading cost, chunk abcdef012345, finished t" holds no single tokens line; restore it from git history'))
|
||||
self.assertEqual(reading_cost.readings_of(written.replace("7 new", "seven new")), Failure('the figure under "## Reading cost, chunk abcdef012345, finished t" holds no single tokens line; restore it from git history'))
|
||||
|
||||
|
||||
def test_counts_only_figures_finished_after_the_last_reset_in_the_order_they_finished(self):
|
||||
@@ -136,7 +136,7 @@ class ReadingCostTool(unittest.TestCase):
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
history = worktree / "docs" / "comprehension-history.md"
|
||||
self.assertEqual(ran.stdout, f"Appended 2 reading-cost figures from {self.home / '.claude' / 'loop-claude-transcripts' / 'proj'} to {history}.\n2 chunks measured; the trend needs 10.\n")
|
||||
figure = "## Reading cost, chunk {}, finished {}\n\n33 tokens read before the first commit.\n\nRead most:\n\n- `a.py` 1\n"
|
||||
figure = "## Reading cost, chunk {}, finished {}\n\n33 new input tokens before the first commit.\n\nRead most (opens and searches):\n\n- `a.py` 1\n"
|
||||
self.assertEqual(history.read_text(), "# Comprehension history\n\n" + "\n".join(figure.format(chunk.folder[:12], chunk.finished) for chunk in chunks))
|
||||
self.assertTrue(self.run_tool(worktree).stdout.startswith(f"Appended 0 reading-cost figures from"))
|
||||
self.assertEqual(history.read_text().count("## Reading cost"), 2)
|
||||
@@ -147,7 +147,6 @@ class ReadingCostTool(unittest.TestCase):
|
||||
def test_refuses_an_option_it_does_not_know(self):
|
||||
ran = self.run_tool(self.checkout, "--rest")
|
||||
self.assertEqual((ran.returncode, ran.stdout), (1, ""))
|
||||
self.assertFalse((self.checkout / "--rest").exists())
|
||||
|
||||
def test_exits_1_outside_a_checkout(self):
|
||||
ran = self.run_tool(self.home)
|
||||
|
||||
Reference in New Issue
Block a user