diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-12-01 01:09:07 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-12-01 01:09:07 +0000 |
| commit | 310a7650bbe2ebbb9f049684520a7539bbb55672 (patch) | |
| tree | 65f919e97a9758e0dd11f5270f8b53abe5f9eb17 | |
| parent | f9148d6f5dcf1e8188411c800daeb0ab493be19b (diff) | |
Add tests for unrecognised elements
| -rw-r--r-- | tests/docx_tests.py | 17 |
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) ) |
