Skip to content

Commit 271c00c

Browse files
author
Steve Canny
committed
acpt: add scenarios for Font.underline
1 parent a8237a0 commit 271c00c

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

features/steps/text.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ def given_a_font_having_typeface_name(context, name):
3131
context.font = document.styles[style_name].font
3232

3333

34+
@given('a font having {underline_type} underline')
35+
def given_a_font_having_type_underline(context, underline_type):
36+
style_name = {
37+
'inherited': 'Normal',
38+
'no': 'None Underlined',
39+
'single': 'Underlined',
40+
'double': 'Double Underlined',
41+
}[underline_type]
42+
document = Document(test_docx('txt-font-props'))
43+
context.font = document.styles[style_name].font
44+
45+
3446
@given('a font of size {size}')
3547
def given_a_font_of_size(context, size):
3648
document = Document(test_docx('txt-font-props'))
@@ -183,6 +195,19 @@ def when_I_assign_value_str_to_font_size(context, value):
183195
font.size = value
184196

185197

198+
@when('I assign {value_key} to font.underline')
199+
def when_I_assign_value_to_font_underline(context, value_key):
200+
value = {
201+
'True': True,
202+
'False': False,
203+
'None': None,
204+
'WD_UNDERLINE.SINGLE': WD_UNDERLINE.SINGLE,
205+
'WD_UNDERLINE.DOUBLE': WD_UNDERLINE.DOUBLE,
206+
}[value_key]
207+
font = context.font
208+
font.underline = value
209+
210+
186211
@when('I assign {value_str} to its {bool_prop_name} property')
187212
def when_assign_true_to_bool_run_prop(context, value_str, bool_prop_name):
188213
value = {'True': True, 'False': False, 'None': None}[value_str]
@@ -229,6 +254,18 @@ def then_font_size_is_value(context, value):
229254
assert font.size == value
230255

231256

257+
@then('font.underline is {value_key}')
258+
def then_font_underline_is_value(context, value_key):
259+
value = {
260+
'None': None,
261+
'True': True,
262+
'False': False,
263+
'WD_UNDERLINE.DOUBLE': WD_UNDERLINE.DOUBLE,
264+
}[value_key]
265+
font = context.font
266+
assert font.underline == value
267+
268+
232269
@then('it is a column break')
233270
def then_type_is_column_break(context):
234271
attrib = context.last_child.attrib

features/txt-font-props.feature

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,39 @@ Feature: Get or set font properties
4848
| 18 pt | None |
4949

5050

51+
@wip
52+
Scenario Outline: Get font underline value
53+
Given a font having <underline-type> underline
54+
Then font.underline is <value>
55+
56+
Examples: font underline values
57+
| underline-type | value |
58+
| inherited | None |
59+
| no | False |
60+
| single | True |
61+
| double | WD_UNDERLINE.DOUBLE |
62+
63+
64+
@wip
65+
Scenario Outline: Change font underline
66+
Given a font having <underline-type> underline
67+
When I assign <new-value> to font.underline
68+
Then font.underline is <expected-value>
69+
70+
Examples: underline property values
71+
| underline-type | new-value | expected-value |
72+
| inherited | True | True |
73+
| inherited | False | False |
74+
| inherited | None | None |
75+
| inherited | WD_UNDERLINE.SINGLE | True |
76+
| inherited | WD_UNDERLINE.DOUBLE | WD_UNDERLINE.DOUBLE |
77+
| single | None | None |
78+
| single | True | True |
79+
| single | False | False |
80+
| single | WD_UNDERLINE.SINGLE | True |
81+
| single | WD_UNDERLINE.DOUBLE | WD_UNDERLINE.DOUBLE |
82+
83+
5184
Scenario Outline: Apply boolean property to a run
5285
Given a run
5386
When I assign True to its <boolean_prop_name> property

0 commit comments

Comments
 (0)