Skip to content

Commit 358233d

Browse files
committed
acpt: Adjust tests for keeping tabs in position order when changing position values
1 parent d2a72cd commit 358233d

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

features/steps/tabstops.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def given_a_tab_stop_inches_from_paragraph_left_edge(context, in_or_out):
2929
tab_idx = {'out': 0, 'in': 1}[in_or_out]
3030
document = Document(test_docx('tab-stops'))
3131
paragraph_format = document.paragraphs[2].paragraph_format
32+
context.tab_stops = paragraph_format.tab_stops
3233
context.tab_stop = paragraph_format.tab_stops[tab_idx]
3334

3435

@@ -69,10 +70,15 @@ def when_I_assign_member_to_tab_stop_leader(context, member):
6970

7071

7172
@when('I assign {value} to tab_stop.position')
72-
def when_I_assign_value_to_tab_stop_value(context, value):
73+
def when_I_assign_value_to_tab_stop_position(context, value):
7374
context.tab_stop.position = int(value)
7475

7576

77+
@when('I change the tab at {index} position to {value}')
78+
def when_I_change_the_tab_at_index_position_to_value(context, index, value):
79+
context.tab_stops[int(index)].position = int(value)
80+
81+
7682
@when('I call tab_stops.clear_all()')
7783
def when_I_call_tab_stops_clear_all(context):
7884
tab_stops = context.tab_stops
@@ -128,6 +134,14 @@ def then_tab_stop_position_is_position(context, position):
128134
assert tab_stop.position == int(position)
129135

130136

137+
# Use this rather than the above method when you change the position,
138+
# as setting position invalidates context.tab_stop
139+
@then('tab_stops at position {index} is {value}')
140+
def then_tab_stops_at_position_index_is_value(context, index, value):
141+
tab_stops = context.tab_stops
142+
assert tab_stops[int(index)].position == int(value)
143+
144+
131145
@then('the removed tab stop is no longer present in tab_stops')
132146
def then_the_removed_tab_stop_is_no_longer_present_in_tab_stops(context):
133147
tab_stops = context.tab_stops

features/tab-tabstop-props.feature

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,24 @@ Feature: Tab stop properties
1717
Scenario Outline: Set tab stop position
1818
Given a tab stop 0.5 inches in from the paragraph left edge
1919
When I assign <value> to tab_stop.position
20-
Then tab_stop.position is <value>
20+
Then tab_stops at position 1 is <value>
2121

2222
Examples: tab stop positions
2323
| value |
2424
| 228600 |
2525
| -228600 |
26-
26+
27+
28+
@wip
29+
Scenario Outline: Maintain tab stop position order when changing position
30+
Given a tab_stops having 3 tab stops
31+
When I change the tab at <index> position to <value>
32+
Then the tab stops are sequenced in position order
33+
34+
Examples: tab stop positions
35+
| index | value |
36+
| 0 | 2285000 |
37+
| 2 | 1371600 |
2738

2839
Scenario Outline: Get tab stop alignment
2940
Given a tab stop having <alignment> alignment

0 commit comments

Comments
 (0)