Read the status line's branch through git_repo.git, and state the comprehension-floor rule as it holds
This commit is contained in:
@@ -103,9 +103,11 @@ 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_a_branch_name_that_is_not_utf_8(self):
|
||||
for branch, shown in ((b"trunk", "trunk"), (b"f\xe5", "f\ufffd")):
|
||||
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}))
|
||||
self.assertEqual((ran.stdout, ran.stderr), (SEP.join([f"{CYAN}{checkout}{RESET}", f"{DIM}{shown}{RESET}"]), ""))
|
||||
row = [f"{CYAN}{checkout}{RESET}"] + ([] if shown is None else [f"{DIM}{shown}{RESET}"])
|
||||
self.assertEqual((ran.stdout, ran.stderr), (SEP.join(row), ""))
|
||||
|
||||
Reference in New Issue
Block a user