88
99from docx import Document
1010from docx .enum .text import WD_TAB_ALIGNMENT , WD_TAB_LEADER
11+ from docx .shared import Inches
1112from docx .text .tabstops import TabStop
1213
1314from 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' )
5461def 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' )
114140def then_the_tab_stops_are_sequenced_in_position_order (context ):
115141 tab_stops = context .tab_stops
0 commit comments