Skip to content

Commit 2fdb937

Browse files
author
Steve Canny
committed
acpt: add scenarios for ParaFormat On/Off props
1 parent 4863ac9 commit 2fdb937

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
-9.29 KB
Binary file not shown.

features/steps/text.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ def given_a_font_of_size(context, size):
6868
context.font = document.styles[style_name].font
6969

7070

71+
@given('a paragraph format having {prop_name} set {setting}')
72+
def given_a_paragraph_format_having_prop_set(context, prop_name, setting):
73+
style_name = {
74+
'to inherit': 'Normal',
75+
'On': 'Base',
76+
'Off': 'Citation',
77+
}[setting]
78+
document = Document(test_docx('sty-known-styles'))
79+
context.paragraph_format = document.styles[style_name].paragraph_format
80+
81+
7182
@given('a paragraph format having {setting} line spacing')
7283
def given_a_paragraph_format_having_setting_line_spacing(context, setting):
7384
style_name = {
@@ -336,6 +347,13 @@ def when_I_assign_value_to_paragraph_format_indent(context, value, type_):
336347
setattr(paragraph_format, prop_name, value)
337348

338349

350+
@when('I assign {value} to paragraph_format.{prop_name}')
351+
def when_I_assign_value_to_paragraph_format_prop(context, value, prop_name):
352+
paragraph_format = context.paragraph_format
353+
value = {'None': None, 'True': True, 'False': False}[value]
354+
setattr(paragraph_format, prop_name, value)
355+
356+
339357
@when('I assign {value_str} to its {bool_prop_name} property')
340358
def when_assign_true_to_bool_run_prop(context, value_str, bool_prop_name):
341359
value = {'True': True, 'False': False, 'None': None}[value_str]
@@ -488,6 +506,14 @@ def then_paragraph_format_type_indent_is_value(context, type_, value):
488506
assert actual_value == expected_value
489507

490508

509+
@then('paragraph_format.{prop_name} is {value}')
510+
def then_paragraph_format_prop_name_is_value(context, prop_name, value):
511+
expected_value = {'None': None, 'True': True, 'False': False}[value]
512+
paragraph_format = context.paragraph_format
513+
actual_value = getattr(paragraph_format, prop_name)
514+
assert actual_value == expected_value
515+
516+
491517
@then('run.font is the Font object for the run')
492518
def then_run_font_is_the_Font_object_for_the_run(context):
493519
run, font = context.run, context.run.font

features/txt-parfmt-props.feature

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,46 @@ Feature: Get or set paragraph formatting properties
126126
| right | inherit | 24 pt | 304800 |
127127
| right | 17.3 pt | -6 pt | -76200 |
128128
| right | 17.3 pt | None | None |
129+
130+
131+
@wip
132+
Scenario Outline: Get On/Off paragraph property
133+
Given a paragraph format having <prop-name> set <state>
134+
Then paragraph_format.<prop-name> is <value>
135+
136+
Examples: ParagraphFormat On/Off property values
137+
| prop-name | state | value |
138+
| keep_together | to inherit | None |
139+
| keep_together | On | True |
140+
| keep_together | Off | False |
141+
| keep_with_next | to inherit | None |
142+
| keep_with_next | On | True |
143+
| keep_with_next | Off | False |
144+
| page_break_before | to inherit | None |
145+
| page_break_before | On | True |
146+
| page_break_before | Off | False |
147+
| widow_control | to inherit | None |
148+
| widow_control | On | True |
149+
| widow_control | Off | False |
150+
151+
152+
@wip
153+
Scenario Outline: Set On/Off paragraph property
154+
Given a paragraph format having <prop-name> set <state>
155+
When I assign <new-value> to paragraph_format.<prop-name>
156+
Then paragraph_format.<prop-name> is <value>
157+
158+
Examples: ParagraphFormat On/Off property values
159+
| prop-name | state | new-value | value |
160+
| keep_together | to inherit | True | True |
161+
| keep_together | On | False | False |
162+
| keep_together | Off | None | None |
163+
| keep_with_next | to inherit | False | False |
164+
| keep_with_next | Off | True | True |
165+
| keep_with_next | On | None | None |
166+
| page_break_before | to inherit | True | True |
167+
| page_break_before | On | False | False |
168+
| page_break_before | Off | None | None |
169+
| widow_control | to inherit | False | False |
170+
| widow_control | Off | True | True |
171+
| widow_control | On | None | None |

0 commit comments

Comments
 (0)