diff options
| author | user <user@clank> | 2026-08-17 14:36:59 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-17 14:36:59 +0200 |
| commit | c0022776d0912042819e4ea330cf7491a8196b45 (patch) | |
| tree | 3c5d547f273d8304e7cd6834fd5a2c730a495064 /tests/test_zoom.py | |
| parent | sl0ppty: ruff formats the Python, and sorts its imports (diff) | |
| download | slosh-c0022776d0912042819e4ea330cf7491a8196b45.tar.gz slosh-c0022776d0912042819e4ea330cf7491a8196b45.tar.xz slosh-c0022776d0912042819e4ea330cf7491a8196b45.zip | |
sl0ppty: ruff format the Python
The bumpy one, again. Every `.py` outside `vendor/` plus the three `contrib/`
scripts that are Python with no extension: 60 files, 6,714 lines rewritten, no
behaviour changed. Nothing here is worth reading -- the next commit adds it to
`.git-blame-ignore-revs` so `git blame` walks past it.
It is a bigger reformat than the C was, 60% of the lines against 17%, and for a
reason worth writing down rather than tuning away: ruff and black break a call that
does not fit onto one argument per line, where this code aligned the continuation
under the opening paren. The test suite is thousands of `check("some prose", cond,
detail)` calls, so nearly every one of them changed shape and the suite grew 3,308
lines. Line length was the one lever that moved it -- 120 columns would have been a
40% reformat and no growth at all -- and it was left at 88, because picking an
unusual width to dodge a one-time diff is paying forever to avoid paying once.
Import sorting came with it. Two files had `import os, pty, uuid, select, struct,
sys, termios, time, fcntl, signal` on one line and now have ten.
Verified after, not before, because a formatter that alters behaviour would be
worse than none:
- `make retest`, 1801 checks green -- and this reformats the suite that does the
checking, including `harness.py`, which every one of those files imports.
- `make test-live`, the tty tests the fast suite skips. They matter here more than
usual: `live_input.py` and `live_m0.py` are two of the files whose comma-imports
were split, and nothing in the fast suite would have noticed if that broke them.
- All 60 files still compile, `make fmt` twice in a row changes nothing the second
time, and `ruff check --select I` has nothing left to say.
Diffstat (limited to 'tests/test_zoom.py')
| -rw-r--r-- | tests/test_zoom.py | 104 |
1 files changed, 68 insertions, 36 deletions
diff --git a/tests/test_zoom.py b/tests/test_zoom.py index d4dca17..43cc545 100644 --- a/tests/test_zoom.py +++ b/tests/test_zoom.py @@ -6,6 +6,7 @@ its tab, you said so. So the things worth checking are that it survives the layout being recomputed, that it cannot outlive the pane it names, and that it is per tab. """ + import os import re import subprocess @@ -22,8 +23,7 @@ def mark(name): `--dump-config`, which is generated from the code, rather than written down here -- a test that pins a glyph starts failing the day somebody picks a nicer one, and says nothing useful when it does.""" - out = subprocess.run([BIN, "--dump-config"], capture_output=True, - text=True).stdout + out = subprocess.run([BIN, "--dump-config"], capture_output=True, text=True).stdout m = re.search(name + r' "(.+)"', out) return m.group(1) if m else "?" @@ -66,17 +66,17 @@ def test_zoom_fills_the_tab_and_puts_it_back(): s.send(r"\x01z") s.settle(20) - check("zooming leaves one pane on screen", len(visible(s)) == 1, - str(s.panes())) - check("but does not close the other", len(s.panes()) == 2, - str(s.panes())) - check("and the zoomed pane has the whole tab", - visible(s)[0]["w"] > 80, str(visible(s)[0])) + check("zooming leaves one pane on screen", len(visible(s)) == 1, str(s.panes())) + check("but does not close the other", len(s.panes()) == 2, str(s.panes())) + check( + "and the zoomed pane has the whole tab", + visible(s)[0]["w"] > 80, + str(visible(s)[0]), + ) s.send(r"\x01z") s.settle(20) - check("unzooming puts them both back", len(visible(s)) == 2, - str(s.panes())) + check("unzooming puts them both back", len(visible(s)) == 2, str(s.panes())) def test_the_button_toggles_and_says_which_way(): @@ -92,17 +92,22 @@ def test_the_button_toggles_and_says_which_way(): s.click(b["x"] + 1, b["y"]) s.settle(20) check("clicking it zooms", len(visible(s)) == 1, str(s.panes())) - check("and the mark says so", ZOOM_ON in s.snapshot().line(2), - repr(s.snapshot().line(2)[-14:])) + check( + "and the mark says so", + ZOOM_ON in s.snapshot().line(2), + repr(s.snapshot().line(2)[-14:]), + ) # The button moved: the pane it belongs to just became the whole tab. b = button(s, "zoom") s.click(b["x"] + 1, b["y"]) s.settle(20) - check("clicking it again puts it back", len(visible(s)) == 2, - str(s.panes())) - check("and the mark goes back too", ZOOM in s.snapshot().line(2), - repr(s.snapshot().line(2)[-14:])) + check("clicking it again puts it back", len(visible(s)) == 2, str(s.panes())) + check( + "and the mark goes back too", + ZOOM in s.snapshot().line(2), + repr(s.snapshot().line(2)[-14:]), + ) def test_the_close_button_closes_that_pane(): @@ -119,8 +124,11 @@ def test_the_close_button_closes_that_pane(): s.click(b["x"] + 1, b["y"]) s.settle(20) left = [p["id"] for p in s.panes()] - check("it closes the pane whose frame it is on", - victim not in left and len(left) == 1, str(left)) + check( + "it closes the pane whose frame it is on", + victim not in left and len(left) == 1, + str(left), + ) def test_a_zoom_cannot_outlive_its_pane(): @@ -134,16 +142,24 @@ def test_a_zoom_cannot_outlive_its_pane(): s.api("close", id=[p for p in s.panes() if p["focused"]][0]["id"]) s.settle(20) - check("closing the zoomed pane leaves the tab usable", - len(visible(s)) == 1 and len(s.panes()) == 1, str(s.panes())) - check("and the survivor is not stuck hidden", - not s.panes()[0]["hidden"], str(s.panes())) + check( + "closing the zoomed pane leaves the tab usable", + len(visible(s)) == 1 and len(s.panes()) == 1, + str(s.panes()), + ) + check( + "and the survivor is not stuck hidden", + not s.panes()[0]["hidden"], + str(s.panes()), + ) def test_zoom_is_per_tab(): lay = tempfile.NamedTemporaryFile("w", suffix=".kdl", delete=False) - lay.write('layout {\n tab name="a" {\n pane\n pane\n }\n' - ' tab name="b" {\n pane\n pane\n }\n}\n') + lay.write( + 'layout {\n tab name="a" {\n pane\n pane\n }\n' + ' tab name="b" {\n pane\n pane\n }\n}\n' + ) lay.close() with Session(SH, cols=90, rows=18, layout=lay.name) as s: s.settle(20) @@ -154,13 +170,19 @@ def test_zoom_is_per_tab(): tabs = s.tabs() s.api("select-tab", id=tabs[1]["id"]) s.settle(20) - check("tab b is not, because zoom belongs to a tab", - len(visible(s)) == 2, str(s.panes())) + check( + "tab b is not, because zoom belongs to a tab", + len(visible(s)) == 2, + str(s.panes()), + ) s.api("select-tab", id=tabs[0]["id"]) s.settle(20) - check("and tab a is still zoomed when you come back", - len(visible(s)) == 1, str(s.panes())) + check( + "and tab a is still zoomed when you come back", + len(visible(s)) == 1, + str(s.panes()), + ) os.unlink(lay.name) @@ -169,27 +191,37 @@ def test_the_status_line_says_zoomed(): s.settle(20) s.api("split", dir="cols") s.settle(20) - check("nothing said while it is not", "zoomed" not in s.snapshot().text[-2], - repr(s.snapshot().text[-2])) + check( + "nothing said while it is not", + "zoomed" not in s.snapshot().text[-2], + repr(s.snapshot().text[-2]), + ) s.send(r"\x01z") s.settle(20) - check("a zoomed pane says so", "zoomed" in s.snapshot().text[-2], - repr(s.snapshot().text[-2])) + check( + "a zoomed pane says so", + "zoomed" in s.snapshot().text[-2], + repr(s.snapshot().text[-2]), + ) def test_the_buttons_can_be_turned_off(): conf = cfg("pane_buttons false\n") with Session(SH, cols=90, rows=18, config=conf) as s: s.settle(20) - hits = [h for h in s.snapshot().hits - if h["action"].startswith(("zoom:", "close:"))] + hits = [ + h for h in s.snapshot().hits if h["action"].startswith(("zoom:", "close:")) + ] check("pane_buttons false draws none", hits == [], str(hits)) # ...but the verb is still there from the keyboard: the setting is # about the affordance, not about zooming. s.send(r"\x01z") s.settle(20) - check("while the keybinding still zooms", - "zoomed" in s.snapshot().text[-2], repr(s.snapshot().text[-2])) + check( + "while the keybinding still zooms", + "zoomed" in s.snapshot().text[-2], + repr(s.snapshot().text[-2]), + ) os.unlink(conf) |
