Skip to content

Commit f618212

Browse files
committed
Add tests for pickleability of StringList and Indent
1 parent bd560b4 commit f618212

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

domdf_python_tools/stringlist.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ def __eq__(self, other):
117117
class StringList(List[str]):
118118
"""
119119
A list of strings that represent lines in a multiline string.
120+
121+
:param iterable: Content to populate the StringList with.
122+
:param convert_indents: Whether indents at the start of lines should be converted.
120123
"""
121124

122125
#: The indent to insert at the beginning of new lines.

tests/test_stringlist.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# stdlib
2+
import pickle
23
from textwrap import dedent
34

45
# 3rd party
@@ -404,6 +405,11 @@ def test_str(self):
404405
sl = StringList(["", '', "hello", "world", '', '', '', "1234", ''])
405406
assert str(sl) == "\n\nhello\nworld\n\n\n\n1234\n"
406407

408+
@pytest.mark.xfail()
409+
def test_pickle(self):
410+
sl = StringList(["", '', "hello", "world", '', '', '', "1234"])
411+
assert sl == pickle.loads(pickle.dumps(sl))
412+
407413

408414
class TestIndent:
409415

@@ -485,3 +491,7 @@ def test_eq(self):
485491
assert Indent(2, "\t") == '\t\t'
486492

487493
assert not Indent() == 1
494+
495+
def test_pickle(self):
496+
indent = Indent(2, " ")
497+
assert indent == pickle.loads(pickle.dumps(indent))

0 commit comments

Comments
 (0)