Skip to content

Commit 44cc330

Browse files
author
Steve Canny
committed
oxml: add unit tests for oxml_parser
1 parent 8ae8ba5 commit 44cc330

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

tests/oxml/test__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# encoding: utf-8
2+
3+
"""
4+
Test suite for pptx.oxml.__init__.py module, primarily XML parser-related.
5+
"""
6+
7+
from __future__ import print_function, unicode_literals
8+
9+
import pytest
10+
11+
from lxml import etree
12+
13+
from docx.oxml import oxml_parser
14+
15+
16+
class DescribeOxmlParser(object):
17+
18+
def it_strips_whitespace_between_elements(self, whitespace_fixture):
19+
pretty_xml_text, stripped_xml_text = whitespace_fixture
20+
element = etree.fromstring(pretty_xml_text, oxml_parser)
21+
xml_text = etree.tostring(element, encoding='unicode')
22+
assert xml_text == stripped_xml_text
23+
24+
# fixtures -------------------------------------------------------
25+
26+
@pytest.fixture
27+
def whitespace_fixture(self):
28+
pretty_xml_text = (
29+
'<foø>\n'
30+
' <bår>text</bår>\n'
31+
'</foø>\n'
32+
)
33+
stripped_xml_text = '<foø><bår>text</bår></foø>'
34+
return pretty_xml_text, stripped_xml_text

0 commit comments

Comments
 (0)