From: Serhiy Storchaka Date: Fri, 19 Jun 2026 12:08:22 +0000 (+0300) Subject: [3.14] gh-151693: Make the curses tests portable to other curses implementations... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8fff472ec18973e82d674f4d471903b84026e59f;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-151693: Make the curses tests portable to other curses implementations (GH-151729) (GH-151731) 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 64fab74bd7288bfa67cd7727452febdaafed4270) Co-authored-by: Claude Opus 4.8 (1M context) --- diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index 0ed7d947c75a..2029c1d8a312 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -374,10 +374,12 @@ class TestCurses(unittest.TestCase): pad.addstr(0, 0, 'PADTEXT') self.assertEqual(pad.instr(0, 0, 7), b'PADTEXT') - # subpad() shares the parent pad's character cells. + # subpad() creates a pad within the parent pad. Cell sharing with + # the parent is implementation-defined, so write to the subpad itself. sub = pad.subpad(3, 5, 0, 0) self.assertEqual(sub.getmaxyx(), (3, 5)) - self.assertEqual(sub.instr(0, 0, 5), b'PADTE') + sub.addstr(1, 0, 'sub') + self.assertEqual(sub.instr(1, 0, 3), b'sub') # A pad is refreshed onto an explicit screen rectangle; the # 6-argument form is required (and rejected for ordinary windows). @@ -410,7 +412,8 @@ class TestCurses(unittest.TestCase): self.assertRaises(curses.error, win.move, 100, 100) self.assertRaises(curses.error, win.move, -1, -1) self.assertRaises(curses.error, win.addch, 100, 100, ord('x')) - self.assertRaises(curses.error, win.chgat, 100, 0, curses.A_BOLD) + if hasattr(win, 'chgat'): # chgat() requires wchgat() + self.assertRaises(curses.error, win.chgat, 100, 0, curses.A_BOLD) def test_argument_errors(self): win = curses.newwin(5, 10, 0, 0)