1. Ali Afshar
  2. er-main

Source

er-main / tests / test_buffer.py


from pygtkhelpers.utils import refresh_gui

from er.buffer import Buffer

def test_buffer_set_text():
    b = Buffer()
    b.set_text(u'Hello')
    refresh_gui()
    assert (b._source_buf.get_text(b._source_buf.get_start_iter(),
                                   b._source_buf.get_end_iter())
            == u'Hello')


def test_buffer_get_text():
    b = Buffer()
    b._source_buf.set_text(u'Hello')
    refresh_gui()
    assert b.get_text() == u'Hello'


def test_cursor_offset_empty():
    b = Buffer()
    assert b.cursor_offset == 0


def test_cursor_offset_text_add():
    b = Buffer()
    b.set_text(u'Hello')
    assert b.cursor_offset == 5


def test_cursor_line_empty():
    b = Buffer()
    assert b.cursor_line == 0


def test_cursor_line():
    b = Buffer()
    b.set_text(u'Hello')
    assert b.cursor_line == 0


def test_cursor_lines():
    b = Buffer()
    b.set_text(u'Hello\nHello')
    print b.cursor_line
    assert b.cursor_line == 1