Skip to content

Commit 946864f

Browse files
mavwolverineSteve Canny
authored and
Steve Canny
committed
acpt: add scenario for Font.color
1 parent 5e9c955 commit 946864f

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

docx/dml/__init__.py

Whitespace-only changes.

docx/dml/color.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# encoding: utf-8
2+
3+
"""
4+
DrawingML objects related to color, ColorFormat being the most prominent.
5+
"""
6+
7+
from __future__ import (
8+
absolute_import, division, print_function, unicode_literals
9+
)
10+
11+
from ..shared import ElementProxy
12+
13+
14+
class ColorFormat(ElementProxy):
15+
"""
16+
Provides access to color settings such as RGB color, theme color, and
17+
luminance adjustments.
18+
"""
19+
20+
__slots__ = ()
21+
22+
def __init__(self, rPr_parent):
23+
super(ColorFormat, self).__init__(rPr_parent)

features/steps/font.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@
1111
from behave import given, then, when
1212

1313
from docx import Document
14+
from docx.dml.color import ColorFormat
1415
from docx.enum.text import WD_UNDERLINE
1516

1617
from helpers import test_docx
1718

1819

1920
# given ===================================================
2021

22+
@given('a font')
23+
def given_a_font(context):
24+
document = Document(test_docx('txt-font-props'))
25+
context.font = document.paragraphs[0].runs[0].font
26+
27+
2128
@given('a font having typeface name {name}')
2229
def given_a_font_having_typeface_name(context, name):
2330
document = Document(test_docx('txt-font-props'))
@@ -109,6 +116,12 @@ def when_I_assign_value_to_font_sub_super(context, value, sub_super):
109116

110117
# then =====================================================
111118

119+
@then('font.color is a ColorFormat object')
120+
def then_font_color_is_a_ColorFormat_object(context):
121+
font = context.font
122+
assert isinstance(font.color, ColorFormat)
123+
124+
112125
@then('font.name is {value}')
113126
def then_font_name_is_value(context, value):
114127
font = context.font

features/txt-font-props.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Feature: Get or set font properties
4848
| 18 pt | None |
4949

5050

51+
@wip
52+
Scenario: Get font color object
53+
Given a font
54+
Then font.color is a ColorFormat object
55+
56+
5157
Scenario Outline: Get font underline value
5258
Given a font having <underline-type> underline
5359
Then font.underline is <value>

0 commit comments

Comments
 (0)