From 310a7650bbe2ebbb9f049684520a7539bbb55672 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 1 Dec 2013 01:09:07 +0000 Subject: Add tests for unrecognised elements --- tests/docx_tests.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'tests') 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) ) -- cgit v1.2.3