Skip to content

Commit 60b38a8

Browse files
author
Steve Canny
committed
acpt: add scenarios for Font.size
1 parent 270271f commit 60b38a8

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

features/steps/text.py

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

3333

34+
@given('a font of size {size}')
35+
def given_a_font_of_size(context, size):
36+
document = Document(test_docx('txt-font-props'))
37+
style_name = {
38+
'unspecified': 'Normal',
39+
'14 pt': 'Having Typeface',
40+
'18 pt': 'Large Size',
41+
}[size]
42+
context.font = document.styles[style_name].font
43+
44+
3445
@given('a run')
3546
def given_a_run(context):
3647
document = Document()
@@ -165,6 +176,13 @@ def when_I_assign_value_to_font_name(context, value):
165176
font.name = value
166177

167178

179+
@when('I assign {value} to font.size')
180+
def when_I_assign_value_str_to_font_size(context, value):
181+
value = None if value == 'None' else int(value)
182+
font = context.font
183+
font.size = value
184+
185+
168186
@when('I assign {value_str} to its {bool_prop_name} property')
169187
def when_assign_true_to_bool_run_prop(context, value_str, bool_prop_name):
170188
value = {'True': True, 'False': False, 'None': None}[value_str]
@@ -204,6 +222,13 @@ def then_font_name_is_value(context, value):
204222
assert font.name == value
205223

206224

225+
@then('font.size is {value}')
226+
def then_font_size_is_value(context, value):
227+
value = None if value == 'None' else int(value)
228+
font = context.font
229+
assert font.size == value
230+
231+
207232
@then('it is a column break')
208233
def then_type_is_column_break(context):
209234
attrib = context.last_child.attrib

features/txt-font-props.feature

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,30 @@ Feature: Get or set font properties
2626
| Avenir Black | None |
2727

2828

29+
@wip
30+
Scenario Outline: Get font size
31+
Given a font of size <size>
32+
Then font.size is <value>
33+
34+
Examples: font.size values
35+
| size | value |
36+
| unspecified | None |
37+
| 14 pt | 177800 |
38+
39+
40+
@wip
41+
Scenario Outline: Set font size
42+
Given a font of size <size>
43+
When I assign <value> to font.size
44+
Then font.size is <value>
45+
46+
Examples: font.size post-assignment values
47+
| size | value |
48+
| unspecified | 177800 |
49+
| 14 pt | 228600 |
50+
| 18 pt | None |
51+
52+
2953
Scenario Outline: Apply boolean property to a run
3054
Given a run
3155
When I assign True to its <boolean_prop_name> property

0 commit comments

Comments
 (0)