@@ -164,8 +164,42 @@ def it_can_add_a_tab_stop(self, add_tab_fixture):
164164 tab_stops .add_tab_stop (position , ** kwargs )
165165 assert tab_stops ._element .xml == expected_xml
166166
167+ def it_can_delete_a_tab_stop (self , del_fixture ):
168+ tab_stops , idx , expected_xml = del_fixture
169+ del tab_stops [idx ]
170+ assert tab_stops ._element .xml == expected_xml
171+
172+ def it_raises_on_del_idx_invalid (self , del_raises_fixture ):
173+ tab_stops , idx = del_raises_fixture
174+ with pytest .raises (IndexError ) as exc :
175+ del tab_stops [idx ]
176+ assert exc .value .args [0 ] == 'tab index out of range'
177+
167178 # fixture --------------------------------------------------------
168179
180+ @pytest .fixture (params = [
181+ ('w:pPr/w:tabs/w:tab{w:pos=42}' , 0 ,
182+ 'w:pPr' ),
183+ ('w:pPr/w:tabs/(w:tab{w:pos=24},w:tab{w:pos=42})' , 0 ,
184+ 'w:pPr/w:tabs/w:tab{w:pos=42}' ),
185+ ('w:pPr/w:tabs/(w:tab{w:pos=24},w:tab{w:pos=42})' , 1 ,
186+ 'w:pPr/w:tabs/w:tab{w:pos=24}' ),
187+ ])
188+ def del_fixture (self , request ):
189+ pPr_cxml , idx , expected_cxml = request .param
190+ tab_stops = TabStops (element (pPr_cxml ))
191+ expected_xml = xml (expected_cxml )
192+ return tab_stops , idx , expected_xml
193+
194+ @pytest .fixture (params = [
195+ ('w:pPr' , 0 ),
196+ ('w:pPr/w:tabs/w:tab{w:pos=42}' , 1 ),
197+ ])
198+ def del_raises_fixture (self , request ):
199+ tab_stops_cxml , idx = request .param
200+ tab_stops = TabStops (element (tab_stops_cxml ))
201+ return tab_stops , idx
202+
169203 @pytest .fixture (params = [
170204 ('w:pPr' , Twips (42 ), {},
171205 'w:pPr/w:tabs/w:tab{w:pos=42,w:val=left}' ),
0 commit comments