@@ -301,6 +301,11 @@ def it_knows_its_space_before(self, space_before_get_fixture):
301301 paragraph_format , expected_value = space_before_get_fixture
302302 assert paragraph_format .space_before == expected_value
303303
304+ def it_can_change_its_space_before (self , space_before_set_fixture ):
305+ paragraph_format , value , expected_xml = space_before_set_fixture
306+ paragraph_format .space_before = value
307+ assert paragraph_format ._element .xml == expected_xml
308+
304309 def it_knows_its_space_after (self , space_after_get_fixture ):
305310 paragraph_format , expected_value = space_after_get_fixture
306311 assert paragraph_format .space_after == expected_value
@@ -356,3 +361,21 @@ def space_before_get_fixture(self, request):
356361 p_cxml , expected_value = request .param
357362 paragraph_format = ParagraphFormat (element (p_cxml ))
358363 return paragraph_format , expected_value
364+
365+ @pytest .fixture (params = [
366+ ('w:p' , Pt (12 ), 'w:p/w:pPr/w:spacing{w:before=240}' ),
367+ ('w:p' , None , 'w:p/w:pPr' ),
368+ ('w:p/w:pPr' , Pt (12 ), 'w:p/w:pPr/w:spacing{w:before=240}' ),
369+ ('w:p/w:pPr' , None , 'w:p/w:pPr' ),
370+ ('w:p/w:pPr/w:spacing' , Pt (12 ), 'w:p/w:pPr/w:spacing{w:before=240}' ),
371+ ('w:p/w:pPr/w:spacing' , None , 'w:p/w:pPr/w:spacing' ),
372+ ('w:p/w:pPr/w:spacing{w:before=240}' , Pt (42 ),
373+ 'w:p/w:pPr/w:spacing{w:before=840}' ),
374+ ('w:p/w:pPr/w:spacing{w:before=840}' , None ,
375+ 'w:p/w:pPr/w:spacing' ),
376+ ])
377+ def space_before_set_fixture (self , request ):
378+ p_cxml , value , expected_p_cxml = request .param
379+ paragraph_format = ParagraphFormat (element (p_cxml ))
380+ expected_xml = xml (expected_p_cxml )
381+ return paragraph_format , value , expected_xml
0 commit comments