2020 a_b , a_bCs , a_br , a_caps , a_cs , a_dstrike , a_p , a_shadow , a_smallCaps ,
2121 a_snapToGrid , a_specVanish , a_strike , a_t , a_vanish , a_webHidden ,
2222 an_emboss , an_i , an_iCs , an_imprint , an_oMath , a_noProof , an_outline ,
23- an_r , an_rPr , an_rtl
23+ an_r , an_rPr , an_rStyle , an_rtl
2424)
2525from .unitutil import class_mock , instance_mock
2626
@@ -135,6 +135,10 @@ def it_can_change_its_bool_prop_settings(self, bool_prop_set_fixture):
135135 setattr (run , prop_name , value )
136136 assert run ._r .xml == expected_xml
137137
138+ def it_knows_its_character_style (self , style_get_fixture ):
139+ run , expected_style = style_get_fixture
140+ assert run .style == expected_style
141+
138142 def it_can_add_text (self , add_text_fixture ):
139143 run , text_str , expected_xml , Text_ = add_text_fixture
140144 _text = run .add_text (text_str )
@@ -306,14 +310,18 @@ def bool_prop_set_fixture(self, request):
306310 expected_xml = an_r ().with_nsdecls ().with_child (rPr_bldr ).xml ()
307311 return run , bool_prop_name , value , expected_xml
308312
309- @pytest .fixture
310- def run (self ):
311- r = an_r ().with_nsdecls ().element
312- return Run (r )
313-
314- @pytest .fixture
315- def Text_ (self , request ):
316- return class_mock (request , 'docx.text.Text' )
313+ @pytest .fixture (params = ['Foobar' , None ])
314+ def style_get_fixture (self , request ):
315+ style = request .param
316+ r_bldr = an_r ().with_nsdecls ()
317+ if style is not None :
318+ r_bldr .with_child (
319+ an_rPr ().with_child (
320+ an_rStyle ().with_val (style ))
321+ )
322+ r = r_bldr .element
323+ run = Run (r )
324+ return run , style
317325
318326 @pytest .fixture
319327 def text_prop_fixture (self , Text_ ):
@@ -324,3 +332,14 @@ def text_prop_fixture(self, Text_):
324332 ).element
325333 run = Run (r )
326334 return run , 'foobar'
335+
336+ # fixture components ---------------------------------------------
337+
338+ @pytest .fixture
339+ def run (self ):
340+ r = an_r ().with_nsdecls ().element
341+ return Run (r )
342+
343+ @pytest .fixture
344+ def Text_ (self , request ):
345+ return class_mock (request , 'docx.text.Text' )
0 commit comments