-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtest_styles.py
More file actions
42 lines (35 loc) · 1.32 KB
/
test_styles.py
File metadata and controls
42 lines (35 loc) · 1.32 KB
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
36
37
38
39
40
41
42
"""Test suite for the docx.oxml.styles module."""
import pytest
from docx.enum.style import WD_STYLE_TYPE
from ..unitutil.cxml import element, xml
class DescribeCT_Styles:
def it_can_add_a_style_of_type(self, add_fixture):
styles, name, style_type, builtin, expected_xml = add_fixture
style = styles.add_style_of_type(name, style_type, builtin)
assert styles.xml == expected_xml
assert style is styles[-1]
# fixtures -------------------------------------------------------
@pytest.fixture(
params=[
(
"w:styles",
"Foo Bar",
WD_STYLE_TYPE.LIST,
False,
"w:styles/w:style{w:type=numbering,w:customStyle=1,w:styleId=FooBar"
"}/w:name{w:val=Foo Bar}",
),
(
"w:styles",
"heading 1",
WD_STYLE_TYPE.PARAGRAPH,
True,
"w:styles/w:style{w:type=paragraph,w:styleId=Heading1}/w:name{w:val=heading 1}",
),
]
)
def add_fixture(self, request):
styles_cxml, name, style_type, builtin, expected_cxml = request.param
styles = element(styles_cxml)
expected_xml = xml(expected_cxml)
return styles, name, style_type, builtin, expected_xml