|
15 | 15 | from docx.package import ImageParts, Package |
16 | 16 | from docx.parts.document import _Body, DocumentPart, InlineShapes, Sections |
17 | 17 | from docx.parts.image import ImagePart |
| 18 | +from docx.parts.styles import StylesPart |
18 | 19 | from docx.section import Section |
19 | 20 | from docx.shape import InlineShape |
| 21 | +from docx.styles.styles import Styles |
20 | 22 | from docx.table import Table |
21 | 23 | from docx.text.paragraph import Paragraph |
22 | 24 | from docx.text.run import Run |
@@ -54,6 +56,11 @@ def it_provides_access_to_the_document_tables(self, tables_fixture): |
54 | 56 | tables = document_part.tables |
55 | 57 | assert tables is tables_ |
56 | 58 |
|
| 59 | + def it_provides_access_to_the_document_styles(self, styles_fixture): |
| 60 | + document_part, styles_ = styles_fixture |
| 61 | + styles = document_part.styles |
| 62 | + assert styles is styles_ |
| 63 | + |
57 | 64 | def it_provides_access_to_the_inline_shapes_in_the_document( |
58 | 65 | self, inline_shapes_fixture): |
59 | 66 | document, InlineShapes_, body_elm = inline_shapes_fixture |
@@ -162,11 +169,18 @@ def paragraphs_fixture(self, document_part_body_, body_, paragraphs_): |
162 | 169 | return document_part, paragraphs_ |
163 | 170 |
|
164 | 171 | @pytest.fixture |
165 | | - def sections_fixture(self, request, Sections_): |
| 172 | + def sections_fixture(self, Sections_): |
166 | 173 | document_elm = a_document().with_nsdecls().element |
167 | 174 | document = DocumentPart(None, None, document_elm, None) |
168 | 175 | return document, document_elm, Sections_ |
169 | 176 |
|
| 177 | + @pytest.fixture |
| 178 | + def styles_fixture(self, _styles_part_prop_, styles_part_, styles_): |
| 179 | + document_part = DocumentPart(None, None, None, None) |
| 180 | + _styles_part_prop_.return_value = styles_part_ |
| 181 | + styles_part_.styles = styles_ |
| 182 | + return document_part, styles_ |
| 183 | + |
170 | 184 | @pytest.fixture |
171 | 185 | def tables_fixture(self, document_part_body_, body_, tables_): |
172 | 186 | document_part = DocumentPart(None, None, None, None) |
@@ -275,6 +289,18 @@ def sectPr_(self, request): |
275 | 289 | def start_type_(self, request): |
276 | 290 | return instance_mock(request, int) |
277 | 291 |
|
| 292 | + @pytest.fixture |
| 293 | + def styles_(self, request): |
| 294 | + return instance_mock(request, Styles) |
| 295 | + |
| 296 | + @pytest.fixture |
| 297 | + def styles_part_(self, request): |
| 298 | + return instance_mock(request, StylesPart) |
| 299 | + |
| 300 | + @pytest.fixture |
| 301 | + def _styles_part_prop_(self, request): |
| 302 | + return property_mock(request, DocumentPart, '_styles_part') |
| 303 | + |
278 | 304 | @pytest.fixture |
279 | 305 | def table_(self, request): |
280 | 306 | return instance_mock(request, Table) |
|
0 commit comments