Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -751,7 +757,6 @@ def test_output_options(self):
curses.nl(False)
curses.nl()


def test_input_options(self):
stdscr = self.stdscr

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
Loading