Skip to content

Commit 234cc0f

Browse files
author
Steve Canny
committed
acpt: add scenarios for Font.name
1 parent 1081cc2 commit 234cc0f

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed
37 KB
Binary file not shown.

features/steps/text.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121

2222
# given ===================================================
2323

24+
@given('a font having typeface name {name}')
25+
def given_a_font_having_typeface_name(context, name):
26+
document = Document(test_docx('txt-font-props'))
27+
style_name = {
28+
'not specified': 'Normal',
29+
'Avenir Black': 'Having Typeface',
30+
}[name]
31+
context.font = document.styles[style_name].font
32+
33+
2434
@given('a run')
2535
def given_a_run(context):
2636
document = Document()
@@ -148,6 +158,13 @@ def when_I_assign_mixed_text_to_the_text_property(context):
148158
context.run.text = 'abc\tdef\nghi\rjkl'
149159

150160

161+
@when('I assign {value} to font.name')
162+
def when_I_assign_value_to_font_name(context, value):
163+
font = context.font
164+
value = None if value == 'None' else value
165+
font.name = value
166+
167+
151168
@when('I assign {value_str} to its {bool_prop_name} property')
152169
def when_assign_true_to_bool_run_prop(context, value_str, bool_prop_name):
153170
value = {'True': True, 'False': False, 'None': None}[value_str]
@@ -180,6 +197,13 @@ def when_I_set_the_run_underline_to_value(context, underline_value):
180197

181198
# then =====================================================
182199

200+
@then('font.name is {value}')
201+
def then_font_name_is_value(context, value):
202+
font = context.font
203+
value = None if value == 'None' else value
204+
assert font.name == value
205+
206+
183207
@then('it is a column break')
184208
def then_type_is_column_break(context):
185209
attrib = context.last_child.attrib
Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
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
1+
Feature: Get or set font properties
2+
In order to customize the character formatting of text in a document
33
As a python-docx developer
4-
I need a way to query and set the boolean properties on a run
4+
I need a set of read/write properties on the Font object
5+
6+
7+
@wip
8+
Scenario Outline: Get typeface name
9+
Given a font having typeface name <name>
10+
Then font.name is <value>
11+
12+
Examples: font.name values
13+
| name | value |
14+
| not specified | None |
15+
| Avenir Black | Avenir Black |
16+
17+
18+
@wip
19+
Scenario Outline: Set typeface name
20+
Given a font having typeface name <name>
21+
When I assign <value> to font.name
22+
Then font.name is <value>
23+
24+
Examples: font.name values
25+
| name | value |
26+
| not specified | Avenir Black |
27+
| Avenir Black | Calibri |
28+
| Avenir Black | None |
29+
530

631
Scenario Outline: Apply boolean property to a run
732
Given a run
@@ -31,6 +56,7 @@ Feature: Query or apply boolean property to a run
3156
| strike |
3257
| web_hidden |
3358

59+
3460
Scenario Outline: Set <boolean_prop_name> off unconditionally
3561
Given a run
3662
When I assign False to its <boolean_prop_name> property
@@ -59,6 +85,7 @@ Feature: Query or apply boolean property to a run
5985
| strike |
6086
| web_hidden |
6187

88+
6289
Scenario Outline: Remove boolean property from a run
6390
Given a run having <boolean_prop_name> set on
6491
When I assign None to its <boolean_prop_name> property

0 commit comments

Comments
 (0)