The last 122 `D205` sites, which takes `ruff check .` to zero. Same shape as the package pass and just as additive: these were a paragraph with no summary, so each one gains a plain sentence saying what is being asserted, and every word that was there moves down into the description. The dense ones benefit most — `test_pathline`'s 23, where "A seam is one cell, not two" now stands alone and the chevron mechanics explain it underneath, and `test_tui`'s wide-glyph repaint test, whose seven lines on prompt_toolkit's relative cursor now sit under the one line that says what the test pins. Four module docstrings (`test_advert`, `test_gallery`, `test_platforms`, `test_repeater_admin`) opened with "X tests: a, b, and c" and now name the subject on the first line with the list below it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""The F-key lane's Shift-state watcher: the raw flag and the shift-bank latch."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from meshterm.services import modifier_watch
|
|
|
|
|
|
def _reset() -> None:
|
|
modifier_watch._shift_down = False
|
|
modifier_watch._last_shift_bank_at = None
|
|
|
|
|
|
def test_shift_down_reflects_the_raw_flag() -> None:
|
|
"""``shift_down()`` reports the flag the watcher last set, with nothing in between."""
|
|
_reset()
|
|
try:
|
|
assert modifier_watch.shift_down() is False
|
|
modifier_watch._shift_down = True
|
|
assert modifier_watch.shift_down() is True
|
|
finally:
|
|
_reset()
|
|
|
|
|
|
def test_shift_bank_key_latches_over_the_release_flicker(monkeypatch) -> None:
|
|
"""A shift-bank key latches over the release flicker.
|
|
|
|
An F6-F10 press keeps the lane's shifted read for a grace window, even if the raw
|
|
watcher reports Shift already back up — which, per the MCU quirk, it may do
|
|
wrongly.
|
|
"""
|
|
_reset()
|
|
try:
|
|
clock = [100.0]
|
|
monkeypatch.setattr(modifier_watch.time, "monotonic", lambda: clock[0])
|
|
|
|
assert modifier_watch.shift_down() is False
|
|
modifier_watch.note_shift_bank_key()
|
|
assert modifier_watch.shift_down() is True # latched, raw flag never went true
|
|
|
|
clock[0] += modifier_watch._SHIFT_BANK_GRACE_S - 0.05
|
|
assert modifier_watch.shift_down() is True # still inside the grace window
|
|
|
|
clock[0] += 0.1
|
|
assert modifier_watch.shift_down() is False # grace lapsed, Shift really let go
|
|
finally:
|
|
_reset()
|