From 2aa7b7399a40fa6408024242d7203af6ad76a8b4 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 23 Nov 2026 22:31:03 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20prose=20round=201:=200=20=F0=9F=94=B4,?= =?UTF-8?q?=206=20=F0=9F=9F=A1=20(0=20misread);=20docstrings=20and=20a=20f?= =?UTF-8?q?ixture's=20comment=20say=20what=20the=20code=20does?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/mutate_changes/mutmut_mutants.py | 4 ++-- bin/task_bench/go_bugs.py | 14 ++++++++------ bin/task_bench/plant.py | 4 ++-- bin/task_bench/planted_mutant.py | 7 ++++--- bin/task_bench/python_bugs.py | 4 ++-- bin/task_bench/test_plant.py | 2 ++ 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/bin/mutate_changes/mutmut_mutants.py b/bin/mutate_changes/mutmut_mutants.py index dd2f968c..8533304b 100644 --- a/bin/mutate_changes/mutmut_mutants.py +++ b/bin/mutate_changes/mutmut_mutants.py @@ -63,7 +63,7 @@ def statuses(results: str) -> dict[str, str]: class Change(NamedTuple): - """The source lines a mutant changes: the number of the first, those lines as the source has them, and what the mutant has in their place.""" + """The source lines a mutant changes: the number of the first, those lines as the source has them, and what the mutant has in their place. Where it only adds lines, the number is that of the line they go in before.""" line: int was: tuple[str, ...] @@ -73,7 +73,7 @@ class Change(NamedTuple): def mutated_lines(source: str, copy: str, key: str, number: int) -> Change | None: """The source lines a mutant changes; None where the mutants/ copy lacks the mutant, or holds an original unlike the source. - A mutant is a changed copy of the original, so the lines before the first that differs, and those after the last, sit at the same offsets from the source function's def.""" + A mutant is a changed copy of the original. The lines before the first that differs sit at the same offsets from the source function's def, and those after the last at the same offsets from its end.""" module, copied = parsed(source), parsed(copy) if module is None or copied is None: return None diff --git a/bin/task_bench/go_bugs.py b/bin/task_bench/go_bugs.py index cfa691ce..714178e4 100644 --- a/bin/task_bench/go_bugs.py +++ b/bin/task_bench/go_bugs.py @@ -1,5 +1,5 @@ -"""The bugs task-bench plants in Go: Gremlins' killed mutants, re-applied from its report, and what go test prints of the test -each fails.""" +"""The bugs task-bench plants in Go: Gremlins' killed mutants, re-applied from its report, and the message go test prints when a test +fails on one.""" import os import pathlib import re @@ -56,8 +56,8 @@ def go_files(top: str) -> list[str]: def reapplied(reported: in_diff_tools.Mutant, lines: list[bytes]) -> Mutant | None: - """The mutant Gremlins reports by its mutator and the token it changed, at a line and a column in bytes, both from 1, as the - line it changes in a file of those lines. None where the place holds no token the mutator changes.""" + """The mutant Gremlins reported, as the line it changes; `lines` are its file's. Gremlins names the mutator and where the token + it changed starts: a line, and a column in bytes, both from 1. None where no token the mutator changes starts there.""" if not (1 <= reported.line <= len(lines) and reported.column >= 1): return None line = lines[reported.line - 1] @@ -73,8 +73,10 @@ def reapplied(reported: in_diff_tools.Mutant, lines: list[bytes]) -> Mutant | No def task_text(output: str) -> str | None: """What Haiku is told of a planted bug: the failing assertion's message in go test's output, without the test's name, file or line, so it says what goes wrong and not where. That is the last message of the first failed test that printed one, since a - test logs before it asserts; a test with a failed subtest is left out, since it fails with the subtest. None where no failed test printed a message, as on a panic, a build that broke or a passing run, - or where the message only names the test.""" + test logs before it asserts. A test with a failed subtest is left out, since it fails with the subtest. + + None where no failed test printed a message, as on a panic, a build that broke or a passing run, or where the message only + names the test.""" lines = output.splitlines() failed = set(FAILED_TEST.findall(output)) # A subtest is named `TestPick/empty_input`; a message may name the whole or the test it belongs to. diff --git a/bin/task_bench/plant.py b/bin/task_bench/plant.py index a211de3c..7595268d 100644 --- a/bin/task_bench/plant.py +++ b/bin/task_bench/plant.py @@ -61,7 +61,7 @@ def drawn(mutants: list[Mutant], seed: int) -> list[Mutant]: def task_text(path: str, output: str, languages: tuple[Language, ...] = LANGUAGES) -> str | None: - """What Haiku is told of a bug planted in the file at path, one place_files named: the failing test's message in output, - what the test command printed, as the file's language reads it. None where the output holds no such message.""" + """What Haiku is told of a bug planted in the file at path, one place_files named. output is what the test command printed; + the file's language picks the failing test's message out of it. None where it finds none.""" language = language_of(path, languages) return language.told(output) if language else None diff --git a/bin/task_bench/planted_mutant.py b/bin/task_bench/planted_mutant.py index c8da318d..a1fe0c7a 100644 --- a/bin/task_bench/planted_mutant.py +++ b/bin/task_bench/planted_mutant.py @@ -9,8 +9,9 @@ HUNK = re.compile(r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@", re.MULTILINE) class Mutant(typing.NamedTuple): """A mutant the project's tests killed, as the lines it changes in the tree its tool ran in: the number of the first, from 1, - those lines as the tree has them, and what the mutant has in their place. name is what the report calls the bug it becomes: - the path and line, then the tool's own name of the mutant.""" + those lines as the tree has them, and what the mutant has in their place. Where it only adds lines, the number is that of the + line they go in before. name is what the report calls the bug it becomes: the path and line, then what the tool tells the + mutant by, which is Gremlins' column and mutator, or mutmut's name.""" path: str line: int @@ -20,7 +21,7 @@ class Mutant(typing.NamedTuple): def mutated(source: bytes, mutant: Mutant) -> bytes | None: - """A file's source with the mutant applied, or None where its line doesn't start the lines the mutant changes.""" + """A file's source with the mutant applied, or None where the lines the mutant changes don't stand at the mutant's line.""" lines = source.split(b"\n") first = mutant.line - 1 if not 0 <= first <= len(lines) or tuple(lines[first:first + len(mutant.was)]) != mutant.was: diff --git a/bin/task_bench/python_bugs.py b/bin/task_bench/python_bugs.py index 9c3d501f..95ec5203 100644 --- a/bin/task_bench/python_bugs.py +++ b/bin/task_bench/python_bugs.py @@ -1,5 +1,5 @@ -"""The bugs task-bench plants in Python: mutmut's killed mutants, re-applied from the copy of each file it writes, and what pytest -prints of the test each fails.""" +"""The bugs task-bench plants in Python: mutmut's killed mutants, re-applied from the copy of each file it writes, and the message +pytest prints when a test fails on one.""" import re from failure import Failure diff --git a/bin/task_bench/test_plant.py b/bin/task_bench/test_plant.py index 0a24bdaa..8a2ada31 100644 --- a/bin/task_bench/test_plant.py +++ b/bin/task_bench/test_plant.py @@ -35,6 +35,8 @@ class PlaceFilesTest(unittest.TestCase): def test_names_none_where_the_seats_found_no_places(self): self.assertEqual(place_files("Seats found no places hard."), []) + + def test_names_none_where_the_places_name_only_test_files_or_another_suffix(self): self.assertEqual(place_files("- `tests/test_geo.py:3` `load`\n- `geo_test.py:3` `load`\n- `notes.pyc:1` `x`\n"), [])