Skip to content

Commit cc7043d

Browse files
[3.13] gh-151693: Make the curses tests portable to other curses implementations (GH-151729) (GH-151730)
Guard the chgat() check (chgat() needs wchgat()) and stop assuming a subpad shares the parent pad's cells (implementation-defined in X/Open). (cherry picked from commit 64fab74) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 92bd696 commit cc7043d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Lib/test/test_curses.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,12 @@ def test_pad(self):
380380
pad.addstr(0, 0, 'PADTEXT')
381381
self.assertEqual(pad.instr(0, 0, 7), b'PADTEXT')
382382

383-
# subpad() shares the parent pad's character cells.
383+
# subpad() creates a pad within the parent pad. Cell sharing with
384+
# the parent is implementation-defined, so write to the subpad itself.
384385
sub = pad.subpad(3, 5, 0, 0)
385386
self.assertEqual(sub.getmaxyx(), (3, 5))
386-
self.assertEqual(sub.instr(0, 0, 5), b'PADTE')
387+
sub.addstr(1, 0, 'sub')
388+
self.assertEqual(sub.instr(1, 0, 3), b'sub')
387389

388390
# A pad is refreshed onto an explicit screen rectangle; the
389391
# 6-argument form is required (and rejected for ordinary windows).
@@ -416,7 +418,8 @@ def test_coordinate_errors(self):
416418
self.assertRaises(curses.error, win.move, 100, 100)
417419
self.assertRaises(curses.error, win.move, -1, -1)
418420
self.assertRaises(curses.error, win.addch, 100, 100, ord('x'))
419-
self.assertRaises(curses.error, win.chgat, 100, 0, curses.A_BOLD)
421+
if hasattr(win, 'chgat'): # chgat() requires wchgat()
422+
self.assertRaises(curses.error, win.chgat, 100, 0, curses.A_BOLD)
420423

421424
def test_argument_errors(self):
422425
win = curses.newwin(5, 10, 0, 0)

0 commit comments

Comments
 (0)