10000 gh-91221: remove unreliable checks on `curses.pair_content(0)` by picnixz · Pull Request #132986 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-91221: remove unreliable checks on curses.pair_content(0) #132986

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

Closed
Show file tree
Hide file tree
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
10 changes: 4 additions & 6 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,6 @@ def test_output_options(self):
curses.nl(False)
curses.nl()


def test_input_options(self):
stdscr = self.stdscr

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Comment on lines +989 to +992
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove the check, the call to curses.pair_content(0) can be removed as well. It is no longer useful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I eventually decided to use the other PR. It's not really an issue and it could catch issues when we call pair_content(0) from the C code.

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()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Do not check the output of :func:`curses.pair_content(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually do not add NEWS entries for test-only changes. They are not useful for Python users.

<curses.pair_content>` since it depends on the terminal capabilities that
are not statically known. Patch by Bénédikt Tran.
Loading
0