1 import unittest
2
3 from lxml import etree
4 from lxml.tests.common_imports import HelperTestCase
5 from lxml.doctestcompare import LXMLOutputChecker, PARSE_HTML, PARSE_XML
6
7
12
13
28
29
31 _checker = LXMLOutputChecker()
32
33 - def compare(self, want, got, html=False):
44
47
55
60
66
72
78
80 self.assert_diff(
81 '<p title="expected">Expected</p>',
82 '<p title="actual">Actual</p>',
83 '<p title="expected (got: actual)">Expected (got: Actual)</p>\n')
84
86
87 self.assert_diff(
88 '<p><span>One</span></p>',
89 '<p><span>One</span><b>Two</b><em>Three</em></p>',
90 '<p>\n'
91 ' <span>One</span>\n'
92 ' +<b>Two</b>\n'
93 ' +<em>Three</em>\n'
94 '</p>\n')
95
97 self.assert_diff(
98 '<p><span>One</span><b>Two</b><em>Three</em></p>',
99 '<p><span>One</span></p>',
100 '<p>\n'
101 ' <span>One</span>\n'
102 ' -<b>Two</b>\n'
103 ' -<em>Three</em>\n'
104 '</p>\n')
105
107 self.assert_diff(
108 '<p><span class="foo">Text</span></p>',
109 '<p><span class="foo" id="bar">Text</span></p>',
110 '<p>\n'
111 ' <span class="foo" +id="bar">Text</span>\n'
112 '</p>\n')
113
115 self.assert_diff(
116 '<p><span class="foo" id="bar">Text</span></p>',
117 '<p><span class="foo">Text</span></p>',
118 '<p>\n'
119 ' <span class="foo" -id="bar">Text</span>\n'
120 '</p>\n')
121
122
124 suite = unittest.TestSuite()
125 suite.addTests([unittest.makeSuite(DoctestCompareTest)])
126 return suite
127
128
129 if __name__ == '__main__':
130 unittest.main()
131