Answer the stability, product-owner and prose reviews

This commit is contained in:
2026-10-02 14:26:54 +02:00
parent 7ba3d0325b
commit f34320270c
6 changed files with 21 additions and 15 deletions
+6 -1
View File
@@ -2,6 +2,7 @@
import dataclasses
import datetime
import json
import locale
import math
import os
import subprocess
@@ -152,7 +153,11 @@ def main() -> str:
except ValueError:
raw = None
if not isinstance(raw, dict):
return f"{RED}warning: statusline.py could not parse its input as a JSON object{RESET}"
return f"{RED}warning: statusline.py's input is not a JSON object{RESET}"
try:
locale.setlocale(locale.LC_TIME, "")
except locale.Error:
pass
# Zone None: astimezone converts to the machine's own zone, daylight saving included.
status = parse(raw, None)
return render(status, current_branch(status.directory), os.environ.get("HOME", ""), datetime.datetime.now().astimezone())
+3 -3
View File
@@ -77,7 +77,7 @@ class Render(unittest.TestCase):
east = statusline.parse({"rate_limits": {"seven_day": {"resets_at": 253402300000, "used_percentage": 1}}}, datetime.timezone(datetime.timedelta(hours=2)))
self.assertIsNone(east.seven_day.resets_at)
def test_dates_now_and_the_reset_each_in_its_own_offset(self):
def test_counts_time_left_across_an_offset_change(self):
cest, cet = datetime.timezone(datetime.timedelta(hours=2)), datetime.timezone(datetime.timedelta(hours=1))
now = datetime.datetime(2026, 10, 25, 0, 30, tzinfo=cest)
self.assertEqual(statusline.reset_suffix(datetime.datetime(2026, 10, 25, 5, 0, tzinfo=cet), now), f" {DIM}5h30m left (05:00){RESET}")
@@ -101,9 +101,9 @@ class Script(unittest.TestCase):
def test_warns_on_the_status_line_for_input_that_is_not_a_json_object(self):
for stdin in ("not json", "[]"):
ran = self.run_script(stdin)
self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, f"{RED}warning: statusline.py could not parse its input as a JSON object{RESET}", ""))
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_the_branch_of_the_directory_even_when_it_is_not_utf_8(self):
def test_shows_a_branch_name_that_is_not_utf_8(self):
for branch, shown in ((b"trunk", "trunk"), (b"f\xe5", "f\ufffd")):
with tempfile.TemporaryDirectory() as checkout:
subprocess.run([b"git", b"init", b"-q", b"-b", branch, checkout.encode()], check=True)