Skip to content

Commit 75006eb

Browse files
author
Steve Canny
committed
style: add _LatentStyle.priority setter
1 parent 15c1cfe commit 75006eb

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

docx/styles/latent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,7 @@ def priority(self):
139139
The integer sort key for this latent style in the Word UI.
140140
"""
141141
return self._element.uiPriority
142+
143+
@priority.setter
144+
def priority(self, value):
145+
self._element.uiPriority = value

features/sty-latent-props.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Feature: Get and set latent style properties
4848
| 42 | 42 |
4949

5050

51-
@wip
5251
Scenario Outline: Set latent style display sort order
5352
Given a latent style having priority of <setting>
5453
When I assign <new-value> to latent_style.priority

tests/styles/test_latent.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ def it_knows_its_priority(self, priority_get_fixture):
2525
latent_style, expected_value = priority_get_fixture
2626
assert latent_style.priority == expected_value
2727

28+
def it_can_change_its_priority(self, priority_set_fixture):
29+
latent_style, new_value, expected_xml = priority_set_fixture
30+
latent_style.priority = new_value
31+
assert latent_style._element.xml == expected_xml
32+
2833
# fixtures -------------------------------------------------------
2934

3035
@pytest.fixture(params=[
@@ -44,6 +49,20 @@ def priority_get_fixture(self, request):
4449
latent_style = _LatentStyle(element(lsdException_cxml))
4550
return latent_style, expected_value
4651

52+
@pytest.fixture(params=[
53+
('w:lsdException', 42,
54+
'w:lsdException{w:uiPriority=42}'),
55+
('w:lsdException{w:uiPriority=42}', 24,
56+
'w:lsdException{w:uiPriority=24}'),
57+
('w:lsdException{w:uiPriority=24}', None,
58+
'w:lsdException'),
59+
])
60+
def priority_set_fixture(self, request):
61+
lsdException_cxml, new_value, expected_cxml = request.param
62+
latent_style = _LatentStyle(element(lsdException_cxml))
63+
expected_xml = xml(expected_cxml)
64+
return latent_style, new_value, expected_xml
65+
4766

4867
class DescribeLatentStyles(object):
4968

0 commit comments

Comments
 (0)