|
14 | 14 | check_disallow_instantiation, MISSING_C_DOCSTRINGS, |
15 | 15 | gc_collect, SHORT_TIMEOUT) |
16 | 16 | from test.support.import_helper import import_module |
| 17 | +from test.support import os_helper |
17 | 18 |
|
18 | 19 | # Optionally test curses module. This currently requires that the |
19 | 20 | # 'curses' resource be given on the regrtest command line using the -u |
@@ -3325,28 +3326,31 @@ def test_set_term(self): |
3325 | 3326 | self.assertIs(curses.set_term(b), a) |
3326 | 3327 |
|
3327 | 3328 | def test_set_term_refreshes_lines_cols_colors(self): |
3328 | | - from test.support import os_helper |
3329 | 3329 | s1 = self.make_pty() |
3330 | 3330 | s2 = self.make_pty() |
3331 | | - |
| 3331 | + |
3332 | 3332 | with os_helper.EnvironmentVarGuard() as env: |
3333 | 3333 | env['LINES'] = '25' |
3334 | 3334 | 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 | + |
3342 | 3344 | env['LINES'] = '30' |
3343 | 3345 | 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 |
3350 | 3354 |
|
3351 | 3355 | curses.set_term(a) |
3352 | 3356 | self.assertEqual((curses.LINES, curses.COLS), a.stdscr.getmaxyx()) |
|
0 commit comments