https://github.com/python/cpython/commit/bf61794fd2c293d79a81f3578fd3fc3f96dd341c commit: bf61794fd2c293d79a81f3578fd3fc3f96dd341c branch: main author: Serhiy Storchaka <[email protected]> committer: serhiy-storchaka <[email protected]> date: 2026-06-26T15:50:30Z summary:
gh-151776: Fix test_state_getters on terminals without insert/delete capability (GH-152304) idcok() and idlok() take effect only when the terminal can insert or delete characters or lines, so check their getters against the terminal's capabilities instead of asserting an unconditional round-trip. Co-authored-by: Claude Opus 4.8 <[email protected]> files: M Lib/test/test_curses.py diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index deadafc93074e3..ba259ae0d1ce36 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -1359,8 +1359,6 @@ def test_state_getters(self): # Each is_*() getter returns the value set by the matching setter. for setter, getter in [ ('clearok', 'is_cleared'), - ('idcok', 'is_idcok'), - ('idlok', 'is_idlok'), ('keypad', 'is_keypad'), ('leaveok', 'is_leaveok'), ('nodelay', 'is_nodelay'), @@ -1371,6 +1369,19 @@ def test_state_getters(self): self.assertIs(getattr(stdscr, getter)(), True) getattr(stdscr, setter)(False) self.assertIs(getattr(stdscr, getter)(), False) + + # idcok()/idlok() only take effect if the terminal can insert/delete + # characters/lines, so the getter reflects that capability. + stdscr.idcok(True) + self.assertIs(stdscr.is_idcok(), curses.has_ic()) + stdscr.idcok(False) + self.assertIs(stdscr.is_idcok(), False) + + stdscr.idlok(True) + self.assertIs(stdscr.is_idlok(), + curses.has_il() or curses.tigetstr('csr') is not None) + stdscr.idlok(False) + self.assertIs(stdscr.is_idlok(), False) if hasattr(stdscr, 'immedok'): stdscr.immedok(True) self.assertIs(stdscr.is_immedok(), True) _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
