mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-91221: fix test_curses.test_use_default_colors
for xterm-256color (#132990)
Terminals with `xterm-256color` Xterm support may use 15 (bright white) as their default foreground color.
This commit is contained in:
parent
ca12a744ab
commit
7f02ded29f
1 changed files with 8 additions and 4 deletions
|
@ -51,6 +51,12 @@ def requires_colors(test):
|
||||||
|
|
||||||
term = os.environ.get('TERM')
|
term = os.environ.get('TERM')
|
||||||
SHORT_MAX = 0x7fff
|
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
|
# If newterm was supported we could use it instead of initscr and not exit
|
||||||
@unittest.skipIf(not term or term == 'unknown',
|
@unittest.skipIf(not term or term == 'unknown',
|
||||||
|
@ -751,7 +757,6 @@ class TestCurses(unittest.TestCase):
|
||||||
curses.nl(False)
|
curses.nl(False)
|
||||||
curses.nl()
|
curses.nl()
|
||||||
|
|
||||||
|
|
||||||
def test_input_options(self):
|
def test_input_options(self):
|
||||||
stdscr = self.stdscr
|
stdscr = self.stdscr
|
||||||
|
|
||||||
|
@ -944,8 +949,7 @@ class TestCurses(unittest.TestCase):
|
||||||
@requires_colors
|
@requires_colors
|
||||||
def test_pair_content(self):
|
def test_pair_content(self):
|
||||||
if not hasattr(curses, 'use_default_colors'):
|
if not hasattr(curses, 'use_default_colors'):
|
||||||
self.assertEqual(curses.pair_content(0),
|
self.assertIn(curses.pair_content(0), DEFAULT_PAIR_CONTENTS)
|
||||||
(curses.COLOR_WHITE, curses.COLOR_BLACK))
|
|
||||||
curses.pair_content(0)
|
curses.pair_content(0)
|
||||||
maxpair = self.get_pair_limit() - 1
|
maxpair = self.get_pair_limit() - 1
|
||||||
if maxpair > 0:
|
if maxpair > 0:
|
||||||
|
@ -996,7 +1000,7 @@ class TestCurses(unittest.TestCase):
|
||||||
except curses.error:
|
except curses.error:
|
||||||
self.skipTest('cannot change color (use_default_colors() failed)')
|
self.skipTest('cannot change color (use_default_colors() failed)')
|
||||||
self.assertEqual(curses.pair_content(0), (-1, -1))
|
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):
|
def test_keyname(self):
|
||||||
# TODO: key_name()
|
# TODO: key_name()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue