aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-01 13:56:31 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-01 13:56:31 +0000
commite1c20f1facebc5bf3e56f6aa6f2d1ac9ff8dc7d8 (patch)
tree16114ff0fb50875a9ac852e5355fabfae2236d61 /tests
parentb160de0cdd0ec662a64718ab796a51cd12924e13 (diff)
Emit warnings on unrecognised elements
Diffstat (limited to 'tests')
-rw-r--r--tests/docx/document_xml_tests.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/docx/document_xml_tests.py b/tests/docx/document_xml_tests.py
index 232bb34..e643efb 100644
--- a/tests/docx/document_xml_tests.py
+++ b/tests/docx/document_xml_tests.py
@@ -1,6 +1,6 @@
from nose.tools import istest, assert_equal
-from mammoth import documents
+from mammoth import documents, results
from mammoth.docx.xmlparser import element as xml_element, text as xml_text
from mammoth.docx.document_xml import read_document_xml_element
from mammoth.docx.numbering_xml import Numbering, NumberingLevel
@@ -117,9 +117,17 @@ class ReadXmlElementTests(object):
def ignored_elements_are_ignored_without_message(self):
element = xml_element("w:bookmarkStart")
result = read_document_xml_element(element)
+ assert_equal(None, result.value)
assert_equal([], result.messages)
@istest
+ def unrecognised_elements_emit_warning(self):
+ element = xml_element("w:huh", {}, [])
+ result = read_document_xml_element(element)
+ expected_warning = results.warning("An unrecognised element was ignored: w:huh")
+ assert_equal([expected_warning], result.messages)
+
+ @istest
def unrecognised_elements_are_ignored(self):
element = xml_element("w:huh", {}, [])
assert_equal(None, _read_and_get_document_xml_element(element))