Skip to content

Commit 6a449d5

Browse files
author
Steve Canny
committed
style: add LatentStyles.load_count setter
1 parent 9121e10 commit 6a449d5

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

docx/styles/latent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ def load_count(self):
9595
"""
9696
return self._element.count
9797

98+
@load_count.setter
99+
def load_count(self, value):
100+
self._element.count = value
101+
98102

99103
class _LatentStyle(ElementProxy):
100104
"""

tests/styles/test_latent.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def it_knows_its_load_count(self, count_get_fixture):
5252
latent_styles, expected_value = count_get_fixture
5353
assert latent_styles.load_count == expected_value
5454

55+
def it_can_change_its_load_count(self, count_set_fixture):
56+
latent_styles, value, expected_xml = count_set_fixture
57+
latent_styles.load_count = value
58+
assert latent_styles._element.xml == expected_xml
59+
5560
def it_knows_its_boolean_properties(self, bool_prop_get_fixture):
5661
latent_styles, prop_name, expected_value = bool_prop_get_fixture
5762
actual_value = getattr(latent_styles, prop_name)
@@ -87,6 +92,17 @@ def count_get_fixture(self, request):
8792
latent_styles = LatentStyles(element(latentStyles_cxml))
8893
return latent_styles, expected_value
8994

95+
@pytest.fixture(params=[
96+
('w:latentStyles', 42, 'w:latentStyles{w:count=42}'),
97+
('w:latentStyles{w:count=24}', 42, 'w:latentStyles{w:count=42}'),
98+
('w:latentStyles{w:count=24}', None, 'w:latentStyles'),
99+
])
100+
def count_set_fixture(self, request):
101+
latentStyles_cxml, value, expected_cxml = request.param
102+
latent_styles = LatentStyles(element(latentStyles_cxml))
103+
expected_xml = xml(expected_cxml)
104+
return latent_styles, value, expected_xml
105+
90106
@pytest.fixture(params=[
91107
('w:lsdException{w:name=Ab},w:lsdException,w:lsdException', 'Ab', 0),
92108
('w:lsdException,w:lsdException{w:name=Cd},w:lsdException', 'Cd', 1),

0 commit comments

Comments
 (0)