Skip to content

Commit e9e93a6

Browse files
author
Steve Canny
committed
oxml: convert CT_Document to xmlchemy
1 parent 3d8d6a6 commit e9e93a6

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

docx/oxml/parts/document.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
from ..ns import qn
99
from ..table import CT_Tbl
1010
from ..text import CT_P
11-
from ..xmlchemy import BaseOxmlElement
11+
from ..xmlchemy import BaseOxmlElement, ZeroOrOne
1212

1313

1414
class CT_Document(BaseOxmlElement):
1515
"""
1616
``<w:document>`` element, the root element of a document.xml file.
1717
"""
18-
@property
19-
def body(self):
20-
return self.find(qn('w:body'))
18+
body = ZeroOrOne('w:body')
2119

2220

2321
class CT_Body(BaseOxmlElement):

tests/oxml/parts/test_document.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
Test suite for the docx.oxml.parts module.
55
"""
66

7-
from docx.oxml.parts.document import CT_Body
87
from docx.oxml.text import CT_P
98

10-
from .unitdata.document import a_body, a_document
9+
from .unitdata.document import a_body
1110
from ..unitdata.text import a_p, a_sectPr
1211

1312

@@ -52,10 +51,3 @@ def it_can_clear_all_the_content_it_holds(self):
5251
body.clear_content()
5352
# verify -------------------
5453
assert body.xml == after_body_bldr.xml()
55-
56-
57-
class DescribeCT_Document(object):
58-
59-
def it_holds_a_body_element(self):
60-
document = a_document().with_nsdecls().with_child(a_body()).element
61-
assert isinstance(document.body, CT_Body)

0 commit comments

Comments
 (0)