1212
1313from docx import Document
1414from docx .dml .color import ColorFormat
15+ from docx .enum .dml import MSO_COLOR_TYPE
1516from docx .enum .text import WD_UNDERLINE
1617
1718from helpers import test_docx
@@ -25,6 +26,13 @@ def given_a_font(context):
2526 context .font = document .paragraphs [0 ].runs [0 ].font
2627
2728
29+ @given ('a font having {type} color' )
30+ def given_a_font_having_type_color (context , type ):
31+ run_idx = ['no' , 'auto' , 'an RGB' , 'a theme' ].index (type )
32+ document = Document (test_docx ('fnt-color' ))
33+ context .font = document .paragraphs [0 ].runs [run_idx ].font
34+
35+
2836@given ('a font having typeface name {name}' )
2937def given_a_font_having_typeface_name (context , name ):
3038 document = Document (test_docx ('txt-font-props' ))
@@ -122,6 +130,15 @@ def then_font_color_is_a_ColorFormat_object(context):
122130 assert isinstance (font .color , ColorFormat )
123131
124132
133+ @then ('font.color.type is {value}' )
134+ def then_font_color_type_is_value (context , value ):
135+ font = context .font
136+ expected_value = (
137+ None if value == 'None' else getattr (MSO_COLOR_TYPE , value )
138+ )
139+ assert font .color .type == expected_value
140+
141+
125142@then ('font.name is {value}' )
126143def then_font_name_is_value (context , value ):
127144 font = context .font
0 commit comments