Skip to content

Commit 7505083

Browse files
author
Steve Canny
committed
oxml: add CT_P.r_elms
1 parent dc8295b commit 7505083

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

docx/oxml/text.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ def new():
3636
p = oxml_fromstring(xml)
3737
return p
3838

39+
@property
40+
def r_elms(self):
41+
"""
42+
Sequence containing a reference to each run element in this paragraph.
43+
"""
44+
if not hasattr(self, 'r'):
45+
return ()
46+
return tuple([r for r in self.r])
47+
3948

4049
class CT_R(OxmlBaseElement):
4150
"""

tests/oxml/test_text.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ def it_can_construct_a_new_p_element(self):
2121
expected_xml = a_p().with_nsdecls().xml
2222
assert p.xml == expected_xml
2323

24+
def it_has_a_sequence_of_the_runs_it_contains(self):
25+
p = a_p().with_nsdecls().with_r(3).element
26+
assert len(p.r_elms) == 3
27+
for r in p.r_elms:
28+
assert isinstance(r, CT_R)
29+
2430
def it_can_add_an_r_to_itself(self):
2531
p = a_p().with_nsdecls().element
2632
# exercise -----------------

0 commit comments

Comments
 (0)