Skip to content

Commit 56edfc3

Browse files
gh-155976: Address review comments on curses set_term
1 parent 45a353a commit 56edfc3

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

Lib/test/test_curses.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
check_disallow_instantiation, MISSING_C_DOCSTRINGS,
1515
gc_collect, SHORT_TIMEOUT)
1616
from test.support.import_helper import import_module
17+
from test.support import os_helper
1718

1819
# Optionally test curses module. This currently requires that the
1920
# 'curses' resource be given on the regrtest command line using the -u
@@ -3325,28 +3326,31 @@ def test_set_term(self):
33253326
self.assertIs(curses.set_term(b), a)
33263327

33273328
def test_set_term_refreshes_lines_cols_colors(self):
3328-
from test.support import os_helper
33293329
s1 = self.make_pty()
33303330
s2 = self.make_pty()
3331-
3331+
33323332
with os_helper.EnvironmentVarGuard() as env:
33333333
env['LINES'] = '25'
33343334
env['COLUMNS'] = '80'
3335-
a = curses.newterm('xterm', s1, s1)
3336-
if hasattr(curses, 'start_color'):
3337-
try:
3338-
curses.start_color()
3339-
except curses.error:
3340-
pass
3341-
3335+
try:
3336+
a = curses.newterm('xterm', s1, s1)
3337+
except curses.error:
3338+
self.skipTest('no xterm terminfo entry')
3339+
try:
3340+
curses.start_color()
3341+
except curses.error:
3342+
pass
3343+
33423344
env['LINES'] = '30'
33433345
env['COLUMNS'] = '100'
3344-
b = curses.newterm('xterm-256color', s2, s2)
3345-
if hasattr(curses, 'start_color'):
3346-
try:
3347-
curses.start_color()
3348-
except curses.error:
3349-
pass
3346+
try:
3347+
b = curses.newterm('xterm-256color', s2, s2)
3348+
except curses.error:
3349+
self.skipTest('no xterm-256color terminfo entry')
3350+
try:
3351+
curses.start_color()
3352+
except curses.error:
3353+
pass
33503354

33513355
curses.set_term(a)
33523356
self.assertEqual((curses.LINES, curses.COLS), a.stdscr.getmaxyx())

Misc/NEWS.d/next/Library/2026-08-18-12-30-00.gh-issue-155976.xyz123.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)