Skip to content

Commit 804aad1

Browse files
author
Steve Canny
committed
api: remove old Document.sections
1 parent 118c438 commit 804aad1

File tree

5 files changed

+3
-33
lines changed

5 files changed

+3
-33
lines changed

docx/api.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ def save(self, path_or_stream):
8989

9090
@property
9191
def sections(self):
92-
"""
93-
Return a reference to the |Sections| instance for this document.
94-
"""
95-
return self._document_part.sections
92+
return self._document.sections
9693

9794
@property
9895
def styles(self):

docx/parts/document.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from .numbering import NumberingPart
1414
from ..opc.constants import RELATIONSHIP_TYPE as RT
1515
from ..opc.part import XmlPart
16-
from ..section import Sections
1716
from ..shape import InlineShape
1817
from ..shared import lazyproperty, Parented
1918
from .styles import StylesPart
@@ -118,13 +117,6 @@ def save(self, path_or_stream):
118117
"""
119118
self.package.save(path_or_stream)
120119

121-
@lazyproperty
122-
def sections(self):
123-
"""
124-
The |Sections| instance organizing the sections in this document.
125-
"""
126-
return Sections(self._element)
127-
128120
@property
129121
def styles(self):
130122
"""

features/steps/document.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
from docx import Document
1212
from docx.enum.section import WD_ORIENT, WD_SECTION
13-
from docx.parts.document import InlineShapes, Sections
13+
from docx.parts.document import InlineShapes
1414
from docx.shared import Inches
15+
from docx.section import Sections
1516
from docx.table import Table
1617

1718
from helpers import test_docx, test_file

tests/parts/test_document.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ def it_has_a_body(self, body_fixture):
4545
_Body_.assert_called_once_with(body_elm, document_part)
4646
assert _body is _Body_.return_value
4747

48-
def it_provides_access_to_the_document_sections(self, sections_fixture):
49-
document, document_elm, Sections_ = sections_fixture
50-
sections = document.sections
51-
Sections_.assert_called_once_with(document_elm)
52-
assert sections is Sections_.return_value
53-
5448
def it_provides_access_to_the_document_tables(self, tables_fixture):
5549
document_part, tables_ = tables_fixture
5650
tables = document_part.tables
@@ -216,12 +210,6 @@ def save_fixture(self, package_):
216210
file_ = 'foobar.docx'
217211
return document_part, file_
218212

219-
@pytest.fixture
220-
def sections_fixture(self, Sections_):
221-
document_elm = a_document().with_nsdecls().element
222-
document = DocumentPart(None, None, document_elm, None)
223-
return document, document_elm, Sections_
224-
225213
@pytest.fixture
226214
def styles_fixture(self, _styles_part_prop_, styles_part_, styles_):
227215
document_part = DocumentPart(None, None, None, None)
@@ -329,10 +317,6 @@ def relate_to_(self, request, rId_):
329317
def rId_(self, request):
330318
return instance_mock(request, str)
331319

332-
@pytest.fixture
333-
def Sections_(self, request):
334-
return class_mock(request, 'docx.parts.document.Sections')
335-
336320
@pytest.fixture
337321
def style_(self, request):
338322
return instance_mock(request, BaseStyle)

tests/test_api.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ def Package_(self, request):
8484

8585
class DescribeDocumentOld(object):
8686

87-
def it_provides_access_to_the_document_sections(self, document):
88-
body = document.sections
89-
assert body is document._document_part.sections
90-
9187
def it_provides_access_to_the_document_tables(self, tables_fixture):
9288
document, tables_ = tables_fixture
9389
tables = document.tables

0 commit comments

Comments
 (0)