forked from python-openxml/python-docx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_shared.py
More file actions
64 lines (55 loc) · 1.75 KB
/
test_shared.py
File metadata and controls
64 lines (55 loc) · 1.75 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# encoding: utf-8
"""
Test suite for docx.oxml.shared
"""
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import pytest
from docx.oxml.shared import XmlString
class DescribeXmlString(object):
def it_knows_if_two_xml_lines_are_equivalent(self, xml_line_case):
line, other, differs = xml_line_case
xml = XmlString(line)
assert xml == other
assert xml != differs
# fixtures ---------------------------------------------
@pytest.fixture(params=[
'simple_elm', 'nsp_tagname', 'indent', 'attrs', 'nsdecl_order',
'closing_elm',
])
def xml_line_case(self, request):
cases = {
'simple_elm': (
'<name/>',
'<name/>',
'<name>',
),
'nsp_tagname': (
'<xyz:name/>',
'<xyz:name/>',
'<abc:name/>',
),
'indent': (
' <xyz:name/>',
' <xyz:name/>',
'<xyz:name/>',
),
'attrs': (
' <abc:Name foo="bar" bar="foo">',
' <abc:Name bar="foo" foo="bar">',
' <abc:Name far="boo" foo="bar">',
),
'nsdecl_order': (
' <name xmlns:a="http://ns/1" xmlns:b="http://ns/2"/>',
' <name xmlns:b="http://ns/2" xmlns:a="http://ns/1"/>',
' <name xmlns:b="http://ns/2" xmlns:a="http://ns/1">',
),
'closing_elm': (
'</xyz:name>',
'</xyz:name>',
'<xyz:name>',
),
}
line, other, differs = cases[request.param]
return line, other, differs