Skip to content

Commit 2facde8

Browse files
gh-152263: Make test_init_reserves_a_line portable to non-ncurses curses
Soft-label formats 2 and 3 are ncurses extensions; other curses implementations (such as NetBSD curses) reject them with an error. Require every format to work on ncurses, but tolerate the extended formats being unsupported elsewhere. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 75013a2 commit 2facde8

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

Lib/test/test_curses.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,10 +3001,18 @@ def make_slk_screen(self, fmt=0):
30013001

30023002
def test_init_reserves_a_line(self):
30033003
# Every layout takes the bottom line for the labels; the index-line
3004-
# layout (3) takes a second line for the index.
3004+
# layout (3) takes a second line for the index. Layouts 0 and 1 are
3005+
# standard; 2 and 3 are ncurses extensions that other curses
3006+
# implementations reject (slk_init() then returns an error).
3007+
ncurses = hasattr(curses, 'ncurses_version')
30053008
for fmt, lines in [(0, 23), (1, 23), (2, 23), (3, 22)]:
30063009
with self.subTest(fmt=fmt):
3007-
screen = self.make_slk_screen(fmt)
3010+
try:
3011+
screen = self.make_slk_screen(fmt)
3012+
except curses.error:
3013+
if ncurses or fmt < 2:
3014+
raise
3015+
continue
30083016
self.assertEqual(screen.stdscr.getmaxyx()[0], lines)
30093017
curses.endwin()
30103018

0 commit comments

Comments
 (0)