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_hover.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_hover.py')
| -rw-r--r-- | tests/test_hover.py | 73 |
1 files changed, 47 insertions, 26 deletions
diff --git a/tests/test_hover.py b/tests/test_hover.py index e515661..2dae5c2 100644 --- a/tests/test_hover.py +++ b/tests/test_hover.py @@ -5,6 +5,7 @@ The feature is three lines. The reason it is not obnoxious is the guards: it must not steal focus mid-chord, reach past an open finder, interrupt a drag, or expand a collapsed pane just because the pointer crossed its header. """ + import os import sys import tempfile @@ -41,8 +42,7 @@ def test_hover_focuses(): hover(s, left["content_x"] + 2, left["content_y"] + 1) s.settle(60) - check("hovering a pane focuses it", focused_id(s) == left["id"], - str(s.panes())) + check("hovering a pane focuses it", focused_id(s) == left["id"], str(s.panes())) hover(s, right["content_x"] + 2, right["content_y"] + 1) s.settle(60) @@ -68,8 +68,11 @@ def test_guards(): s.send(r"\x01") hover(s, left["content_x"] + 2, left["content_y"] + 1) s.settle(60) - check("hover does not steal focus mid-chord", - focused_id(s) == right["id"], str(s.panes())) + check( + "hover does not steal focus mid-chord", + focused_id(s) == right["id"], + str(s.panes()), + ) s.send("g") # release the prefix harmlessly # with the finder open, the pane underneath must not take focus @@ -77,17 +80,19 @@ def test_guards(): s.settle(60) hover(s, left["content_x"] + 2, left["content_y"] + 1) s.settle(60) - check("hover does not reach past the finder", - focused_id(s) == right["id"], str(s.panes())) + check( + "hover does not reach past the finder", + focused_id(s) == right["id"], + str(s.panes()), + ) s.send(r"\e") s.settle(60) # during a drag, the mouse belongs to the drag - s.send(rf"\e[<0;{right['x'] + 5};{right['y'] + 1}M") # press a title + s.send(rf"\e[<0;{right['x'] + 5};{right['y'] + 1}M") # press a title hover(s, left["content_x"] + 2, left["content_y"] + 1) # (button held) s.settle(60) - check("a drag owns the mouse", focused_id(s) == right["id"], - str(s.panes())) + check("a drag owns the mouse", focused_id(s) == right["id"], str(s.panes())) s.send(r"\x01g") # any key ends the drag @@ -108,15 +113,19 @@ def test_hover_does_not_expand_collapsed_panes(): before = focused_id(s) hover(s, h["x"] + 3, h["y"]) s.settle(60) - check("hovering a collapsed header does not expand it", - [p for p in s.panes() if p["id"] == h["id"]][0]["hidden"], - str(s.panes())) + check( + "hovering a collapsed header does not expand it", + [p for p in s.panes() if p["id"] == h["id"]][0]["hidden"], + str(s.panes()), + ) check("nor move focus", focused_id(s) == before, str(s.panes())) # clicking it still does s.click(h["x"] + 3, h["y"]) s.settle() - check("clicking it still expands it", - not [p for p in s.panes() if p["id"] == h["id"]][0]["hidden"]) + check( + "clicking it still expands it", + not [p for p in s.panes() if p["id"] == h["id"]][0]["hidden"], + ) def test_can_be_turned_off(): @@ -128,38 +137,50 @@ def test_can_be_turned_off(): left, right = s.panes() hover(s, left["content_x"] + 2, left["content_y"] + 1) s.settle(60) - check("with the option off, hovering does nothing", - focused_id(s) == right["id"], str(s.panes())) + check( + "with the option off, hovering does nothing", + focused_id(s) == right["id"], + str(s.panes()), + ) s.click(left["content_x"] + 2, left["content_y"] + 1) s.settle(60) - check("but clicking still focuses", focused_id(s) == left["id"], - str(s.panes())) + check("but clicking still focuses", focused_id(s) == left["id"], str(s.panes())) os.unlink(path) def test_panes_still_get_motion(): """?1003 also fixes something: a pane that tracks hover can now see it.""" - tracker = ["/bin/sh", "-c", - 'stty raw -echo; printf "\\033[?1003h\\033[?1006h"; cat -v'] + tracker = [ + "/bin/sh", + "-c", + 'stty raw -echo; printf "\\033[?1003h\\033[?1006h"; cat -v', + ] with Session(tracker, cols=70, rows=12) as s: s.settle() p = s.pane() hover(s, p["content_x"] + 4, p["content_y"] + 2) s.settle() out = s.snapshot().pane_text(p) - check("motion reaches a pane that asked for any-event tracking", - "^[[<35;5;3M" in out, repr(out[:120])) + check( + "motion reaches a pane that asked for any-event tracking", + "^[[<35;5;3M" in out, + repr(out[:120]), + ) - quiet = ["/bin/sh", "-c", - 'stty raw -echo; printf "\\033[?1000h\\033[?1006h"; cat -v'] + quiet = [ + "/bin/sh", + "-c", + 'stty raw -echo; printf "\\033[?1000h\\033[?1006h"; cat -v', + ] with Session(quiet, cols=70, rows=12) as s: s.settle() p = s.pane() hover(s, p["content_x"] + 4, p["content_y"] + 2) s.settle() out = s.snapshot().pane_text(p) - check("but not one that only asked for clicks", "[<" not in out, - repr(out[:120])) + check( + "but not one that only asked for clicks", "[<" not in out, repr(out[:120]) + ) if __name__ == "__main__": |
