|
5 | 5 |
|
6 | 6 | from __future__ import annotations |
7 | 7 |
|
| 8 | +from typing import cast |
| 9 | + |
8 | 10 | import pytest |
9 | 11 |
|
10 | 12 | from docx.document import Document, _Body |
11 | 13 | from docx.enum.section import WD_SECTION |
12 | 14 | from docx.enum.text import WD_BREAK |
13 | 15 | from docx.opc.coreprops import CoreProperties |
| 16 | +from docx.oxml.document import CT_Document |
14 | 17 | from docx.parts.document import DocumentPart |
15 | 18 | from docx.section import Section, Sections |
16 | 19 | from docx.settings import Settings |
|
22 | 25 | from docx.text.run import Run |
23 | 26 |
|
24 | 27 | from .unitutil.cxml import element, xml |
25 | | -from .unitutil.mock import class_mock, instance_mock, method_mock, property_mock |
| 28 | +from .unitutil.mock import Mock, class_mock, instance_mock, method_mock, property_mock |
26 | 29 |
|
27 | 30 |
|
28 | 31 | class DescribeDocument: |
@@ -104,6 +107,16 @@ def it_provides_access_to_its_inline_shapes(self, inline_shapes_fixture): |
104 | 107 | document, inline_shapes_ = inline_shapes_fixture |
105 | 108 | assert document.inline_shapes is inline_shapes_ |
106 | 109 |
|
| 110 | + def it_can_iterate_the_inner_content_of_the_document( |
| 111 | + self, body_prop_: Mock, body_: Mock, document_part_: Mock |
| 112 | + ): |
| 113 | + document_elm = cast(CT_Document, element("w:document")) |
| 114 | + body_prop_.return_value = body_ |
| 115 | + body_.iter_inner_content.return_value = iter((1, 2, 3)) |
| 116 | + document = Document(document_elm, document_part_) |
| 117 | + |
| 118 | + assert list(document.iter_inner_content()) == [1, 2, 3] |
| 119 | + |
107 | 120 | def it_provides_access_to_its_paragraphs(self, paragraphs_fixture): |
108 | 121 | document, paragraphs_ = paragraphs_fixture |
109 | 122 | paragraphs = document.paragraphs |
|
0 commit comments