Skip to content
Open
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
12 changes: 9 additions & 3 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,14 @@ def test_input_options(self):
stdscr.timeout(0)
stdscr.timeout(5)

def test_getparent(self):
# getparent() calls no curses function, so it works with any backend
# and is not gated like the is_*() getters below.
stdscr = self.stdscr
self.assertIsNone(stdscr.getparent())
sub = stdscr.subwin(3, 3, 0, 0)
self.assertIs(sub.getparent(), stdscr)

@requires_curses_window_meth('is_scrollok')
def test_state_getters(self):
stdscr = self.stdscr
Expand Down Expand Up @@ -1771,13 +1779,11 @@ def test_state_getters(self):
stdscr.setscrreg(5, 10)
self.assertEqual(stdscr.getscrreg(), (5, 10))

# is_pad()/is_subwin()/getparent().
# is_pad()/is_subwin().
self.assertIs(stdscr.is_pad(), False)
self.assertIs(stdscr.is_subwin(), False)
self.assertIsNone(stdscr.getparent())
sub = stdscr.subwin(3, 3, 0, 0)
self.assertIs(sub.is_subwin(), True)
self.assertIs(sub.getparent(), stdscr)
pad = curses.newpad(5, 5)
self.assertIs(pad.is_pad(), True)

Expand Down
4 changes: 1 addition & 3 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,7 @@ PyCursesWindow_getscrreg(PyObject *op, PyObject *Py_UNUSED(ignored))
}
return Py_BuildValue("(ii)", top, bottom);
}
#endif /* NCURSES_EXT_FUNCS >= 20110404 || PDCURSES */

static PyObject *
PyCursesWindow_getparent(PyObject *op, PyObject *Py_UNUSED(ignored))
Expand All @@ -1882,7 +1883,6 @@ PyCursesWindow_getparent(PyObject *op, PyObject *Py_UNUSED(ignored))
}
return Py_NewRef((PyObject *)self->orig);
}
#endif /* NCURSES_EXT_FUNCS >= 20110404 || PDCURSES */

Window_NoArgNoReturnVoidFunction(wsyncup)
Window_NoArgNoReturnVoidFunction(wsyncdown)
Expand Down Expand Up @@ -4963,11 +4963,9 @@ static PyMethodDef PyCursesWindow_methods[] = {
{"getmaxyx", PyCursesWindow_getmaxyx, METH_NOARGS,
"getmaxyx($self, /)\n--\n\n"
"Return a tuple (y, x) of the window height and width."},
#if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20110404) || defined(PDCURSES)
{"getparent", PyCursesWindow_getparent, METH_NOARGS,
"getparent($self, /)\n--\n\n"
"Return the parent window, or None if this is not a subwindow."},
#endif
{"getparyx", PyCursesWindow_getparyx, METH_NOARGS,
"getparyx($self, /)\n--\n\n"
"Return (y, x) relative to the parent window, or (-1, -1) if none."},
Expand Down
Loading