|
15 | 15 | from docx.package import Package |
16 | 16 | from docx.parts.styles import StylesPart, _Styles |
17 | 17 |
|
| 18 | +from ..oxml.unitdata.styles import a_style, a_styles |
18 | 19 | from ..unitutil import ( |
19 | 20 | function_mock, class_mock, initializer_mock, instance_mock, method_mock |
20 | 21 | ) |
@@ -130,3 +131,22 @@ def styles_part_(self, request): |
130 | 131 | @pytest.fixture |
131 | 132 | def styles_part_load_(self, request): |
132 | 133 | return method_mock(request, StylesPart, 'load') |
| 134 | + |
| 135 | + |
| 136 | +class Describe_Styles(object): |
| 137 | + |
| 138 | + def it_knows_how_many_styles_it_contains(self, len_fixture): |
| 139 | + styles, style_count = len_fixture |
| 140 | + assert len(styles) == style_count |
| 141 | + |
| 142 | + # fixtures ------------------------------------------------------- |
| 143 | + |
| 144 | + @pytest.fixture(params=[0, 1, 2, 3]) |
| 145 | + def len_fixture(self, request): |
| 146 | + style_count = request.param |
| 147 | + styles_bldr = a_styles().with_nsdecls() |
| 148 | + for idx in range(style_count): |
| 149 | + styles_bldr.with_child(a_style()) |
| 150 | + styles_elm = styles_bldr.element |
| 151 | + styles = _Styles(styles_elm) |
| 152 | + return styles, style_count |
0 commit comments