|
15 | 15 | from docx.enum.text import WD_BREAK
|
16 | 16 | from docx.opc.coreprops import CoreProperties
|
17 | 17 | from docx.parts.document import DocumentPart, InlineShapes
|
| 18 | +from docx.section import Sections |
18 | 19 | from docx.shape import InlineShape
|
19 | 20 | from docx.table import Table
|
20 | 21 | from docx.text.paragraph import Paragraph
|
@@ -99,6 +100,12 @@ def it_provides_access_to_its_paragraphs(self, paragraphs_fixture):
|
99 | 100 | paragraphs = document.paragraphs
|
100 | 101 | assert paragraphs is paragraphs_
|
101 | 102 |
|
| 103 | + def it_provides_access_to_its_sections(self, sections_fixture): |
| 104 | + document, Sections_, sections_ = sections_fixture |
| 105 | + sections = document.sections |
| 106 | + Sections_.assert_called_once_with(document._element) |
| 107 | + assert sections is sections_ |
| 108 | + |
102 | 109 | def it_provides_access_to_the_document_part(self, part_fixture):
|
103 | 110 | document, part_ = part_fixture
|
104 | 111 | assert document.part is part_
|
@@ -212,6 +219,13 @@ def save_fixture(self, document_part_):
|
212 | 219 | file_ = 'foobar.docx'
|
213 | 220 | return document, file_
|
214 | 221 |
|
| 222 | + @pytest.fixture |
| 223 | + def sections_fixture(self, Sections_, sections_): |
| 224 | + document_elm = element('w:document') |
| 225 | + document = Document(document_elm, None) |
| 226 | + Sections_.return_value = sections_ |
| 227 | + return document, Sections_, sections_ |
| 228 | + |
215 | 229 | # fixture components ---------------------------------------------
|
216 | 230 |
|
217 | 231 | @pytest.fixture
|
@@ -262,6 +276,14 @@ def run_(self, request):
|
262 | 276 | def Section_(self, request):
|
263 | 277 | return class_mock(request, 'docx.document.Section')
|
264 | 278 |
|
| 279 | + @pytest.fixture |
| 280 | + def Sections_(self, request): |
| 281 | + return class_mock(request, 'docx.document.Sections') |
| 282 | + |
| 283 | + @pytest.fixture |
| 284 | + def sections_(self, request): |
| 285 | + return instance_mock(request, Sections) |
| 286 | + |
265 | 287 | @pytest.fixture
|
266 | 288 | def table_(self, request):
|
267 | 289 | return instance_mock(request, Table, style='UNASSIGNED')
|
0 commit comments