Skip to content

Commit

Permalink
Increase test coverage in stringlist module.
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Dec 11, 2023
1 parent 4f8c306 commit 185f1c0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/test_stringlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def test_setitem(self):
sl[3:4] = "\nfoo\nbar\n", "baz"
assert sl == ["foo", "bar", '', '', "foo", "bar", '', "baz", '', "world", '', '', '', "1234"]

sl[3:5] = iter(["foo", "bar", "baz"])
assert sl == ["foo", "bar", '', "foo", "bar", "baz", '', "baz", '', "world", '', '', '', "1234"]

def test_blankline(self):
sl = StringList(['', '', "hello", "world", '', '', '', "1234"])

Expand Down Expand Up @@ -563,8 +566,15 @@ def test_joinlines(string, lines):


@no_type_check
def test_textwrap_indent():
def test_stringlist_textwrap_indent():
sl = StringList(['', '', "hello", "world", '', '', '', "1234"])
assert textwrap.indent(sl, " ") == "\n\n hello\n world\n\n\n\n 1234\n"
assert textwrap.indent(sl, '\t') == "\n\n\thello\n\tworld\n\n\n\n\t1234\n"
assert textwrap.indent(sl, ">>> ") == "\n\n>>> hello\n>>> world\n\n\n\n>>> 1234\n"


def test_stringlist_splitlines():
sl = StringList(['', '', "hello", "world", '', '', '', "1234"])
assert sl.splitlines() is sl
assert list(sl.splitlines()) == ['', '', "hello", "world", '', '', '', "1234"]
assert sl.splitlines(keepends=True) == ['\n', '\n', "hello\n", "world\n", '\n', '\n', '\n', "1234\n"]

0 comments on commit 185f1c0

Please sign in to comment.