Fix the broken tests

This commit is contained in:
Kovid Goyal 2017-09-16 17:05:58 +05:30
parent 37feb65204
commit bc1de92534
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 10 additions and 5 deletions

View File

@ -237,7 +237,7 @@ typedef struct {
bool use_latin1, selection_updated_once, is_dirty, scroll_changed;
Cursor *cursor;
SavepointBuffer main_savepoints, alt_savepoints;
PyObject *callbacks;
PyObject *callbacks, *test_child;
LineBuf *linebuf, *main_linebuf, *alt_linebuf;
HistoryBuf *historybuf;
unsigned int history_line_added_count;

View File

@ -49,9 +49,9 @@ static PyObject*
new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
Screen *self;
int ret = 0;
PyObject *callbacks = Py_None;
PyObject *callbacks = Py_None, *test_child = Py_None;
unsigned int columns=80, lines=24, scrollback=0, window_id=0;
if (!PyArg_ParseTuple(args, "|OIIII", &callbacks, &lines, &columns, &scrollback, &window_id)) return NULL;
if (!PyArg_ParseTuple(args, "|OIIIIO", &callbacks, &lines, &columns, &scrollback, &window_id, &test_child)) return NULL;
self = (Screen *)type->tp_alloc(type, 0);
if (self != NULL) {
@ -75,6 +75,7 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
self->history_line_added_count = 0;
RESET_CHARSETS;
self->callbacks = callbacks; Py_INCREF(callbacks);
self->test_child = test_child; Py_INCREF(test_child);
self->cursor = alloc_cursor();
self->color_profile = alloc_color_profile();
self->main_linebuf = alloc_linebuf(lines, columns); self->alt_linebuf = alloc_linebuf(lines, columns);
@ -208,6 +209,7 @@ dealloc(Screen* self) {
pthread_mutex_destroy(&self->write_buf_lock);
PyMem_RawFree(self->write_buf);
Py_CLEAR(self->callbacks);
Py_CLEAR(self->test_child);
Py_CLEAR(self->cursor);
Py_CLEAR(self->main_linebuf);
Py_CLEAR(self->alt_linebuf);
@ -962,7 +964,9 @@ screen_bell(Screen UNUSED *self) {
static inline void
write_to_child(Screen *self, const char *data, size_t sz) {
if (self->window_id) schedule_write_to_child(self->window_id, data, sz);
if (self->test_child != Py_None) { PyObject *r = PyObject_CallMethod(self->test_child, "write", "y#", data, sz); if (r == NULL) PyErr_Print(); Py_CLEAR(r); }
}
#define write_str_to_child(s) write_to_child(self, (s), sizeof((s)) - 1)
void

View File

@ -12,7 +12,7 @@ class Callbacks:
def __init__(self):
self.clear()
def write_to_child(self, data):
def write(self, data):
self.wtcbuf += data
def title_changed(self, data):
@ -70,7 +70,8 @@ class BaseTest(TestCase):
ae = TestCase.assertEqual
def create_screen(self, cols=5, lines=5, scrollback=5):
return Screen(Callbacks(), lines, cols, scrollback)
c = Callbacks()
return Screen(c, lines, cols, scrollback, 0, c)
def assertEqualAttributes(self, c1, c2):
x1, y1, c1.x, c1.y = c1.x, c1.y, 0, 0