1 import sys
2 import unittest
3
4 from lxml import etree
5 from lxml.tests.common_imports import HelperTestCase
6 from lxml.doctestcompare import LXMLOutputChecker, PARSE_HTML, PARSE_XML
7
8
13
14
29
30
32 _checker = LXMLOutputChecker()
33
34 - def compare(self, want, got, html=False):
45
48
56
61
67
73
79
81 self.assert_diff(
82 '<p title="expected">Expected</p>',
83 '<p title="actual">Actual</p>',
84 '<p title="expected (got: actual)">Expected (got: Actual)</p>\n')
85
87
88 self.assert_diff(
89 '<p><span>One</span></p>',
90 '<p><span>One</span><b>Two</b><em>Three</em></p>',
91 '<p>\n'
92 ' <span>One</span>\n'
93 ' +<b>Two</b>\n'
94 ' +<em>Three</em>\n'
95 '</p>\n')
96
98 self.assert_diff(
99 '<p><span>One</span><b>Two</b><em>Three</em></p>',
100 '<p><span>One</span></p>',
101 '<p>\n'
102 ' <span>One</span>\n'
103 ' -<b>Two</b>\n'
104 ' -<em>Three</em>\n'
105 '</p>\n')
106
108 self.assert_diff(
109 '<p><span class="foo">Text</span></p>',
110 '<p><span class="foo" id="bar">Text</span></p>',
111 '<p>\n'
112 ' <span class="foo" +id="bar">Text</span>\n'
113 '</p>\n')
114
116 self.assert_diff(
117 '<p><span class="foo" id="bar">Text</span></p>',
118 '<p><span class="foo">Text</span></p>',
119 '<p>\n'
120 ' <span class="foo" -id="bar">Text</span>\n'
121 '</p>\n')
122
123
125 suite = unittest.TestSuite()
126 if sys.version_info >= (2,4):
127 suite.addTests([unittest.makeSuite(DoctestCompareTest)])
128 return suite
129
130
131 if __name__ == '__main__':
132 unittest.main()
133