Skip to content

Commit f13be7b

Browse files
author
Steve Canny
committed
doc: add DocumentPart.paragraphs
1 parent ae1c8d1 commit f13be7b

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

docx/parts/document.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ def paragraphs(self):
9292
the document, in document order. Note that paragraphs within revision
9393
marks such as inserted or deleted do not appear in this list.
9494
"""
95-
# return self.body.paragraphs
96-
raise NotImplementedError
95+
return self.body.paragraphs
9796

9897
@property
9998
def part(self):

tests/parts/test_document.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ def it_can_serialize_to_xml(self, document_blob_fixture):
102102
serialize_part_xml_.assert_called_once_with(document_elm)
103103
assert blob is serialize_part_xml_.return_value
104104

105+
def it_provides_access_to_the_document_paragraphs(
106+
self, paragraphs_fixture):
107+
document_part, paragraphs_ = paragraphs_fixture
108+
paragraphs = document_part.paragraphs
109+
assert paragraphs is paragraphs_
110+
105111
def it_provides_access_to_the_inline_shapes_in_the_document(
106112
self, inline_shapes_fixture):
107113
document, InlineShapes_, body_elm = inline_shapes_fixture
@@ -244,6 +250,16 @@ def p_(self, request):
244250
def package_(self, request):
245251
return instance_mock(request, Package)
246252

253+
@pytest.fixture
254+
def paragraphs_(self, request):
255+
return instance_mock(request, list)
256+
257+
@pytest.fixture
258+
def paragraphs_fixture(self, document_part_body_, body_, paragraphs_):
259+
document_part = DocumentPart(None, None, None, None)
260+
body_.paragraphs = paragraphs_
261+
return document_part, paragraphs_
262+
247263
@pytest.fixture
248264
def part_load_fixture(
249265
self, document_part_load_, partname_, blob_, package_,

0 commit comments

Comments
 (0)