summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-01 01:09:07 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-01 01:09:07 +0000
commit310a7650bbe2ebbb9f049684520a7539bbb55672 (patch)
tree65f919e97a9758e0dd11f5270f8b53abe5f9eb17
parentf9148d6f5dcf1e8188411c800daeb0ab493be19b (diff)
Add tests for unrecognised elements
-rw-r--r--tests/docx_tests.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/docx_tests.py b/tests/docx_tests.py
index 55a2222..d5f4990 100644
--- a/tests/docx_tests.py
+++ b/tests/docx_tests.py
@@ -44,18 +44,23 @@ class ReadXmlElementTests(object):
)
@istest
- def can_read_text_within_paragraph(self):
- element = _paragraph_element_with_text("Hello!")
+ def can_read_text_within_document(self):
+ element = _document_element_with_text("Hello!")
assert_equal(
- documents.Paragraph([documents.Run([documents.Text("Hello!")])]),
+ documents.Document([documents.Paragraph([documents.Run([documents.Text("Hello!")])])]),
docx.read_xml_element(element)
)
@istest
- def can_read_text_within_document(self):
- element = _document_element_with_text("Hello!")
+ def unrecognised_elements_are_ignored(self):
+ element = xml_element("w:huh", {}, [])
+ assert_equal(None, docx.read_xml_element(element))
+
+ @istest
+ def unrecognised_children_are_ignored(self):
+ element = xml_element("w:r", {}, [_text_element("Hello!"), xml_element("w:huh", {}, [])])
assert_equal(
- documents.Document([documents.Paragraph([documents.Run([documents.Text("Hello!")])])]),
+ documents.Run([documents.Text("Hello!")]),
docx.read_xml_element(element)
)