diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-12-01 13:34:41 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-12-01 13:34:41 +0000 |
| commit | bc62c8382815d5ca3b0812247cbc46ba8430ebab (patch) | |
| tree | 7cd1216dad37b160e2a05c2bdfb251e4e6d6ab9a /tests/docx/document_xml_tests.py | |
| parent | ff8b54b819c08e97cc35dc123fdb4b64969d4ef6 (diff) | |
Read bold property of runs
Diffstat (limited to 'tests/docx/document_xml_tests.py')
| -rw-r--r-- | tests/docx/document_xml_tests.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/docx/document_xml_tests.py b/tests/docx/document_xml_tests.py index d2ec1ee..4722a4c 100644 --- a/tests/docx/document_xml_tests.py +++ b/tests/docx/document_xml_tests.py @@ -78,11 +78,24 @@ class ReadXmlElementTests(object): @istest def run_has_style_name_read_from_run_properties_if_present(self): style_xml = xml_element("w:rStyle", {"w:val": "Emphasis"}) - properties_xml = xml_element("w:rPr", {}, [style_xml]) - run_xml = xml_element("w:r", {}, [properties_xml]) - run = read_document_xml_element(run_xml) + run = self._read_run_with_properties([style_xml]) assert_equal("Emphasis", run.style_name) + @istest + def run_is_not_bold_if_bold_element_is_not_present(self): + run = self._read_run_with_properties([]) + assert_equal(False, run.is_bold) + + @istest + def run_is_bold_if_bold_element_is_present(self): + run = self._read_run_with_properties([xml_element("w:b")]) + assert_equal(True, run.is_bold) + + def _read_run_with_properties(self, properties): + properties_xml = xml_element("w:rPr", {}, properties) + run_xml = xml_element("w:r", {}, [properties_xml]) + return read_document_xml_element(run_xml) + @istest def unrecognised_elements_are_ignored(self): |
