From 9bf2c8ab30e00feec1b81bb1cef1bdefc4d9f9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sat, 26 Apr 2025 12:06:55 +0200 Subject: [PATCH 1/3] fix `test_use_default_colors` for xterm256-color --- Lib/test/test_curses.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index cc3aa561cd4c42..938fe6533264ef 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), # error + (15, 0), # for xterm256-color (15 is usually 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() From 0ab82e453ae0fb6395f25d82455aee76f205bf49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sat, 26 Apr 2025 12:10:40 +0200 Subject: [PATCH 2/3] fixup --- Lib/test/test_curses.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index 938fe6533264ef..40228f842a9fa6 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -55,7 +55,7 @@ def wrapped(self, *args, **kwargs): (curses.COLOR_WHITE, curses.COLOR_BLACK), (0, 0), (-1, -1), # error - (15, 0), # for xterm256-color (15 is usually for BRIGHT WHITE) + (15, 0), # for xterm-256color (15 is for BRIGHT WHITE) ] # If newterm was supported we could use it instead of initscr and not exit From fda2846af790b26fbf89a751385fa22e57f2629a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sat, 26 Apr 2025 12:12:16 +0200 Subject: [PATCH 3/3] Update Lib/test/test_curses.py --- Lib/test/test_curses.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index 40228f842a9fa6..6fe0e7fd4b7fe9 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -54,8 +54,8 @@ def wrapped(self, *args, **kwargs): DEFAULT_PAIR_CONTENTS = [ (curses.COLOR_WHITE, curses.COLOR_BLACK), (0, 0), - (-1, -1), # error - (15, 0), # for xterm-256color (15 is for BRIGHT WHITE) + (-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