Answer principles round 1: 0 🔴, 6 🟡; cut the false status-line exception, split the branch test, and date the lowest-dimension rule without Shape's score

This commit is contained in:
2026-10-22 19:50:09 +02:00
parent 2fefab6b2e
commit 87f41071f2
4 changed files with 17 additions and 12 deletions
+13 -8
View File
@@ -103,11 +103,16 @@ class Script(unittest.TestCase):
ran = self.run_script(stdin)
self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, f"{RED}warning: statusline.py's input is not a JSON object{RESET}", ""))
def test_shows_no_branch_where_git_fails(self):
# git_repo.git fails on text that is not UTF-8, so a branch named f\xe5 shows as none.
for branch, shown in ((b"trunk", "trunk"), (b"f\xe5", None)):
with tempfile.TemporaryDirectory() as checkout:
subprocess.run([b"git", b"init", b"-q", b"-b", branch, checkout.encode()], check=True)
ran = self.run_script(json.dumps({"cwd": checkout}))
row = [f"{CYAN}{checkout}{RESET}"] + ([] if shown is None else [f"{DIM}{shown}{RESET}"])
self.assertEqual((ran.stdout, ran.stderr), (SEP.join(row), ""))
def run_on_branch(self, branch):
with tempfile.TemporaryDirectory() as checkout:
subprocess.run([b"git", b"init", b"-q", b"-b", branch, checkout.encode()], check=True)
ran = self.run_script(json.dumps({"cwd": checkout}))
return ran, checkout
def test_shows_the_branch(self):
ran, checkout = self.run_on_branch(b"trunk")
self.assertEqual((ran.stdout, ran.stderr), (SEP.join([f"{CYAN}{checkout}{RESET}", f"{DIM}trunk{RESET}"]), ""))
def test_shows_no_branch_where_git_fails_on_a_name_that_is_not_utf_8(self):
ran, checkout = self.run_on_branch(b"f\xe5")
self.assertEqual((ran.stdout, ran.stderr), (f"{CYAN}{checkout}{RESET}", ""))