https://github.com/python/cpython/commit/41e19a78b2e80514a3352cdcbd51c79bf4bdf5bb
commit: 41e19a78b2e80514a3352cdcbd51c79bf4bdf5bb
branch: 3.13
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: picnixz <10796600+picn...@users.noreply.github.com>
date: 2025-04-26T11:02:17Z
summary:

[3.13] gh-91221: fix `test_curses.test_use_default_colors` for xterm-256color 
(GH-132990) (#132992)

gh-91221: fix `test_curses.test_use_default_colors` for xterm-256color 
(GH-132990)

Terminals with `xterm-256color` Xterm support may use 15 (bright white) as 
their default foreground color.
(cherry picked from commit 7f02ded29fb0e7f4ee115b5be32a591ff7b449b8)

Co-authored-by: Bénédikt Tran <10796600+picn...@users.noreply.github.com>

files:
M Lib/test/test_curses.py

diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
index cc3aa561cd4c42..6fe0e7fd4b7fe9 100644
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -51,6 +51,12 @@ def wrapped(self, *args, **kwargs):
 
 term = os.environ.get('TERM')
 SHORT_MAX = 0x7fff
+DEFAULT_PAIR_CONTENTS = [
+    (curses.COLOR_WHITE, curses.COLOR_BLACK),
+    (0, 0),
+    (-1, -1),
+    (15, 0),  # for xterm-256color (15 is for BRIGHT WHITE)
+]
 
 # If newterm was supported we could use it instead of initscr and not exit
 @unittest.skipIf(not term or term == 'unknown',
@@ -751,7 +757,6 @@ def test_output_options(self):
         curses.nl(False)
         curses.nl()
 
-
     def test_input_options(self):
         stdscr = self.stdscr
 
@@ -944,8 +949,7 @@ def get_pair_limit(self):
     @requires_colors
     def test_pair_content(self):
         if not hasattr(curses, 'use_default_colors'):
-            self.assertEqual(curses.pair_content(0),
-                             (curses.COLOR_WHITE, curses.COLOR_BLACK))
+            self.assertIn(curses.pair_content(0), DEFAULT_PAIR_CONTENTS)
         curses.pair_content(0)
         maxpair = self.get_pair_limit() - 1
         if maxpair > 0:
@@ -996,7 +1000,7 @@ def test_use_default_colors(self):
         except curses.error:
             self.skipTest('cannot change color (use_default_colors() failed)')
         self.assertEqual(curses.pair_content(0), (-1, -1))
-        self.assertIn(old, [(curses.COLOR_WHITE, curses.COLOR_BLACK), (-1, 
-1), (0, 0)])
+        self.assertIn(old, DEFAULT_PAIR_CONTENTS)
 
     def test_keyname(self):
         # TODO: key_name()

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to