Skip to content

Commit a788802

Browse files
author
Steve Canny
committed
acpt: add run-bool-props.feature
1 parent 8837a45 commit a788802

3 files changed

Lines changed: 106 additions & 81 deletions

File tree

features/run-bold-italic.feature

Lines changed: 0 additions & 34 deletions
This file was deleted.

features/run-bool-props.feature

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
Feature: Query or apply boolean property to a run
2+
In order to query or change a boolean display property of a word or phrase
3+
As a python-docx developer
4+
I need a way to query and set the boolean properties on a run
5+
6+
@wip
7+
Scenario Outline: Apply boolean property to a run
8+
Given a run
9+
When I assign True to its <boolean_prop_name> property
10+
Then the run appears in <boolean_prop_name> unconditionally
11+
12+
Examples: Boolean run properties
13+
| boolean_prop_name |
14+
| all_caps |
15+
| bold |
16+
| complex_script |
17+
| cs_bold |
18+
| cs_italic |
19+
| double_strike |
20+
| emboss |
21+
| hidden |
22+
| italic |
23+
| imprint |
24+
| math |
25+
| no_proof |
26+
| outline |
27+
| rtl |
28+
| shadow |
29+
| small_caps |
30+
| snap_to_grid |
31+
| spec_vanish |
32+
| strike |
33+
| web_hidden |
34+
35+
@wip
36+
Scenario Outline: Set <boolean_prop_name> off unconditionally
37+
Given a run
38+
When I assign False to its <boolean_prop_name> property
39+
Then the run appears without <boolean_prop_name> unconditionally
40+
41+
Examples: Boolean run properties
42+
| boolean_prop_name |
43+
| all_caps |
44+
| bold |
45+
| complex_script |
46+
| cs_bold |
47+
| cs_italic |
48+
| double_strike |
49+
| emboss |
50+
| hidden |
51+
| italic |
52+
| imprint |
53+
| math |
54+
| no_proof |
55+
| outline |
56+
| rtl |
57+
| shadow |
58+
| small_caps |
59+
| snap_to_grid |
60+
| spec_vanish |
61+
| strike |
62+
| web_hidden |
63+
64+
@wip
65+
Scenario Outline: Remove boolean property from a run
66+
Given a run having <boolean_prop_name> set on
67+
When I assign None to its <boolean_prop_name> property
68+
Then the run appears with its inherited <boolean_prop_name> setting
69+
70+
Examples: Boolean run properties
71+
| boolean_prop_name |
72+
| all_caps |
73+
| bold |
74+
| complex_script |
75+
| cs_bold |
76+
| cs_italic |
77+
| double_strike |
78+
| emboss |
79+
| hidden |
80+
| italic |
81+
| imprint |
82+
| math |
83+
| no_proof |
84+
| outline |
85+
| rtl |
86+
| shadow |
87+
| small_caps |
88+
| snap_to_grid |
89+
| spec_vanish |
90+
| strike |
91+
| web_hidden |

features/steps/text.py

Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,10 @@ def given_a_run(context):
2121
context.run = p.add_run()
2222

2323

24-
@given('a run having bold set on')
25-
def given_a_run_having_bold_set_on(context):
24+
@given('a run having {bool_prop_name} set on')
25+
def given_a_run_having_bool_prop_set_on(context, bool_prop_name):
2626
run = Document().add_paragraph().add_run()
27-
run.bold = True
28-
context.run = run
29-
30-
31-
@given('a run having italic set on')
32-
def given_a_run_having_italic_set_on(context):
33-
run = Document().add_paragraph().add_run()
34-
run.italic = True
27+
setattr(run, bool_prop_name, True)
3528
context.run = run
3629

3730

@@ -55,18 +48,11 @@ def when_add_page_break(context):
5548
run.add_break(WD_BREAK.PAGE)
5649

5750

58-
@when('I assign {value_str} to its bold property')
59-
def when_assign_true_to_its_bold_property(context, value_str):
51+
@when('I assign {value_str} to its {bool_prop_name} property')
52+
def when_assign_true_to_bool_run_prop(context, value_str, bool_prop_name):
6053
value = {'True': True, 'False': False, 'None': None}[value_str]
6154
run = context.run
62-
run.bold = value
63-
64-
65-
@when('I assign {value_str} to its italic property')
66-
def when_assign_true_to_its_italic_property(context, value_str):
67-
value = {'True': True, 'False': False, 'None': None}[value_str]
68-
run = context.run
69-
run.italic = value
55+
setattr(run, bool_prop_name, value)
7056

7157

7258
# then =====================================================
@@ -99,37 +85,19 @@ def then_last_item_in_run_is_a_break(context):
9985
assert context.last_child.tag == expected_tag
10086

10187

102-
@then('the run appears in bold typeface')
103-
def then_run_appears_in_bold_typeface(context):
104-
run = context.run
105-
assert run.bold is True
106-
107-
108-
@then('the run appears in italic typeface')
109-
def then_run_appears_in_italic_typeface(context):
110-
run = context.run
111-
assert run.italic is True
112-
113-
114-
@then('the run appears with its inherited bold setting')
115-
def then_run_appears_with_its_inherited_bold_setting(context):
116-
run = context.run
117-
assert run.bold is None
118-
119-
120-
@then('the run appears with its inherited italic setting')
121-
def then_run_appears_with_its_inherited_italic_setting(context):
88+
@then('the run appears in {boolean_prop_name} unconditionally')
89+
def then_run_appears_in_boolean_prop_name(context, boolean_prop_name):
12290
run = context.run
123-
assert run.italic is None
91+
assert getattr(run, boolean_prop_name) is True
12492

12593

126-
@then('the run appears without bold regardless of its style hierarchy')
127-
def then_run_appears_without_bold_regardless(context):
94+
@then('the run appears with its inherited {boolean_prop_name} setting')
95+
def then_run_inherits_bool_prop_value(context, boolean_prop_name):
12896
run = context.run
129-
assert run.bold is False
97+
assert getattr(run, boolean_prop_name) is None
13098

13199

132-
@then('the run appears without italic regardless of its style hierarchy')
133-
def then_run_appears_without_italic_regardless(context):
100+
@then('the run appears without {boolean_prop_name} unconditionally')
101+
def then_run_appears_without_bool_prop(context, boolean_prop_name):
134102
run = context.run
135-
assert run.italic is False
103+
assert getattr(run, boolean_prop_name) is False

0 commit comments

Comments
 (0)