1
2 from __future__ import absolute_import
3
4 import unittest
5
6 from lxml import etree
7 from .common_imports import HelperTestCase
8 from lxml.doctestcompare import LXMLOutputChecker, PARSE_HTML, PARSE_XML
9
10
15
16
31
32
34 _checker = LXMLOutputChecker()
35
36 - def compare(self, want, got, html=False):
47
50
58
63
69
75
81
83 self.assert_diff(
84 '<p title="expected">Expected</p>',
85 '<p title="actual">Actual</p>',
86 '<p title="expected (got: actual)">Expected (got: Actual)</p>\n')
87
89
90 self.assert_diff(
91 '<p><span>One</span></p>',
92 '<p><span>One</span><b>Two</b><em>Three</em></p>',
93 '<p>\n'
94 ' <span>One</span>\n'
95 ' +<b>Two</b>\n'
96 ' +<em>Three</em>\n'
97 '</p>\n')
98
100 self.assert_diff(
101 '<p><span>One</span><b>Two</b><em>Three</em></p>',
102 '<p><span>One</span></p>',
103 '<p>\n'
104 ' <span>One</span>\n'
105 ' -<b>Two</b>\n'
106 ' -<em>Three</em>\n'
107 '</p>\n')
108
110 self.assert_diff(
111 '<p><span class="foo">Text</span></p>',
112 '<p><span class="foo" id="bar">Text</span></p>',
113 '<p>\n'
114 ' <span class="foo" +id="bar">Text</span>\n'
115 '</p>\n')
116
118 self.assert_diff(
119 '<p><span class="foo" id="bar">Text</span></p>',
120 '<p><span class="foo">Text</span></p>',
121 '<p>\n'
122 ' <span class="foo" -id="bar">Text</span>\n'
123 '</p>\n')
124
125
127 suite = unittest.TestSuite()
128 suite.addTests([unittest.makeSuite(DoctestCompareTest)])
129 return suite
130
131
132 if __name__ == '__main__':
133 unittest.main()
134