Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2bdaf7e

Browse files
DKWoodsSteve Canny
authored andcommitted
acpt: add scenarios for add/remove tab stop
1 parent 78ecbd6 commit 2bdaf7e

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

features/steps/tabstops.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from docx import Document
1010
from docx.enum.text import WD_TAB_ALIGNMENT, WD_TAB_LEADER
11+
from docx.shared import Inches
1112
from docx.text.tabstops import TabStop
1213

1314
from helpers import test_docx
@@ -50,6 +51,12 @@ def given_a_tab_stop_having_leader_leader(context, leader):
5051

5152
# when ====================================================
5253

54+
@when('I add a tab stop')
55+
def when_I_add_a_tab_stop(context):
56+
tab_stops = context.tab_stops
57+
tab_stops.add_tab_stop(Inches(1.75))
58+
59+
5360
@when('I assign {member} to tab_stop.alignment')
5461
def when_I_assign_member_to_tab_stop_alignment(context, member):
5562
value = getattr(WD_TAB_ALIGNMENT, member)
@@ -67,6 +74,18 @@ def when_I_assign_value_to_tab_stop_value(context, value):
6774
context.tab_stop.position = int(value)
6875

6976

77+
@when('I call tab_stops.clear_all()')
78+
def when_I_call_tab_stops_clear_all(context):
79+
tab_stops = context.tab_stops
80+
tab_stops.clear_all()
81+
82+
83+
@when('I remove a tab stop')
84+
def when_I_remove_a_tab_stop(context):
85+
tab_stops = context.tab_stops
86+
del tab_stops[1]
87+
88+
7089
# then =====================================================
7190

7291
@then('I can access a tab stop by index')
@@ -110,6 +129,13 @@ def then_tab_stop_position_is_position(context, position):
110129
assert tab_stop.position == int(position)
111130

112131

132+
@then('the removed tab stop is no longer present in tab_stops')
133+
def then_the_removed_tab_stop_is_no_longer_present_in_tab_stops(context):
134+
tab_stops = context.tab_stops
135+
assert tab_stops[0].position == Inches(1)
136+
assert tab_stops[1].position == Inches(3)
137+
138+
113139
@then('the tab stops are sequenced in position order')
114140
def then_the_tab_stops_are_sequenced_in_position_order(context):
115141
tab_stops = context.tab_stops

features/tab-access-tabs.feature

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,31 @@ Feature: Access TabStop objects
1818
Given a tab_stops having 3 tab stops
1919
Then I can iterate the TabStops object
2020
And I can access a tab stop by index
21+
22+
23+
@wip
24+
Scenario Outline: TabStops.add_tab_stop()
25+
Given a tab_stops having <count> tab stops
26+
When I add a tab stop
27+
Then len(tab_stops) is <new-count>
28+
And the tab stops are sequenced in position order
29+
30+
Examples: tab stop object counts
31+
| count | new-count |
32+
| 0 | 1 |
33+
| 3 | 4 |
34+
35+
36+
@wip
37+
Scenario: TabStops.__delitem__()
38+
Given a tab_stops having 3 tab stops
39+
When I remove a tab stop
40+
Then len(tab_stops) is 2
41+
And the removed tab stop is no longer present in tab_stops
42+
43+
44+
@wip
45+
Scenario: TabStops.clear_all()
46+
Given a tab_stops having 3 tab stops
47+
When I call tab_stops.clear_all()
48+
Then len(tab_stops) is 0

0 commit comments

Comments
 (0)