@@ -159,8 +159,35 @@ def it_raises_on_indexed_access_when_empty(self):
159159 with pytest .raises (IndexError ):
160160 tab_stops [0 ]
161161
162+ def it_can_add_a_tab_stop (self , add_tab_fixture ):
163+ tab_stops , position , kwargs , expected_xml = add_tab_fixture
164+ tab_stops .add_tab_stop (position , ** kwargs )
165+ assert tab_stops ._element .xml == expected_xml
166+
162167 # fixture --------------------------------------------------------
163168
169+ @pytest .fixture (params = [
170+ ('w:pPr' , Twips (42 ), {},
171+ 'w:pPr/w:tabs/w:tab{w:pos=42,w:val=left}' ),
172+ ('w:pPr' , Twips (72 ), {'alignment' : WD_TAB_ALIGNMENT .RIGHT },
173+ 'w:pPr/w:tabs/w:tab{w:pos=72,w:val=right}' ),
174+ ('w:pPr' , Twips (24 ),
175+ {'alignment' : WD_TAB_ALIGNMENT .CENTER ,
176+ 'leader' : WD_TAB_LEADER .DOTS },
177+ 'w:pPr/w:tabs/w:tab{w:pos=24,w:val=center,w:leader=dot}' ),
178+ ('w:pPr/w:tabs/w:tab{w:pos=42}' , Twips (72 ), {},
179+ 'w:pPr/w:tabs/(w:tab{w:pos=42},w:tab{w:pos=72,w:val=left})' ),
180+ ('w:pPr/w:tabs/w:tab{w:pos=42}' , Twips (24 ), {},
181+ 'w:pPr/w:tabs/(w:tab{w:pos=24,w:val=left},w:tab{w:pos=42})' ),
182+ ('w:pPr/w:tabs/w:tab{w:pos=42}' , Twips (42 ), {},
183+ 'w:pPr/w:tabs/(w:tab{w:pos=42},w:tab{w:pos=42,w:val=left})' ),
184+ ])
185+ def add_tab_fixture (self , request ):
186+ pPr_cxml , position , kwargs , expected_cxml = request .param
187+ tab_stops = TabStops (element (pPr_cxml ))
188+ expected_xml = xml (expected_cxml )
189+ return tab_stops , position , kwargs , expected_xml
190+
164191 @pytest .fixture (params = [
165192 ('w:pPr/w:tabs/w:tab{w:pos=0}' , 0 ),
166193 ('w:pPr/w:tabs/(w:tab{w:pos=1},w:tab{w:pos=2},w:tab{w:pos=3})' , 1 ),
0 commit comments