summaryrefslogtreecommitdiff
path: root/tests/test_document.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_document.py')
-rw-r--r--tests/test_document.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_document.py b/tests/test_document.py
index 0ddce94..4f0a911 100644
--- a/tests/test_document.py
+++ b/tests/test_document.py
@@ -192,3 +192,46 @@ class TestExtractPlaintext:
])
def test_with_node(self, node, plain):
assert document.extract_plaintext(node) == plain
+
+ def test_with_nodelist(self):
+ nodes = [
+ document.Plain("foo"),
+ document.Plain("bar "),
+ document.Style(document.Plain("qux"), False, True, True),
+ ]
+ expected = "foobar qux"
+ assert document.extract_plaintext(nodes) == expected
+
+ # Most of those just defer to Block.plain() which is tested above
+ @pytest.mark.parametrize("block, plain", [
+ (document.Paragraph([document.Plain("foo"), document.Plain("bar")]),
+ "foobar"),
+ (document.Verbatim("foo bar"), "foo bar"),
+ ])
+ def test_with_block(self, block, plain):
+ assert document.extract_plaintext(block) == plain
+
+ def test_with_blocklist(self):
+ blocks = [
+ document.Paragraph([document.Plain("foo")]),
+ document.Verbatim("bar"),
+ document.ItemList([
+ document.Paragraph([document.Plain("qux")]),
+ document.Paragraph([document.Plain("baz")]),
+ ], False),
+ ]
+ expected = "foo\n\nbar\n\nqux\nbaz"
+ assert document.extract_plaintext(blocks) == expected
+
+ def test_with_document(self):
+ blocks = [
+ document.Paragraph([document.Plain("foo")]),
+ document.Verbatim("bar"),
+ document.ItemList([
+ document.Paragraph([document.Plain("qux")]),
+ document.Paragraph([document.Plain("baz")]),
+ ], False),
+ ]
+ doc = document.Document(blocks)
+ expected = "foo\n\nbar\n\nqux\nbaz"
+ assert document.extract_plaintext(doc) == expected