def test_add(self): block = WrapBlock() # Add to empty block - just add it a a line. block.add_text('text') assert block.words == ['text'] assert not block.is_empty() # Add to non empty block - add it to the last line. block.add_text('-xx') assert block.words == ['text', '-xx'] assert not block.is_box_started() # Add empty - add nothing to the last line block.add_text('') assert block.words == ['text', '-xx'] # Add multiple words. block.add_text('two words') assert block.words == ['text', '-xx', 'two', 'words'] # This adds empty word which will be skipped in further processing. block.add_text('\n') # assert block.words == ['text', '-xx', 'two', 'words', ''] assert block.words == ['text', '-xx', 'two', 'words'] # Add empty string to empyt block. block = WrapBlock() block.add_text('') assert block.words == []
def test_construct(self): b = WrapBlock() assert b.indent == 0 assert b.first_offset is None assert b.child_indent == 0 assert b.width is None assert b.top_margin == 0 assert b.bottom_margin == 0 assert b.words == [] assert b._box is None assert not b.is_box_started() assert list(b.get_lines()) == [] b = WrapBlock(1, 2, 3, 4, 5, 6) assert b.indent == 1 assert b.first_offset == 2 assert b.child_indent == 3 assert b.width == 3 assert b.top_margin == 5 assert b.bottom_margin == 6 assert b.words == [] assert b._box is None assert not b.is_box_started() assert b.is_empty()
def test_clear(self): block = WrapBlock(parent_width=20) block.add_text('This paragraph will result in an indented block of') block.start_box() block.add_text('sss') block.clear() assert block.words == [] assert block._box is None assert block.is_empty()