@@ -31,6 +31,18 @@ def given_a_font_having_typeface_name(context, name):
3131 context .font = document .styles [style_name ].font
3232
3333
34+ @given ('a font having {underline_type} underline' )
35+ def given_a_font_having_type_underline (context , underline_type ):
36+ style_name = {
37+ 'inherited' : 'Normal' ,
38+ 'no' : 'None Underlined' ,
39+ 'single' : 'Underlined' ,
40+ 'double' : 'Double Underlined' ,
41+ }[underline_type ]
42+ document = Document (test_docx ('txt-font-props' ))
43+ context .font = document .styles [style_name ].font
44+
45+
3446@given ('a font of size {size}' )
3547def given_a_font_of_size (context , size ):
3648 document = Document (test_docx ('txt-font-props' ))
@@ -183,6 +195,19 @@ def when_I_assign_value_str_to_font_size(context, value):
183195 font .size = value
184196
185197
198+ @when ('I assign {value_key} to font.underline' )
199+ def when_I_assign_value_to_font_underline (context , value_key ):
200+ value = {
201+ 'True' : True ,
202+ 'False' : False ,
203+ 'None' : None ,
204+ 'WD_UNDERLINE.SINGLE' : WD_UNDERLINE .SINGLE ,
205+ 'WD_UNDERLINE.DOUBLE' : WD_UNDERLINE .DOUBLE ,
206+ }[value_key ]
207+ font = context .font
208+ font .underline = value
209+
210+
186211@when ('I assign {value_str} to its {bool_prop_name} property' )
187212def when_assign_true_to_bool_run_prop (context , value_str , bool_prop_name ):
188213 value = {'True' : True , 'False' : False , 'None' : None }[value_str ]
@@ -229,6 +254,18 @@ def then_font_size_is_value(context, value):
229254 assert font .size == value
230255
231256
257+ @then ('font.underline is {value_key}' )
258+ def then_font_underline_is_value (context , value_key ):
259+ value = {
260+ 'None' : None ,
261+ 'True' : True ,
262+ 'False' : False ,
263+ 'WD_UNDERLINE.DOUBLE' : WD_UNDERLINE .DOUBLE ,
264+ }[value_key ]
265+ font = context .font
266+ assert font .underline == value
267+
268+
232269@then ('it is a column break' )
233270def then_type_is_column_break (context ):
234271 attrib = context .last_child .attrib
0 commit comments