Skip to content

Commit 478c68b

Browse files
mavwolverineSteve Canny
authored and
Steve Canny
committed
acpt: add scenarios for ColorFormat.rgb
1 parent 96273f2 commit 478c68b

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

features/steps/font.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from docx.dml.color import ColorFormat
1515
from docx.enum.dml import MSO_COLOR_TYPE
1616
from docx.enum.text import WD_UNDERLINE
17+
from docx.shared import RGBColor
1718

1819
from helpers import test_docx
1920

@@ -79,6 +80,13 @@ def given_a_font_of_size(context, size):
7980

8081
# when ====================================================
8182

83+
@when('I assign {value} to font.color.rgb')
84+
def when_I_assign_value_to_font_color_rgb(context, value):
85+
font = context.font
86+
new_value = None if value == 'None' else RGBColor.from_string(value)
87+
font.color.rgb = new_value
88+
89+
8290
@when('I assign {value} to font.name')
8391
def when_I_assign_value_to_font_name(context, value):
8492
font = context.font
@@ -130,6 +138,13 @@ def then_font_color_is_a_ColorFormat_object(context):
130138
assert isinstance(font.color, ColorFormat)
131139

132140

141+
@then('font.color.rgb is {value}')
142+
def then_font_color_rgb_is_value(context, value):
143+
font = context.font
144+
expected_value = None if value == 'None' else RGBColor.from_string(value)
145+
assert font.color.rgb == expected_value
146+
147+
133148
@then('font.color.type is {value}')
134149
def then_font_color_type_is_value(context, value):
135150
font = context.font

features/txt-font-color.feature

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,33 @@ Feature: Get and set font color
1414
| auto | AUTO |
1515
| an RGB | RGB |
1616
| a theme | THEME |
17+
18+
19+
@wip
20+
Scenario Outline: Get font RGB color
21+
Given a font having <type> color
22+
Then font.color.rgb is <value>
23+
24+
Examples: Color type settings
25+
| type | value |
26+
| no | None |
27+
| auto | None |
28+
| an RGB | 008000 |
29+
| a theme | 4f81bd |
30+
31+
32+
@wip
33+
Scenario Outline: Set font RGB color
34+
Given a font having <type> color
35+
When I assign <value> to font.color.rgb
36+
Then font.color.type is <type-value>
37+
Then font.color.rgb is <rgb-value>
38+
39+
Examples: Color type settings
40+
| type | value | type-value | rgb-value |
41+
| no | f00ba5 | RGB | f00ba5 |
42+
| auto | 2468ac | RGB | 2468ac |
43+
| an RGB | feeb1e | RGB | feeb1e |
44+
| a theme | 987bac | RGB | 987bac |
45+
| an RGB | None | None | None |
46+
| a theme | None | None | None |

0 commit comments

Comments
 (0)