forked from python-openxml/python-docx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_run.py
More file actions
35 lines (26 loc) · 998 Bytes
/
test_run.py
File metadata and controls
35 lines (26 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# encoding: utf-8
"""
Test suite for the docx.oxml.text.run module.
"""
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import pytest
from ...unitutil.cxml import element, xml
class DescribeCT_R(object):
def it_can_add_a_t_preserving_edge_whitespace(self, add_t_fixture):
r, text, expected_xml = add_t_fixture
r.add_t(text)
assert r.xml == expected_xml
# fixtures -------------------------------------------------------
@pytest.fixture(params=[
('w:r', 'foobar', 'w:r/w:t"foobar"'),
('w:r', 'foobar ', 'w:r/w:t{xml:space=preserve}"foobar "'),
('w:r/(w:rPr/w:rStyle{w:val=emphasis}, w:cr)', 'foobar',
'w:r/(w:rPr/w:rStyle{w:val=emphasis}, w:cr, w:t"foobar")'),
])
def add_t_fixture(self, request):
initial_cxml, text, expected_cxml = request.param
r = element(initial_cxml)
expected_xml = xml(expected_cxml)
return r, text, expected_xml