Fix the broken tests
This commit is contained in:
parent
37feb65204
commit
bc1de92534
@ -237,7 +237,7 @@ typedef struct {
|
|||||||
bool use_latin1, selection_updated_once, is_dirty, scroll_changed;
|
bool use_latin1, selection_updated_once, is_dirty, scroll_changed;
|
||||||
Cursor *cursor;
|
Cursor *cursor;
|
||||||
SavepointBuffer main_savepoints, alt_savepoints;
|
SavepointBuffer main_savepoints, alt_savepoints;
|
||||||
PyObject *callbacks;
|
PyObject *callbacks, *test_child;
|
||||||
LineBuf *linebuf, *main_linebuf, *alt_linebuf;
|
LineBuf *linebuf, *main_linebuf, *alt_linebuf;
|
||||||
HistoryBuf *historybuf;
|
HistoryBuf *historybuf;
|
||||||
unsigned int history_line_added_count;
|
unsigned int history_line_added_count;
|
||||||
|
|||||||
@ -49,9 +49,9 @@ static PyObject*
|
|||||||
new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
|
new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
|
||||||
Screen *self;
|
Screen *self;
|
||||||
int ret = 0;
|
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;
|
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);
|
self = (Screen *)type->tp_alloc(type, 0);
|
||||||
if (self != NULL) {
|
if (self != NULL) {
|
||||||
@ -75,6 +75,7 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
|
|||||||
self->history_line_added_count = 0;
|
self->history_line_added_count = 0;
|
||||||
RESET_CHARSETS;
|
RESET_CHARSETS;
|
||||||
self->callbacks = callbacks; Py_INCREF(callbacks);
|
self->callbacks = callbacks; Py_INCREF(callbacks);
|
||||||
|
self->test_child = test_child; Py_INCREF(test_child);
|
||||||
self->cursor = alloc_cursor();
|
self->cursor = alloc_cursor();
|
||||||
self->color_profile = alloc_color_profile();
|
self->color_profile = alloc_color_profile();
|
||||||
self->main_linebuf = alloc_linebuf(lines, columns); self->alt_linebuf = alloc_linebuf(lines, columns);
|
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);
|
pthread_mutex_destroy(&self->write_buf_lock);
|
||||||
PyMem_RawFree(self->write_buf);
|
PyMem_RawFree(self->write_buf);
|
||||||
Py_CLEAR(self->callbacks);
|
Py_CLEAR(self->callbacks);
|
||||||
|
Py_CLEAR(self->test_child);
|
||||||
Py_CLEAR(self->cursor);
|
Py_CLEAR(self->cursor);
|
||||||
Py_CLEAR(self->main_linebuf);
|
Py_CLEAR(self->main_linebuf);
|
||||||
Py_CLEAR(self->alt_linebuf);
|
Py_CLEAR(self->alt_linebuf);
|
||||||
@ -962,7 +964,9 @@ screen_bell(Screen UNUSED *self) {
|
|||||||
static inline void
|
static inline void
|
||||||
write_to_child(Screen *self, const char *data, size_t sz) {
|
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->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)
|
#define write_str_to_child(s) write_to_child(self, (s), sizeof((s)) - 1)
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class Callbacks:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
def write_to_child(self, data):
|
def write(self, data):
|
||||||
self.wtcbuf += data
|
self.wtcbuf += data
|
||||||
|
|
||||||
def title_changed(self, data):
|
def title_changed(self, data):
|
||||||
@ -70,7 +70,8 @@ class BaseTest(TestCase):
|
|||||||
ae = TestCase.assertEqual
|
ae = TestCase.assertEqual
|
||||||
|
|
||||||
def create_screen(self, cols=5, lines=5, scrollback=5):
|
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):
|
def assertEqualAttributes(self, c1, c2):
|
||||||
x1, y1, c1.x, c1.y = c1.x, c1.y, 0, 0
|
x1, y1, c1.x, c1.y = c1.x, c1.y, 0, 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user