Skip to content
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

test_curses fails if terminal defaults to bright white text (15) #91221

Open
ncoghlan opened this issue Mar 19, 2022 · 5 comments
Open

test_curses fails if terminal defaults to bright white text (15) #91221

ncoghlan opened this issue Mar 19, 2022 · 5 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@ncoghlan
Copy link
Contributor

BPO 47065
Nosy @Yhg1s, @gpshead, @ncoghlan, @encukou, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2022-03-19.11:10:26.159>
labels = ['type-bug', 'tests']
title = 'test_curses fails if terminal defaults to bright white text (15)'
updated_at = <Date 2022-03-20.21:36:01.610>
user = 'https://github.com/ncoghlan'

bugs.python.org fields:

activity = <Date 2022-03-20.21:36:01.610>
actor = 'gregory.p.smith'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Tests']
creation = <Date 2022-03-19.11:10:26.159>
creator = 'ncoghlan'
dependencies = []
files = []
hgrepos = []
issue_num = 47065
keywords = []
message_count = 3.0
messages = ['415539', '415559', '415634']
nosy_count = 5.0
nosy_names = ['twouters', 'gregory.p.smith', 'ncoghlan', 'petr.viktorin', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue47065'
versions = []

@ncoghlan
Copy link
Contributor Author

test_curses fails for me by default (running on Fedora 35 in KDE's Konsole):

[ncoghlan@thechalk cpython]$ echo $TERM
xterm-256color
[ncoghlan@thechalk cpython]$ ./python -m test -u curses test_curses
0:00:00 load avg: 0.88 Run tests sequentially
0:00:00 load avg: 0.88 [1/1] test_curses
test test_curses failed -- Traceback (most recent call last):
  File "/home/ncoghlan/devel/cpython/Lib/test/test_curses.py", line 48, in wrapped
    test(self, *args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ncoghlan/devel/cpython/Lib/test/test_curses.py", line 993, in test_use_default_colors
    self.assertIn(old, [(curses.COLOR_WHITE, curses.COLOR_BLACK), (-1, -1), (0, 0)])
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: (15, 0) not found in [(7, 0), (-1, -1), (0, 0)]

test_curses failed (1 failure)

== Tests result: FAILURE ==

1 test failed:
    test_curses

Total duration: 466 ms
Tests result: FAILURE

The active terminal info indicates that the default text colour is indeed bright white (assuming I'm reading the infocmp output correctly), so it feels like (15, 0) is just missing from the set of permissible "old" colour pairs in the test case:

[ncoghlan@thechalk cpython]$ infocmp -L | grep initialize_color
        initialize_color=\E]4;%p1%d;rgb\072%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\,

@ncoghlan ncoghlan added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Mar 19, 2022
@serhiy-storchaka
Copy link
Member

I am surprised. I use Konsole too, and the TERM value and the infocmp output are the same for me.

@gpshead
Copy link
Member

gpshead commented Mar 20, 2022

can we reliably query for what the default is and add that to the expectations? or just skip the test if the defaults don't match our expectations (less ideal)?

if those are a challenge to do reliably - adding 15, 0 to the expected set may be the most practical.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@Krelyshy
Copy link

Same issue with Konsole on openSUSE 15.3 while compiling Python 3.9.14 and 3.10.7

`TERM=xterm-256color
test_use_default_colors (test.test_curses.TestCurses) ...
FAIL

======================================================================
FAIL: test_use_default_colors (test.test_curses.TestCurses)

Traceback (most recent call last):
File "/home/krel/dev/Python-3.9.14/Lib/test/test_curses.py", line 46, in wrapped
test(self, *args, **kwargs)
File "/home/krel/dev/Python-3.9.14/Lib/test/test_curses.py", line 991, in test_use_default_colors
self.assertIn(old, [(curses.COLOR_WHITE, curses.COLOR_BLACK), (-1, -1), (0, 0)])
AssertionError: (15, 0) not found in [(7, 0), (-1, -1), (0, 0)]


Ran 1 test in 0.003s

FAILED (failures=1)
test test_curses failed`

@dandv
Copy link

dandv commented May 13, 2024

Same issue with Konsole on Fedora 38:

Re-running test_curses in verbose mode (matching: test_use_default_colors)
TERM=xterm-256color
test_use_default_colors (test.test_curses.TestCurses.test_use_default_colors) ... 
======================================================================
FAIL: test_use_default_colors (test.test_curses.TestCurses.test_use_default_colors)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dandv/downloads/Python-3.12.3/Lib/test/test_curses.py", line 49, in wrapped
    test(self, *args, **kwargs)
  File "/home/dandv/downloads/Python-3.12.3/Lib/test/test_curses.py", line 999, in test_use_default_colors
    self.assertIn(old, [(curses.COLOR_WHITE, curses.COLOR_BLACK), (-1, -1), (0, 0)])
AssertionError: (15, 0) not found in [(7, 0), (-1, -1), (0, 0)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
Status: Bugs
Development

No branches or pull requests

5 participants