Skip to content

Commit 91d48ae

Browse files
author
Steve Canny
committed
acpt: add scenarios for Font.sub/superscript
1 parent 208a9cf commit 91d48ae

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

features/steps/text.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ def given_a_font_having_type_underline(context, underline_type):
4343
context.font = document.styles[style_name].font
4444

4545

46+
@given('a font having {vertAlign_state} vertical alignment')
47+
def given_a_font_having_vertAlign_state(context, vertAlign_state):
48+
style_name = {
49+
'inherited': 'Normal',
50+
'subscript': 'Subscript',
51+
'superscript': 'Superscript',
52+
}[vertAlign_state]
53+
document = Document(test_docx('txt-font-props'))
54+
context.font = document.styles[style_name].font
55+
56+
4657
@given('a font of size {size}')
4758
def given_a_font_of_size(context, size):
4859
document = Document(test_docx('txt-font-props'))
@@ -208,6 +219,22 @@ def when_I_assign_value_to_font_underline(context, value_key):
208219
font.underline = value
209220

210221

222+
@when('I assign {value_key} to font.{sub_super}script')
223+
def when_I_assign_value_to_font_sub_super(context, value_key, sub_super):
224+
font = context.font
225+
name = {
226+
'sub': 'subscript',
227+
'super': 'superscript',
228+
}[sub_super]
229+
value = {
230+
'None': None,
231+
'True': True,
232+
'False': False,
233+
}[value_key]
234+
235+
setattr(font, name, value)
236+
237+
211238
@when('I assign {value_str} to its {bool_prop_name} property')
212239
def when_assign_true_to_bool_run_prop(context, value_str, bool_prop_name):
213240
value = {'True': True, 'False': False, 'None': None}[value_str]
@@ -266,6 +293,22 @@ def then_font_underline_is_value(context, value_key):
266293
assert font.underline == value
267294

268295

296+
@then('font.{sub_super}script is {value_key}')
297+
def then_font_sub_super_is_value(context, sub_super, value_key):
298+
name = {
299+
'sub': 'subscript',
300+
'super': 'superscript',
301+
}[sub_super]
302+
expected_value = {
303+
'None': None,
304+
'True': True,
305+
'False': False,
306+
}[value_key]
307+
font = context.font
308+
actual_value = getattr(font, name)
309+
assert actual_value == expected_value
310+
311+
269312
@then('it is a column break')
270313
def then_type_is_column_break(context):
271314
attrib = context.last_child.attrib

features/txt-font-props.feature

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,47 @@ Feature: Get or set font properties
7979
| single | WD_UNDERLINE.DOUBLE | WD_UNDERLINE.DOUBLE |
8080

8181

82+
@wip
83+
Scenario Outline: Get font sub/superscript value
84+
Given a font having <vertAlign-state> vertical alignment
85+
Then font.subscript is <sub-value>
86+
And font.superscript is <super-value>
87+
88+
Examples: font sub/superscript values
89+
| vertAlign-state | sub-value | super-value |
90+
| inherited | None | None |
91+
| subscript | True | False |
92+
| superscript | False | True |
93+
94+
95+
@wip
96+
Scenario Outline: Change font sub/superscript
97+
Given a font having <vertAlign-state> vertical alignment
98+
When I assign <value> to font.<name>script
99+
Then font.<name-2>script is <expected-value>
100+
101+
Examples: value of sub/superscript after assignment
102+
| vertAlign-state | name | value | name-2 | expected-value |
103+
| inherited | sub | True | sub | True |
104+
| inherited | sub | True | super | False |
105+
| inherited | sub | False | sub | None |
106+
| inherited | super | True | super | True |
107+
| inherited | super | True | sub | False |
108+
| inherited | super | False | super | None |
109+
| subscript | sub | True | sub | True |
110+
| subscript | sub | False | sub | None |
111+
| subscript | sub | None | sub | None |
112+
| subscript | super | True | sub | False |
113+
| subscript | super | False | sub | True |
114+
| subscript | super | None | sub | None |
115+
| superscript | super | True | super | True |
116+
| superscript | super | False | super | None |
117+
| superscript | super | None | super | None |
118+
| superscript | sub | True | super | False |
119+
| superscript | sub | False | super | True |
120+
| superscript | sub | None | super | None |
121+
122+
82123
Scenario Outline: Apply boolean property to a run
83124
Given a run
84125
When I assign True to its <boolean_prop_name> property

0 commit comments

Comments
 (0)