@@ -85,6 +85,11 @@ def it_knows_its_highlight_color(self, highlight_get_fixture):
8585 font , expected_value = highlight_get_fixture
8686 assert font .highlight_color is expected_value
8787
88+ def it_can_change_its_highlight_color (self , highlight_set_fixture ):
89+ font , highlight_color , expected_xml = highlight_set_fixture
90+ font .highlight_color = highlight_color
91+ assert font ._element .xml == expected_xml
92+
8893 # fixtures -------------------------------------------------------
8994
9095 @pytest .fixture (params = [
@@ -189,6 +194,26 @@ def highlight_get_fixture(self, request):
189194 font = Font (element (r_cxml ), None )
190195 return font , expected_value
191196
197+ @pytest .fixture (params = [
198+ ('w:r' , WD_COLOR .AUTO ,
199+ 'w:r/w:rPr/w:highlight{w:val=default}' ),
200+ ('w:r/w:rPr' , WD_COLOR .BRIGHT_GREEN ,
201+ 'w:r/w:rPr/w:highlight{w:val=green}' ),
202+ ('w:r/w:rPr/w:highlight{w:val=green}' , WD_COLOR .YELLOW ,
203+ 'w:r/w:rPr/w:highlight{w:val=yellow}' ),
204+ ('w:r/w:rPr/w:highlight{w:val=yellow}' , None ,
205+ 'w:r/w:rPr' ),
206+ ('w:r/w:rPr' , None ,
207+ 'w:r/w:rPr' ),
208+ ('w:r' , None ,
209+ 'w:r/w:rPr' ),
210+ ])
211+ def highlight_set_fixture (self , request ):
212+ r_cxml , value , expected_cxml = request .param
213+ font = Font (element (r_cxml ), None )
214+ expected_xml = xml (expected_cxml )
215+ return font , value , expected_xml
216+
192217 @pytest .fixture (params = [
193218 ('w:r' , None ),
194219 ('w:r/w:rPr' , None ),
0 commit comments