| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 19f6830 commit baac01e
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ | |||
| 7 | 7 | ** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards | |
| 8 | 8 | ** against multiple definition of wchar_t. | |
| 9 | 9 | */ | |
| 10 | - #ifdef _BSD_WCHAR_T_DEFINED_ | ||
| 10 | + #ifdef _BSD_WCHAR_T_DEFINED_ | ||
| 11 | 11 | #define _WCHAR_T | |
| 12 | 12 | #endif | |
| 13 | 13 | ||
@@ -22,7 +22,7 @@ | |||
| 22 | 22 | ** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards | |
| 23 | 23 | ** against multiple definition of wchar_t and wint_t. | |
| 24 | 24 | */ | |
| 25 | - #ifdef _XOPEN_SOURCE_EXTENDED | ||
| 25 | + #ifdef _XOPEN_SOURCE_EXTENDED | ||
| 26 | 26 | #ifndef __FreeBSD_version | |
| 27 | 27 | #include <osreldate.h> | |
| 28 | 28 | #endif | |
@@ -48,10 +48,6 @@ | |||
| 48 | 48 | #include <ncurses.h> | |
| 49 | 49 | #else | |
| 50 | 50 | #include <curses.h> | |
| 51 | - #ifdef HAVE_TERM_H | ||
| 52 | - /* for tigetstr, which is not declared in SysV curses */ | ||
| 53 | - #include <term.h> | ||
| 54 | - #endif | ||
| 55 | 51 | #endif | |
| 56 | 52 | ||
| 57 | 53 | #ifdef HAVE_NCURSES_H | |
@@ -74,12 +70,12 @@ extern "C" { | |||
| 74 | 70 | /* Type declarations */ | |
| 75 | 71 | ||
| 76 | 72 | typedef struct { | |
| 77 | - PyObject_HEAD | ||
| 78 | - WINDOW *win; | ||
| 79 | - char *encoding; | ||
| 73 | + PyObject_HEAD | ||
| 74 | + WINDOW *win; | ||
| 75 | + char *encoding; | ||
| 80 | 76 | } PyCursesWindowObject; | |
| 81 | 77 | ||
| 82 | - #define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) | ||
| 78 | + #define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) | ||
| 83 | 79 | ||
| 84 | 80 | #define PyCurses_CAPSULE_NAME "_curses._C_API" | |
| 85 | 81 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,9 +25,12 @@ | |||
| 25 | 25 | ||
| 26 | 26 | # If either of these don't exist, skip the tests. | |
| 27 | 27 | curses = import_module('curses') | |
| 28 | - import_module('curses.panel') | ||
| 29 | 28 | import_module('curses.ascii') | |
| 30 | 29 | import_module('curses.textpad') | |
| 30 | + try: | ||
| 31 | + import curses.panel | ||
| 32 | + except ImportError: | ||
| 33 | + pass | ||
| 31 | 34 | ||
| 32 | 35 | def requires_curses_func(name): | |
| 33 | 36 | return unittest.skipUnless(hasattr(curses, name), | |
@@ -138,7 +141,8 @@ def test_window_funcs(self): | |||
| 138 | 141 | ||
| 139 | 142 | stdscr.idcok(1) | |
| 140 | 143 | stdscr.idlok(1) | |
| 141 | - stdscr.immedok(1) | ||
| 144 | + if hasattr(stdscr, 'immedok'): | ||
| 145 | + stdscr.immedok(1) | ||
| 142 | 146 | stdscr.insch('c') | |
| 143 | 147 | stdscr.insdelln(1) | |
| 144 | 148 | stdscr.insnstr('abc', 3) | |
@@ -172,7 +176,8 @@ def test_window_funcs(self): | |||
| 172 | 176 | stdscr.setscrreg(10,15) | |
| 173 | 177 | win3 = stdscr.subwin(10,10) | |
| 174 | 178 | win3 = stdscr.subwin(10,10, 5,5) | |
| 175 | - stdscr.syncok(1) | ||
| 179 | + if hasattr(stdscr, 'syncok'): | ||
| 180 | + stdscr.syncok(1) | ||
| 176 | 181 | stdscr.timeout(5) | |
| 177 | 182 | stdscr.touchline(5,5) | |
| 178 | 183 | stdscr.touchline(5,5,0) | |
@@ -211,15 +216,19 @@ def test_module_funcs(self): | |||
| 211 | 216 | "Test module-level functions" | |
| 212 | 217 | for func in [curses.baudrate, curses.beep, curses.can_change_color, | |
| 213 | 218 | curses.cbreak, curses.def_prog_mode, curses.doupdate, | |
| 214 | - curses.filter, curses.flash, curses.flushinp, | ||
| 219 | + curses.flash, curses.flushinp, | ||
| 215 | 220 | curses.has_colors, curses.has_ic, curses.has_il, | |
| 216 | 221 | curses.isendwin, curses.killchar, curses.longname, | |
| 217 | 222 | curses.nocbreak, curses.noecho, curses.nonl, | |
| 218 | 223 | curses.noqiflush, curses.noraw, | |
| 219 | 224 | curses.reset_prog_mode, curses.termattrs, | |
| 220 | - curses.termname, curses.erasechar, curses.getsyx]: | ||
| 225 | + curses.termname, curses.erasechar]: | ||
| 221 | 226 | with self.subTest(func=func.__qualname__): | |
| 222 | 227 | func() | |
| 228 | + if hasattr(curses, 'filter'): | ||
| 229 | + curses.filter() | ||
| 230 | + if hasattr(curses, 'getsyx'): | ||
| 231 | + curses.getsyx() | ||
| 223 | 232 | ||
| 224 | 233 | # Functions that actually need arguments | |
| 225 | 234 | if curses.tigetstr("cnorm"): | |
@@ -243,15 +252,18 @@ def test_module_funcs(self): | |||
| 243 | 252 | curses.putp(b'abc') | |
| 244 | 253 | curses.qiflush() | |
| 245 | 254 | curses.raw() ; curses.raw(1) | |
| 246 | - curses.setsyx(5,5) | ||
| 255 | + if hasattr(curses, 'setsyx'): | ||
| 256 | + curses.setsyx(5,5) | ||
| 247 | 257 | curses.tigetflag('hc') | |
| 248 | 258 | curses.tigetnum('co') | |
| 249 | 259 | curses.tigetstr('cr') | |
| 250 | 260 | curses.tparm(b'cr') | |
| 251 | - curses.typeahead(sys.__stdin__.fileno()) | ||
| 261 | + if hasattr(curses, 'typeahead'): | ||
| 262 | + curses.typeahead(sys.__stdin__.fileno()) | ||
| 252 | 263 | curses.unctrl('a') | |
| 253 | 264 | curses.ungetch('a') | |
| 254 | - curses.use_env(1) | ||
| 265 | + if hasattr(curses, 'use_env'): | ||
| 266 | + curses.use_env(1) | ||
| 255 | 267 | ||
| 256 | 268 | # Functions only available on a few platforms | |
| 257 | 269 | def test_colors_funcs(self): | |
@@ -285,6 +297,7 @@ def test_getmouse(self): | |||
| 285 | 297 | curses.ungetmouse(0, 0, 0, 0, curses.BUTTON1_PRESSED) | |
| 286 | 298 | m = curses.getmouse() | |
| 287 | 299 | ||
| 300 | + @requires_curses_func('panel') | ||
| 288 | 301 | def test_userptr_without_set(self): | |
| 289 | 302 | w = curses.newwin(10, 10) | |
| 290 | 303 | p = curses.panel.new_panel(w) | |
@@ -293,6 +306,7 @@ def test_userptr_without_set(self): | |||
| 293 | 306 | msg='userptr should fail since not set'): | |
| 294 | 307 | p.userptr() | |
| 295 | 308 | ||
| 309 | + @requires_curses_func('panel') | ||
| 296 | 310 | def test_userptr_memory_leak(self): | |
| 297 | 311 | w = curses.newwin(10, 10) | |
| 298 | 312 | p = curses.panel.new_panel(w) | |
@@ -305,6 +319,7 @@ def test_userptr_memory_leak(self): | |||
| 305 | 319 | self.assertEqual(sys.getrefcount(obj), nrefs, | |
| 306 | 320 | "set_userptr leaked references") | |
| 307 | 321 | ||
| 322 | + @requires_curses_func('panel') | ||
| 308 | 323 | def test_userptr_segfault(self): | |
| 309 | 324 | panel = curses.panel.new_panel(self.stdscr) | |
| 310 | 325 | class A: | |
@@ -313,6 +328,7 @@ def __del__(self): | |||
| 313 | 328 | panel.set_userptr(A()) | |
| 314 | 329 | panel.set_userptr(None) | |
| 315 | 330 | ||
| 331 | + @requires_curses_func('panel') | ||
| 316 | 332 | def test_new_curses_panel(self): | |
| 317 | 333 | panel = curses.panel.new_panel(self.stdscr) | |
| 318 | 334 | self.assertRaises(TypeError, type(panel)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Fixed building the curses module on NetBSD. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments