Skip to content

Commit 09d88de

Browse files
committed
test_text: updated
corrected errors in test_text.
1 parent 9d7af1b commit 09d88de

2 files changed

Lines changed: 40 additions & 8 deletions

File tree

tests/oxml/unitdata/text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ def an_emboss():
137137
def an_i():
138138
return CT_OnOffBuilder('w:i')
139139

140-
def an_underline():
141-
return CT_OnOffBuilder('w:u')
140+
def an_u():
141+
return CT_StringBuilder('w:u')
142142

143143
def an_iCs():
144144
return CT_OnOffBuilder('w:iCs')

tests/test_text.py

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
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, an_underline
23+
an_r, an_rPr, an_rtl, an_underline, an_u
2424
)
2525
from .unitutil import class_mock, instance_mock
2626

@@ -145,13 +145,49 @@ def it_can_add_a_break(self, add_break_fixture):
145145
run, break_type, expected_xml = add_break_fixture
146146
run.add_break(break_type)
147147
assert run._r.xml == expected_xml
148+
149+
def it_can_underline_text(self, add_underline_fixture):
150+
run, underline_type, expected_xml = add_underline_fixture
151+
run.add_break(underline_type)
152+
assert run._r.xml == expected_xml
148153

149154
def it_knows_the_text_it_contains(self, text_prop_fixture):
150155
run, expected_text = text_prop_fixture
151156
assert run.text == expected_text
152157

153158
# fixtures -------------------------------------------------------
154159

160+
@pytest.fixture(params=[
161+
'dash','dashHeavy','dashLong','longHeavy','dotDash','dotDashHeavy',
162+
'dotDotDash','dotDotDashHeavy','dotted','dottedHeavy','double','none',
163+
'single','thick','wavy','wavyDouble','wavyHeavy','words',
164+
])
165+
def add_underline_fixture(self, request, run):
166+
type_, underline_type = {
167+
'dash':WD_UNDERLINE.DASH,
168+
'dashHeavy':WD_UNDERLINE.DASH_HEAVY,
169+
'dashLong':WD_UNDERLINE.DASH_LONG,
170+
'longHeavy':WD_UNDERLINE.LONG_HEAVY,
171+
'dotDash':WD_UNDERLINE.DOT_DASH,
172+
'dotDashHeavy':WD_UNDERLINE.DOT_DASH_HEAVY,
173+
'dotDotDash':WD_UNDERLINE.DOT_DOT_DASH,
174+
'dotDotDashHeavy':WD_UNDERLINE.DOT_DOT_DASH_HEAVY,
175+
'dotted':WD_UNDERLINE.DOTTED,
176+
'dottedHeavy':WD_UNDERLINE.DOTTED_HEAVY,
177+
'double':WD_UNDERLINE.DOUBLE,
178+
'none':WD_UNDERLINE.NONE,
179+
'single':WD_UNDERLINE.SINGLE,
180+
'thick':WD_UNDERLINE.THICK,
181+
'wavy':WD_UNDERLINE.WAVY,
182+
'wavyDouble':WD_UNDERLINE.WAVY_DOUBLE,
183+
'wavyHeavy':WD_UNDERLINE.WAVY_HEAVY,
184+
'words':WD_UNDERLINE.WORDS,
185+
}[request.param]
186+
u_bldr = an_u()
187+
expected_xml = an_r().with_nsdecls().with_child(u_bldr).xml()
188+
return run, underline_type, expected_xml
189+
190+
155191
@pytest.fixture(params=[
156192
'line', 'page', 'column', 'clr_lt', 'clr_rt', 'clr_all'
157193
])
@@ -186,7 +222,6 @@ def add_text_fixture(self, request, run, Text_):
186222
('all_caps', True), ('all_caps', False), ('all_caps', None),
187223
('bold', True), ('bold', False), ('bold', None),
188224
('italic', True), ('italic', False), ('italic', None),
189-
('underline', True), ('underline', False), ('underline', None),
190225
('complex_script', True), ('complex_script', False),
191226
('complex_script', None),
192227
('cs_bold', True), ('cs_bold', False), ('cs_bold', None),
@@ -232,7 +267,6 @@ def bool_prop_get_fixture(self, request):
232267
'spec_vanish': a_specVanish,
233268
'strike': a_strike,
234269
'web_hidden': a_webHidden,
235-
'underline': an_underline,
236270
}[bool_prop_name]
237271
r_bldr = an_r().with_nsdecls()
238272
if expected_state is not None:
@@ -249,7 +283,6 @@ def bool_prop_get_fixture(self, request):
249283
('all_caps', True), ('all_caps', False), ('all_caps', None),
250284
('bold', True), ('bold', False), ('bold', None),
251285
('italic', True), ('italic', False), ('italic', None),
252-
('underline', True), ('underline', False), ('underline', None),
253286
('complex_script', True), ('complex_script', False),
254287
('complex_script', None),
255288
('cs_bold', True), ('cs_bold', False), ('cs_bold', None),
@@ -269,7 +302,7 @@ def bool_prop_get_fixture(self, request):
269302
('snap_to_grid', True), ('snap_to_grid', False),
270303
('snap_to_grid', None),
271304
('spec_vanish', True), ('spec_vanish', False), ('spec_vanish', None),
272-
('strike', True), ('strikregister_custom_element_class('w:tcPr', CT_TcPr)e', False), ('strike', None),
305+
('strike', True), ('strie', False), ('strike', None),
273306
('web_hidden', True), ('web_hidden', False), ('web_hidden', None),
274307
])
275308
def bool_prop_set_fixture(self, request):
@@ -295,7 +328,6 @@ def bool_prop_set_fixture(self, request):
295328
'spec_vanish': a_specVanish,
296329
'strike': a_strike,
297330
'web_hidden': a_webHidden,
298-
'underline': an_underline,
299331
}[bool_prop_name]
300332
# run --------------------------
301333
r = an_r().with_nsdecls().element

0 commit comments

Comments
 (0)