Skip to content

Commit bf61794

Browse files
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 <noreply@anthropic.com>
1 parent 6713576 commit bf61794

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

Lib/test/test_curses.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,8 +1359,6 @@ def test_state_getters(self):
13591359
# Each is_*() getter returns the value set by the matching setter.
13601360
for setter, getter in [
13611361
('clearok', 'is_cleared'),
1362-
('idcok', 'is_idcok'),
1363-
('idlok', 'is_idlok'),
13641362
('keypad', 'is_keypad'),
13651363
('leaveok', 'is_leaveok'),
13661364
('nodelay', 'is_nodelay'),
@@ -1371,6 +1369,19 @@ def test_state_getters(self):
13711369
self.assertIs(getattr(stdscr, getter)(), True)
13721370
getattr(stdscr, setter)(False)
13731371
self.assertIs(getattr(stdscr, getter)(), False)
1372+
1373+
# idcok()/idlok() only take effect if the terminal can insert/delete
1374+
# characters/lines, so the getter reflects that capability.
1375+
stdscr.idcok(True)
1376+
self.assertIs(stdscr.is_idcok(), curses.has_ic())
1377+
stdscr.idcok(False)
1378+
self.assertIs(stdscr.is_idcok(), False)
1379+
1380+
stdscr.idlok(True)
1381+
self.assertIs(stdscr.is_idlok(),
1382+
curses.has_il() or curses.tigetstr('csr') is not None)
1383+
stdscr.idlok(False)
1384+
self.assertIs(stdscr.is_idlok(), False)
13741385
if hasattr(stdscr, 'immedok'):
13751386
stdscr.immedok(True)
13761387
self.assertIs(stdscr.is_immedok(), True)

0 commit comments

Comments
 (0)