Skip to content

Commit 41e19a7

Browse files
[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 7f02ded) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
1 parent 0877222 commit 41e19a7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Lib/test/test_curses.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def wrapped(self, *args, **kwargs):
5151

5252
term = os.environ.get('TERM')
5353
SHORT_MAX = 0x7fff
54+
DEFAULT_PAIR_CONTENTS = [
55+
(curses.COLOR_WHITE, curses.COLOR_BLACK),
56+
(0, 0),
57+
(-1, -1),
58+
(15, 0), # for xterm-256color (15 is for BRIGHT WHITE)
59+
]
5460

5561
# If newterm was supported we could use it instead of initscr and not exit
5662
@unittest.skipIf(not term or term == 'unknown',
@@ -751,7 +757,6 @@ def test_output_options(self):
751757
curses.nl(False)
752758
curses.nl()
753759

754-
755760
def test_input_options(self):
756761
stdscr = self.stdscr
757762

@@ -944,8 +949,7 @@ def get_pair_limit(self):
944949
@requires_colors
945950
def test_pair_content(self):
946951
if not hasattr(curses, 'use_default_colors'):
947-
self.assertEqual(curses.pair_content(0),
948-
(curses.COLOR_WHITE, curses.COLOR_BLACK))
952+
self.assertIn(curses.pair_content(0), DEFAULT_PAIR_CONTENTS)
949953
curses.pair_content(0)
950954
maxpair = self.get_pair_limit() - 1
951955
if maxpair > 0:
@@ -996,7 +1000,7 @@ def test_use_default_colors(self):
9961000
except curses.error:
9971001
self.skipTest('cannot change color (use_default_colors() failed)')
9981002
self.assertEqual(curses.pair_content(0), (-1, -1))
999-
self.assertIn(old, [(curses.COLOR_WHITE, curses.COLOR_BLACK), (-1, -1), (0, 0)])
1003+
self.assertIn(old, DEFAULT_PAIR_CONTENTS)
10001004

10011005
def test_keyname(self):
10021006
# TODO: key_name()

0 commit comments

Comments
 (0)