From: Serhiy Storchaka Date: Fri, 17 Jul 2026 21:59:27 +0000 (+0300) Subject: Skip curses tests when scr_dump()/is_keypad() are unavailable (GH-153866) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4c19f5323e9b16556388926fd804366d0112690;p=thirdparty%2FPython%2Fcpython.git Skip curses tests when scr_dump()/is_keypad() are unavailable (GH-153866) test_scr_dump() and test_state_getters() errored instead of skipping on builds without scr_dump(), is_keypad() or is_leaveok() (e.g. some narrow ncurses, NetBSD, PDCurses). Co-authored-by: Claude Opus 4.8 --- diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index b99e4efbb83c..3ba79be789cf 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -1364,6 +1364,7 @@ class TestCurses(unittest.TestCase): self.assertEqual(win.getmaxyx(), (5, 12)) self.assertEqual(win.instr(2, 0), b' Lorem ipsum') + @requires_curses_func('scr_dump') def test_scr_dump(self): # Test scr_dump(), scr_restore(), scr_init() and scr_set(). # scr_dump() writes the virtual screen to a named file; the other three @@ -1722,6 +1723,9 @@ class TestCurses(unittest.TestCase): ('notimeout', 'is_notimeout'), ('scrollok', 'is_scrollok'), ]: + # is_keypad()/is_leaveok() are not available in every curses build. + if not hasattr(stdscr, getter): + continue getattr(stdscr, setter)(True) self.assertIs(getattr(stdscr, getter)(), True) getattr(stdscr, setter)(False)