|
12 | 12 |
|
13 | 13 | from docx.styles.latent import _LatentStyle, LatentStyles
|
14 | 14 |
|
15 |
| -from ..unitutil.cxml import element |
| 15 | +from ..unitutil.cxml import element, xml |
16 | 16 |
|
17 | 17 |
|
18 | 18 | class DescribeLatentStyles(object):
|
@@ -43,6 +43,11 @@ def it_knows_its_default_priority(self, priority_get_fixture):
|
43 | 43 | latent_styles, expected_value = priority_get_fixture
|
44 | 44 | assert latent_styles.default_priority == expected_value
|
45 | 45 |
|
| 46 | + def it_can_change_its_default_priority(self, priority_set_fixture): |
| 47 | + latent_styles, value, expected_xml = priority_set_fixture |
| 48 | + latent_styles.default_priority = value |
| 49 | + assert latent_styles._element.xml == expected_xml |
| 50 | + |
46 | 51 | def it_knows_its_load_count(self, count_get_fixture):
|
47 | 52 | latent_styles, expected_value = count_get_fixture
|
48 | 53 | assert latent_styles.load_count == expected_value
|
@@ -128,3 +133,17 @@ def priority_get_fixture(self, request):
|
128 | 133 | latentStyles_cxml, expected_value = request.param
|
129 | 134 | latent_styles = LatentStyles(element(latentStyles_cxml))
|
130 | 135 | return latent_styles, expected_value
|
| 136 | + |
| 137 | + @pytest.fixture(params=[ |
| 138 | + ('w:latentStyles', 42, |
| 139 | + 'w:latentStyles{w:defUIPriority=42}'), |
| 140 | + ('w:latentStyles{w:defUIPriority=24}', 42, |
| 141 | + 'w:latentStyles{w:defUIPriority=42}'), |
| 142 | + ('w:latentStyles{w:defUIPriority=24}', None, |
| 143 | + 'w:latentStyles'), |
| 144 | + ]) |
| 145 | + def priority_set_fixture(self, request): |
| 146 | + latentStyles_cxml, value, expected_cxml = request.param |
| 147 | + latent_styles = LatentStyles(element(latentStyles_cxml)) |
| 148 | + expected_xml = xml(expected_cxml) |
| 149 | + return latent_styles, value, expected_xml |
0 commit comments