append text test

This commit is contained in:
Will McGugan 2020-08-08 18:22:38 +01:00
parent 350cbbe6c8
commit 5a9f0dcc36
2 changed files with 9 additions and 1 deletions

View File

@ -778,7 +778,8 @@ class Text(JupyterMixin):
return self return self
def append_text(self, text: "Text") -> "Text": def append_text(self, text: "Text") -> "Text":
"""Append another Text instance. This method is more performant that Text.append. """Append another Text instance. This method is more performant that Text.append, but
only works for Text.
Returns: Returns:
Text: Returns self for chaining. Text: Returns self for chaining.

View File

@ -275,6 +275,13 @@ def test_append():
test.append(1) test.append(1)
def test_append_text():
test = Text("foo")
test.append_text(Text("bar", style="bold"))
assert str(test) == "foobar"
assert test._spans == [Span(3, 6, "bold")]
def test_split(): def test_split():
test = Text() test = Text()
test.append("foo", "red") test.append("foo", "red")