Skip to content

Commit 0f58ff4

Browse files
author
Steve Canny
committed
acpt: add scenarios for ParagraphFormat indents
1 parent 6f5ed6d commit 0f58ff4

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

features/steps/text.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ def given_a_paragraph_format_having_align_type_alignment(context, type):
9797
context.paragraph_format = document.styles[style_name].paragraph_format
9898

9999

100+
@given('a paragraph format having {type} indent of {value}')
101+
def given_a_paragraph_format_having_type_indent_value(context, type, value):
102+
style_name = {
103+
'inherit': 'Normal',
104+
'18 pt': 'Base',
105+
'17.3 pt': 'Base',
106+
'-17.3 pt': 'Citation',
107+
'46.1 pt': 'Citation',
108+
}[value]
109+
document = Document(test_docx('sty-known-styles'))
110+
context.paragraph_format = document.styles[style_name].paragraph_format
111+
112+
100113
@given('a run')
101114
def given_a_run(context):
102115
document = Document()
@@ -315,6 +328,14 @@ def when_I_assign_value_to_paragraph_format_space(context, value_key, side):
315328
setattr(paragraph_format, prop_name, value)
316329

317330

331+
@when('I assign {value} to paragraph_format.{type_}_indent')
332+
def when_I_assign_value_to_paragraph_format_indent(context, value, type_):
333+
paragraph_format = context.paragraph_format
334+
prop_name = '%s_indent' % type_
335+
value = None if value == 'None' else Pt(float(value.split()[0]))
336+
setattr(paragraph_format, prop_name, value)
337+
338+
318339
@when('I assign {value_str} to its {bool_prop_name} property')
319340
def when_assign_true_to_bool_run_prop(context, value_str, bool_prop_name):
320341
value = {'True': True, 'False': False, 'None': None}[value_str]
@@ -458,6 +479,15 @@ def then_paragraph_format_space_side_is_value(context, side, value):
458479
assert actual_value == expected_value
459480

460481

482+
@then('paragraph_format.{type_}_indent is {value}')
483+
def then_paragraph_format_type_indent_is_value(context, type_, value):
484+
expected_value = None if value == 'None' else int(value)
485+
prop_name = '%s_indent' % type_
486+
paragraph_format = context.paragraph_format
487+
actual_value = getattr(paragraph_format, prop_name)
488+
assert actual_value == expected_value
489+
490+
461491
@then('run.font is the Font object for the run')
462492
def then_run_font_is_the_Font_object_for_the_run(context):
463493
run, font = context.run, context.run.font

features/txt-parfmt-props.feature

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,38 @@ Feature: Get or set paragraph formatting properties
9393
| double | WD_LINE_SPACING.SINGLE | 1.0 | WD_LINE_SPACING.SINGLE |
9494
| 14 pt | WD_LINE_SPACING.AT_LEAST | 177800 | WD_LINE_SPACING.AT_LEAST |
9595
| 14 pt | None | 1.1666 | WD_LINE_SPACING.MULTIPLE |
96+
97+
98+
@wip
99+
Scenario Outline: Get paragraph indents
100+
Given a paragraph format having <type> indent of <setting>
101+
Then paragraph_format.<type>_indent is <value>
102+
103+
Examples: paragraph_format indent values
104+
| type | setting | value |
105+
| first_line | inherit | None |
106+
| first_line | 18 pt | 228600 |
107+
| first_line | -17.3 pt | -219710 |
108+
| left | inherit | None |
109+
| left | 46.1 pt | 585470 |
110+
| right | inherit | None |
111+
| right | 17.3 pt | 219710 |
112+
113+
114+
@wip
115+
Scenario Outline: Set paragraph indents
116+
Given a paragraph format having <type> indent of <setting>
117+
When I assign <new-value> to paragraph_format.<type>_indent
118+
Then paragraph_format.<type>_indent is <value>
119+
120+
Examples: paragraph_format indent assignment results
121+
| type | setting | new-value | value |
122+
| first_line | inherit | 18 pt | 228600 |
123+
| first_line | 18 pt | -18 pt | -228600 |
124+
| first_line | -17.3 pt | None | None |
125+
| left | inherit | 36 pt | 457200 |
126+
| left | 46.1 pt | -12 pt | -152400 |
127+
| left | 46.1 pt | None | None |
128+
| right | inherit | 24 pt | 304800 |
129+
| right | 17.3 pt | -6 pt | -76200 |
130+
| right | 17.3 pt | None | None |

0 commit comments

Comments
 (0)