aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mammoth/docx/numbering_xml.py2
-rw-r--r--tests/docx/numbering_xml_tests.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/mammoth/docx/numbering_xml.py b/mammoth/docx/numbering_xml.py
index ebac1c8..f7f98e0 100644
--- a/mammoth/docx/numbering_xml.py
+++ b/mammoth/docx/numbering_xml.py
@@ -56,4 +56,4 @@ class Numbering(object):
if num is None:
return None
else:
- return num[level]
+ return num.get(level)
diff --git a/tests/docx/numbering_xml_tests.py b/tests/docx/numbering_xml_tests.py
index 6f4e9ac..8fb59ff 100644
--- a/tests/docx/numbering_xml_tests.py
+++ b/tests/docx/numbering_xml_tests.py
@@ -41,3 +41,9 @@ def list_is_not_ordered_if_formatted_as_bullet():
def list_is_ordered_if_formatted_as_decimal():
numbering = read_numbering_xml_element(_sample_numbering_xml)
assert_equal(True, numbering.find_level("47", "1").is_ordered)
+
+
+@istest
+def find_level_returns_none_if_level_cannot_be_found():
+ numbering = read_numbering_xml_element(_sample_numbering_xml)
+ assert_equal(None, numbering.find_level("47", "2"))