]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Skip curses tests when scr_dump()/is_keypad() are unavailable (GH-153866)
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 17 Jul 2026 21:59:27 +0000 (00:59 +0300)
committerGitHub <noreply@github.com>
Fri, 17 Jul 2026 21:59:27 +0000 (21:59 +0000)
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 <noreply@anthropic.com>
Lib/test/test_curses.py

index b99e4efbb83ce41c57c5960da89aa6c1d6257e25..3ba79be789cf3e50e52be560a8fc9a3242f66f87 100644 (file)
@@ -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)