aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_tui.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-25 19:03:09 -0400
committerhistoria <historiavg@proton.me>2026-08-25 19:03:09 -0400
commit8c9a782dfe94525dc5f0893c98fd19543648264b (patch)
treefdff70d967ef06f0da560ca284842427cbe647a8 /app/tests/test_tui.py
parent64e9940d43fad1bc5908b39673b03e4fdc1e8f2f (diff)
downloadtts-audiobook-generator-8c9a782dfe94525dc5f0893c98fd19543648264b.tar.gz
fix: tui errors wait for getch()
Diffstat (limited to 'app/tests/test_tui.py')
-rw-r--r--app/tests/test_tui.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/tests/test_tui.py b/app/tests/test_tui.py
index 543194e..1b7af86 100644
--- a/app/tests/test_tui.py
+++ b/app/tests/test_tui.py
@@ -88,6 +88,10 @@ class FakeScreen:
self.height = height
self.strings = [] # (y, x, text, attr) from addstr
self.chars = [] # (y, x, ch, attr) from addch
+ self.timeouts = [] # ms values passed to timeout()
+
+ def timeout(self, ms):
+ self.timeouts.append(ms)
def getmaxyx(self):
return self.height, self.width
@@ -979,6 +983,23 @@ class FlashTests(TuiTestCase):
self.assertEqual(attr, tui._THEME["warn"])
self.assert_inside_border(screen)
+ def test_timed_out_reads_are_ignored_until_a_real_key(self):
+ # A screen left in redraw-cadence mode feeds getch() -1s; the
+ # notice must still wait for an actual key press.
+ screen = FakeScreen(keys=[-1, -1, ord("x")])
+ tui.flash(screen, "a notice", kind="err")
+ self.assertEqual(screen.keys, [])
+
+ def test_ctrl_c_still_aborts(self):
+ screen = FakeScreen(keys=[-1, 3])
+ with self.assertRaises(tui.WizardCancelled):
+ tui.flash(screen, "a notice")
+
+ def test_frame_flash_ignores_timed_out_reads_too(self):
+ frame = tui.Frame(FakeScreen(keys=[-1, 10]), "Title", "footer")
+ frame.flash("status line notice", "err")
+ self.assertIsNone(frame.status)
+
class WizardTests(unittest.TestCase):
"""The tui.Wizard screen-stack driver: Esc steps back one screen."""