From 89d56e296ed3a0da02a55beba39fda335a78ebfe 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 10:34:43 +0200 Subject: [PATCH 1/2] remove checks on `curses.pair_content(0)` The current terminal fg/bg colors given by `pair_content(0)`, which is backed by `extended_pair_content(3)`, depends on the terminal emulator and its supported colors. Thus, its output cannot not be reliably checked. --- Lib/test/test_curses.py | 10 ++++------ .../2025-04-26-10-36-43.gh-issue-132985.qlhMVS.rst | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2025-04-26-10-36-43.gh-issue-132985.qlhMVS.rst diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index cc3aa561cd4c42..4b43ab0d26faa4 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -751,7 +751,6 @@ def test_output_options(self): curses.nl(False) curses.nl() - def test_input_options(self): stdscr = self.stdscr @@ -943,9 +942,6 @@ 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)) curses.pair_content(0) maxpair = self.get_pair_limit() - 1 if maxpair > 0: @@ -990,13 +986,15 @@ def test_color_attrs(self): @requires_curses_func('use_default_colors') @requires_colors def test_use_default_colors(self): - old = curses.pair_content(0) + # The current terminal fg/bg colors given by pair_content(0), + # which is backed by extended_pair_content(3), depends on the + # terminal emulator and its supported colors. + curses.pair_content(0) try: curses.use_default_colors() 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)]) def test_keyname(self): # TODO: key_name() diff --git a/Misc/NEWS.d/next/Tests/2025-04-26-10-36-43.gh-issue-132985.qlhMVS.rst b/Misc/NEWS.d/next/Tests/2025-04-26-10-36-43.gh-issue-132985.qlhMVS.rst new file mode 100644 index 00000000000000..4f5d5be9c78419 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2025-04-26-10-36-43.gh-issue-132985.qlhMVS.rst @@ -0,0 +1,3 @@ +Do not check the output of :func:`curses.pair_content(0) +` since it depends on the terminal capabilities that +are not statically known. Patch by Bénédikt Tran. From 2f52c3379266de6e5e1968572d4a0d5f31d0cbd3 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 11:34:36 +0200 Subject: [PATCH 2/2] blurb --- ...5.qlhMVS.rst => 2025-04-26-11-34-07.gh-issue-91221.qlhMVS.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/Tests/{2025-04-26-10-36-43.gh-issue-132985.qlhMVS.rst => 2025-04-26-11-34-07.gh-issue-91221.qlhMVS.rst} (100%) diff --git a/Misc/NEWS.d/next/Tests/2025-04-26-10-36-43.gh-issue-132985.qlhMVS.rst b/Misc/NEWS.d/next/Tests/2025-04-26-11-34-07.gh-issue-91221.qlhMVS.rst similarity index 100% rename from Misc/NEWS.d/next/Tests/2025-04-26-10-36-43.gh-issue-132985.qlhMVS.rst rename to Misc/NEWS.d/next/Tests/2025-04-26-11-34-07.gh-issue-91221.qlhMVS.rst