..\latest\test_difflib.py
..\patched\test_difflib.py
1import difflib f 1import difflib
2from test import test_support 2from test import test_support
3import unittest 3import unittest
4import doctest 4import doctest
5 5
6class TestSFbugs(unittest.TestCase): 6class TestSFbugs(unittest.TestCase):
7 7
8    def test_ratio_for_null_seqn(self): 8    def test_ratio_for_null_seqn(self):
9        # Check clearing of SF bug 763023 9        # Check clearing of SF bug 763023
10        s = difflib.SequenceMatcher(None, [], []) 10        s = difflib.SequenceMatcher(None, [], [])
11        self.assertEqual(s.ratio(), 1) 11        self.assertEqual(s.ratio(), 1)
12        self.assertEqual(s.quick_ratio(), 1) 12        self.assertEqual(s.quick_ratio(), 1)
13        self.assertEqual(s.real_quick_ratio(), 1) 13        self.assertEqual(s.real_quick_ratio(), 1)
14 14
15    def test_comparing_empty_lists(self): 15    def test_comparing_empty_lists(self):
16        # Check fix for bug #979794 16        # Check fix for bug #979794
17        group_gen = difflib.SequenceMatcher(None, [], []).get_grouped_opcodes() 17        group_gen = difflib.SequenceMatcher(None, [], []).get_grouped_opcodes()
18        self.assertRaises(StopIteration, group_gen.next) 18        self.assertRaises(StopIteration, group_gen.next)
19        diff_gen = difflib.unified_diff([], []) 19        diff_gen = difflib.unified_diff([], [])
20        self.assertRaises(StopIteration, diff_gen.next) 20        self.assertRaises(StopIteration, diff_gen.next)
21 21
n 22patch914575_from = '''
23   1. Beautiful is beTTer than ugly.
24   2. Explicit is better than implicit.
25   3. Simple is better than complex.
26   4. Complex is better than complicated.
27'''
28 
29patch914575_to = '''
30   1. Beautiful is better than ugly.
31   3.   Simple is better than complex.
32   4. Complicated is better than complex.
33   5. Flat is better than nested.
34'''
35 
36patch914575_full_expectation = '''
37        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
38            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
39        <html>
40        <head>
41        <meta http-equiv="Content-Type" 
42              content="text/html; charset=ISO-8859-1" />
43        <title>Full Side by Side Difference</title>
44        <style type="text/css">
45        .diff_header {background-color:#e0e0e0}
46        td.diff_header {text-align:right}
47        .diff_next {background-color:#c0c0c0}
48        .diff_add {background-color:#aaffaa}
49        .diff_chg {background-color:#ffff77}
50        .diff_sub {background-color:#ffaaaa}
51        </style>
52        </head>
53        <body>
54        <h2>full</h2>
55        
56        <table summary="s_full" id="difflib_chg_to1__top" border="3" 
57               cellspacing="0" cellpadding="0" rules="groups" 
58               style="font-family:Courier">
59            <colgroup></colgroup> <colgroup></colgroup> <colgroup></colgroup> 
60            <colgroup></colgroup> <colgroup></colgroup>
61            <thead><tr><th colspan="2" class="diff_header">from</th><th class="diff_next"><br /></th><th colspan="2" class="diff_header">to</th></tr></thead><tbody><tr><td class="diff_header" id="from1_1">1</td><td nowrap="nowrap">
62</td>
63<td class="diff_next" id="difflib_chg_to1__0"><a href="#difflib_chg_to1__0">f</a></td>
64<td class="diff_header" id="to1_1">1</td><td nowrap="nowrap">
65</td>
66</tr><tr><td class="diff_header" id="from1_2">2</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">TT</span>er&nbsp;than&nbsp;ugly.
67</td>
68<td class="diff_next"><a href="#difflib_chg_to1__1">n</a></td>
69<td class="diff_header" id="to1_2">2</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">tt</span>er&nbsp;than&nbsp;ugly.
70</td>
71</tr><tr><td class="diff_header" id="from1_3">3</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;2.&nbsp;Explicit&nbsp;is&nbsp;better&nbsp;than&nbsp;implicit.
72</span></td>
73<td class="diff_next"></td>
74<td class="diff_header"></td><td nowrap="nowrap">
75</td>
76</tr><tr><td class="diff_header" id="from1_4">4</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
77</td>
78<td class="diff_next"></td>
79<td class="diff_header" id="to1_3">3</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.<span class="diff_add">&nbsp;&nbsp;</span>&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
80</td>
81</tr><tr><td class="diff_header" id="from1_5">5</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;4.&nbsp;Complex&nbsp;is&nbsp;better&nbsp;than&nbsp;complicated.
82</span></td>
83<td class="diff_next"></td>
84<td class="diff_header" id="to1_4">4</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;4.&nbsp;Complicated&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
85</span></td>
86</tr><tr><td class="diff_header"></td><td nowrap="nowrap">
87</td>
88<td class="diff_next"></td>
89<td class="diff_header" id="to1_5">5</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;5.&nbsp;Flat&nbsp;is&nbsp;better&nbsp;than&nbsp;nested.
90</span></td>
91</tr><tr><td class="diff_header" id="from1_6">6</td><td nowrap="nowrap">123
92</td>
93<td class="diff_next"></td>
94<td class="diff_header" id="to1_6">6</td><td nowrap="nowrap">123
95</td>
96</tr><tr><td class="diff_header" id="from1_7">7</td><td nowrap="nowrap">123
97</td>
98<td class="diff_next"></td>
99<td class="diff_header" id="to1_7">7</td><td nowrap="nowrap">123
100</td>
101</tr><tr><td class="diff_header" id="from1_8">8</td><td nowrap="nowrap">123
102</td>
103<td class="diff_next"></td>
104<td class="diff_header" id="to1_8">8</td><td nowrap="nowrap">123
105</td>
106</tr><tr><td class="diff_header" id="from1_9">9</td><td nowrap="nowrap">123
107</td>
108<td class="diff_next"></td>
109<td class="diff_header" id="to1_9">9</td><td nowrap="nowrap">123
110</td>
111</tr><tr><td class="diff_header" id="from1_10">10</td><td nowrap="nowrap">123
112</td>
113<td class="diff_next"></td>
114<td class="diff_header" id="to1_10">10</td><td nowrap="nowrap">123
115</td>
116</tr><tr><td class="diff_header" id="from1_11">11</td><td nowrap="nowrap">123
117</td>
118<td class="diff_next"></td>
119<td class="diff_header" id="to1_11">11</td><td nowrap="nowrap">123
120</td>
121</tr><tr><td class="diff_header" id="from1_12">12</td><td nowrap="nowrap">123
122</td>
123<td class="diff_next" id="difflib_chg_to1__1"></td>
124<td class="diff_header" id="to1_12">12</td><td nowrap="nowrap">123
125</td>
126</tr><tr><td class="diff_header" id="from1_13">13</td><td nowrap="nowrap">123
127</td>
128<td class="diff_next"></td>
129<td class="diff_header" id="to1_13">13</td><td nowrap="nowrap">123
130</td>
131</tr><tr><td class="diff_header" id="from1_14">14</td><td nowrap="nowrap">123
132</td>
133<td class="diff_next"></td>
134<td class="diff_header" id="to1_14">14</td><td nowrap="nowrap">123
135</td>
136</tr><tr><td class="diff_header" id="from1_15">15</td><td nowrap="nowrap">123
137</td>
138<td class="diff_next"></td>
139<td class="diff_header" id="to1_15">15</td><td nowrap="nowrap">123
140</td>
141</tr><tr><td class="diff_header" id="from1_16">16</td><td nowrap="nowrap">
142</td>
143<td class="diff_next"></td>
144<td class="diff_header" id="to1_16">16</td><td nowrap="nowrap">
145</td>
146</tr><tr><td class="diff_header" id="from1_17">17</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">TT</span>er&nbsp;than&nbsp;ugly.
147</td>
148<td class="diff_next"><a href="#difflib_chg_to1__2">n</a></td>
149<td class="diff_header" id="to1_17">17</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">tt</span>er&nbsp;than&nbsp;ugly.
150</td>
151</tr><tr><td class="diff_header" id="from1_18">18</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;2.&nbsp;Explicit&nbsp;is&nbsp;better&nbsp;than&nbsp;implicit.
152</span></td>
153<td class="diff_next"></td>
154<td class="diff_header"></td><td nowrap="nowrap">
155</td>
156</tr><tr><td class="diff_header" id="from1_19">19</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
157</td>
158<td class="diff_next"></td>
159<td class="diff_header" id="to1_18">18</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.<span class="diff_add">&nbsp;&nbsp;</span>&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
160</td>
161</tr><tr><td class="diff_header" id="from1_20">20</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;4.&nbsp;Complex&nbsp;is&nbsp;better&nbsp;than&nbsp;complicated.
162</span></td>
163<td class="diff_next"></td>
164<td class="diff_header" id="to1_19">19</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;4.&nbsp;Complicated&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
165</span></td>
166</tr><tr><td class="diff_header"></td><td nowrap="nowrap">
167</td>
168<td class="diff_next"></td>
169<td class="diff_header" id="to1_20">20</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;5.&nbsp;Flat&nbsp;is&nbsp;better&nbsp;than&nbsp;nested.
170</span></td>
171</tr><tr><td class="diff_header" id="from1_21">21</td><td nowrap="nowrap">123
172</td>
173<td class="diff_next"></td>
174<td class="diff_header" id="to1_21">21</td><td nowrap="nowrap">123
175</td>
176</tr><tr><td class="diff_header" id="from1_22">22</td><td nowrap="nowrap">123
177</td>
178<td class="diff_next"></td>
179<td class="diff_header" id="to1_22">22</td><td nowrap="nowrap">123
180</td>
181</tr><tr><td class="diff_header" id="from1_23">23</td><td nowrap="nowrap">123
182</td>
183<td class="diff_next"></td>
184<td class="diff_header" id="to1_23">23</td><td nowrap="nowrap">123
185</td>
186</tr><tr><td class="diff_header" id="from1_24">24</td><td nowrap="nowrap">123
187</td>
188<td class="diff_next"></td>
189<td class="diff_header" id="to1_24">24</td><td nowrap="nowrap">123
190</td>
191</tr><tr><td class="diff_header" id="from1_25">25</td><td nowrap="nowrap">123
192</td>
193<td class="diff_next"></td>
194<td class="diff_header" id="to1_25">25</td><td nowrap="nowrap">123
195</td>
196</tr><tr><td class="diff_header" id="from1_26">26</td><td nowrap="nowrap">123
197</td>
198<td class="diff_next"></td>
199<td class="diff_header" id="to1_26">26</td><td nowrap="nowrap">123
200</td>
201</tr><tr><td class="diff_header" id="from1_27">27</td><td nowrap="nowrap">123
202</td>
203<td class="diff_next" id="difflib_chg_to1__2"></td>
204<td class="diff_header" id="to1_27">27</td><td nowrap="nowrap">123
205</td>
206</tr><tr><td class="diff_header" id="from1_28">28</td><td nowrap="nowrap">123
207</td>
208<td class="diff_next"></td>
209<td class="diff_header" id="to1_28">28</td><td nowrap="nowrap">123
210</td>
211</tr><tr><td class="diff_header" id="from1_29">29</td><td nowrap="nowrap">123
212</td>
213<td class="diff_next"></td>
214<td class="diff_header" id="to1_29">29</td><td nowrap="nowrap">123
215</td>
216</tr><tr><td class="diff_header" id="from1_30">30</td><td nowrap="nowrap">123
217</td>
218<td class="diff_next"></td>
219<td class="diff_header" id="to1_30">30</td><td nowrap="nowrap">123
220</td>
221</tr><tr><td class="diff_header" id="from1_31">31</td><td nowrap="nowrap">
222</td>
223<td class="diff_next"></td>
224<td class="diff_header" id="to1_31">31</td><td nowrap="nowrap">
225</td>
226</tr><tr><td class="diff_header" id="from1_32">32</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">TT</span>er&nbsp;than&nbsp;ugly.
227</td>
228<td class="diff_next"><a href="#difflib_chg_to1__top">t</a></td>
229<td class="diff_header" id="to1_32">32</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">tt</span>er&nbsp;than&nbsp;ugly.
230</td>
231</tr><tr><td class="diff_header" id="from1_33">33</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;2.&nbsp;Explicit&nbsp;is&nbsp;better&nbsp;than&nbsp;implicit.
232</span></td>
233<td class="diff_next"></td>
234<td class="diff_header"></td><td nowrap="nowrap">
235</td>
236</tr><tr><td class="diff_header" id="from1_34">34</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
237</td>
238<td class="diff_next"></td>
239<td class="diff_header" id="to1_33">33</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.<span class="diff_add">&nbsp;&nbsp;</span>&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
240</td>
241</tr><tr><td class="diff_header" id="from1_35">35</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;4.&nbsp;Complex&nbsp;is&nbsp;better&nbsp;than&nbsp;complicated.
242</span></td>
243<td class="diff_next"></td>
244<td class="diff_header" id="to1_34">34</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;4.&nbsp;Complicated&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
245</span></td>
246</tr><tr><td class="diff_header"></td><td nowrap="nowrap">
247</td>
248<td class="diff_next"></td>
249<td class="diff_header" id="to1_35">35</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;5.&nbsp;Flat&nbsp;is&nbsp;better&nbsp;than&nbsp;nested.
250</span></td>
251</tr><tr><td class="diff_header" id="from1_36">36</td><td nowrap="nowrap">123
252</td>
253<td class="diff_next"></td>
254<td class="diff_header" id="to1_36">36</td><td nowrap="nowrap">123
255</td>
256</tr><tr><td class="diff_header" id="from1_37">37</td><td nowrap="nowrap">123
257</td>
258<td class="diff_next"></td>
259<td class="diff_header" id="to1_37">37</td><td nowrap="nowrap">123
260</td>
261</tr><tr><td class="diff_header" id="from1_38">38</td><td nowrap="nowrap">123
262</td>
263<td class="diff_next"></td>
264<td class="diff_header" id="to1_38">38</td><td nowrap="nowrap">123
265</td>
266</tr><tr><td class="diff_header" id="from1_39">39</td><td nowrap="nowrap">123
267</td>
268<td class="diff_next"></td>
269<td class="diff_header" id="to1_39">39</td><td nowrap="nowrap">123
270</td>
271</tr><tr><td class="diff_header" id="from1_40">40</td><td nowrap="nowrap">123
272</td>
273<td class="diff_next"></td>
274<td class="diff_header" id="to1_40">40</td><td nowrap="nowrap">123
275</td>
276</tr><tr><td class="diff_header" id="from1_41">41</td><td nowrap="nowrap">123
277</td>
278<td class="diff_next"></td>
279<td class="diff_header" id="to1_41">41</td><td nowrap="nowrap">123
280</td>
281</tr><tr><td class="diff_header" id="from1_42">42</td><td nowrap="nowrap">123
282</td>
283<td class="diff_next"></td>
284<td class="diff_header" id="to1_42">42</td><td nowrap="nowrap">123
285</td>
286</tr><tr><td class="diff_header" id="from1_43">43</td><td nowrap="nowrap">123
287</td>
288<td class="diff_next"></td>
289<td class="diff_header" id="to1_43">43</td><td nowrap="nowrap">123
290</td>
291</tr><tr><td class="diff_header" id="from1_44">44</td><td nowrap="nowrap">123
292</td>
293<td class="diff_next"></td>
294<td class="diff_header" id="to1_44">44</td><td nowrap="nowrap">123
295</td>
296</tr><tr><td class="diff_header" id="from1_45">45</td><td nowrap="nowrap">123
297</td>
298<td class="diff_next"></td>
299<td class="diff_header" id="to1_45">45</td><td nowrap="nowrap">123
300</td>
301</tr></tbody>
302        </table>
303        <table summary="Legends" style="font-family:Courier">
304            <tr> <th colspan="2"> Legends </th> </tr>
305            <tr> <td> <table border="" summary="Colors">
306                          <tr><th> Colors </th> </tr>
307                          <tr><td class="diff_add">&nbsp;Added&nbsp;</td></tr>
308                          <tr><td class="diff_chg">Changed</td> </tr>
309                          <tr><td class="diff_sub">Deleted</td> </tr>
310                      </table></td>
311                 <td> <table border="" summary="Links">
312                          <tr><th colspan="2"> Links </th> </tr>
313                          <tr><td>(f)irst change</td> </tr>
314                          <tr><td>(n)ext change</td> </tr>
315                          <tr><td>(t)op</td> </tr>
316                      </table></td> </tr>
317        </table>
318        </body>
319        </html>'''
320        
321patch914575_context_expectation = '''
322        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
323            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
324        <html>
325        <head>
326        <meta http-equiv="Content-Type" 
327              content="text/html; charset=ISO-8859-1" />
328        <title>Context Side by Side Difference</title>
329        <style type="text/css">
330        .diff_header {background-color:#e0e0e0}
331        td.diff_header {text-align:right}
332        .diff_next {background-color:#c0c0c0}
333        .diff_add {background-color:#aaffaa}
334        .diff_chg {background-color:#ffff77}
335        .diff_sub {background-color:#ffaaaa}
336        </style>
337        </head>
338        <body>
339        <h1>context</h1>
340        
341        <table summary="s_context" id="difflib_chg_to1__top" border="3" 
342               cellspacing="0" cellpadding="0" rules="groups" 
343               style="font-family:Courier">
344            <colgroup></colgroup> <colgroup></colgroup> <colgroup></colgroup> 
345            <colgroup></colgroup> <colgroup></colgroup>
346            <thead><tr><th colspan="2" class="diff_header">from</th><th class="diff_next"><br /></th><th colspan="2" class="diff_header">to</th></tr></thead><tbody><tr><td class="diff_header" id="from1_1">1</td><td nowrap="nowrap">
347</td>
348<td class="diff_next" id="difflib_chg_to1__0"><a href="#difflib_chg_to1__0">f</a></td>
349<td class="diff_header" id="to1_1">1</td><td nowrap="nowrap">
350</td>
351</tr><tr><td class="diff_header" id="from1_2">2</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">TT</span>er&nbsp;than&nbsp;ugly.
352</td>
353<td class="diff_next"><a href="#difflib_chg_to1__1">n</a></td>
354<td class="diff_header" id="to1_2">2</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">tt</span>er&nbsp;than&nbsp;ugly.
355</td>
356</tr><tr><td class="diff_header" id="from1_3">3</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;2.&nbsp;Explicit&nbsp;is&nbsp;better&nbsp;than&nbsp;implicit.
357</span></td>
358<td class="diff_next"></td>
359<td class="diff_header"></td><td nowrap="nowrap">
360</td>
361</tr><tr><td class="diff_header" id="from1_4">4</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
362</td>
363<td class="diff_next"></td>
364<td class="diff_header" id="to1_3">3</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.<span class="diff_add">&nbsp;&nbsp;</span>&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
365</td>
366</tr><tr><td class="diff_header" id="from1_5">5</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;4.&nbsp;Complex&nbsp;is&nbsp;better&nbsp;than&nbsp;complicated.
367</span></td>
368<td class="diff_next"></td>
369<td class="diff_header" id="to1_4">4</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;4.&nbsp;Complicated&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
370</span></td>
371</tr><tr><td class="diff_header"></td><td nowrap="nowrap">
372</td>
373<td class="diff_next"></td>
374<td class="diff_header" id="to1_5">5</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;5.&nbsp;Flat&nbsp;is&nbsp;better&nbsp;than&nbsp;nested.
375</span></td>
376</tr><tr><td class="diff_header" id="from1_6">6</td><td nowrap="nowrap">123
377</td>
378<td class="diff_next"></td>
379<td class="diff_header" id="to1_6">6</td><td nowrap="nowrap">123
380</td>
381</tr><tr><td class="diff_header" id="from1_7">7</td><td nowrap="nowrap">123
382</td>
383<td class="diff_next"></td>
384<td class="diff_header" id="to1_7">7</td><td nowrap="nowrap">123
385</td>
386</tr><tr><td class="diff_header" id="from1_8">8</td><td nowrap="nowrap">123
387</td>
388<td class="diff_next"></td>
389<td class="diff_header" id="to1_8">8</td><td nowrap="nowrap">123
390</td>
391</tr><tr><td class="diff_header" id="from1_9">9</td><td nowrap="nowrap">123
392</td>
393<td class="diff_next"></td>
394<td class="diff_header" id="to1_9">9</td><td nowrap="nowrap">123
395</td>
396</tr></tbody><tbody>
397<tr><td class="diff_header" id="from1_14">14</td><td nowrap="nowrap">123
398</td>
399<td class="diff_next" id="difflib_chg_to1__1"></td>
400<td class="diff_header" id="to1_14">14</td><td nowrap="nowrap">123
401</td>
402</tr><tr><td class="diff_header" id="from1_15">15</td><td nowrap="nowrap">123
403</td>
404<td class="diff_next"></td>
405<td class="diff_header" id="to1_15">15</td><td nowrap="nowrap">123
406</td>
407</tr><tr><td class="diff_header" id="from1_16">16</td><td nowrap="nowrap">
408</td>
409<td class="diff_next"></td>
410<td class="diff_header" id="to1_16">16</td><td nowrap="nowrap">
411</td>
412</tr><tr><td class="diff_header" id="from1_17">17</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">TT</span>er&nbsp;than&nbsp;ugly.
413</td>
414<td class="diff_next"><a href="#difflib_chg_to1__2">n</a></td>
415<td class="diff_header" id="to1_17">17</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">tt</span>er&nbsp;than&nbsp;ugly.
416</td>
417</tr><tr><td class="diff_header" id="from1_18">18</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;2.&nbsp;Explicit&nbsp;is&nbsp;better&nbsp;than&nbsp;implicit.
418</span></td>
419<td class="diff_next"></td>
420<td class="diff_header"></td><td nowrap="nowrap">
421</td>
422</tr><tr><td class="diff_header" id="from1_19">19</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
423</td>
424<td class="diff_next"></td>
425<td class="diff_header" id="to1_18">18</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.<span class="diff_add">&nbsp;&nbsp;</span>&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
426</td>
427</tr><tr><td class="diff_header" id="from1_20">20</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;4.&nbsp;Complex&nbsp;is&nbsp;better&nbsp;than&nbsp;complicated.
428</span></td>
429<td class="diff_next"></td>
430<td class="diff_header" id="to1_19">19</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;4.&nbsp;Complicated&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
431</span></td>
432</tr><tr><td class="diff_header"></td><td nowrap="nowrap">
433</td>
434<td class="diff_next"></td>
435<td class="diff_header" id="to1_20">20</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;5.&nbsp;Flat&nbsp;is&nbsp;better&nbsp;than&nbsp;nested.
436</span></td>
437</tr><tr><td class="diff_header" id="from1_21">21</td><td nowrap="nowrap">123
438</td>
439<td class="diff_next"></td>
440<td class="diff_header" id="to1_21">21</td><td nowrap="nowrap">123
441</td>
442</tr><tr><td class="diff_header" id="from1_22">22</td><td nowrap="nowrap">123
443</td>
444<td class="diff_next"></td>
445<td class="diff_header" id="to1_22">22</td><td nowrap="nowrap">123
446</td>
447</tr><tr><td class="diff_header" id="from1_23">23</td><td nowrap="nowrap">123
448</td>
449<td class="diff_next"></td>
450<td class="diff_header" id="to1_23">23</td><td nowrap="nowrap">123
451</td>
452</tr><tr><td class="diff_header" id="from1_24">24</td><td nowrap="nowrap">123
453</td>
454<td class="diff_next"></td>
455<td class="diff_header" id="to1_24">24</td><td nowrap="nowrap">123
456</td>
457</tr></tbody><tbody>
458<tr><td class="diff_header" id="from1_29">29</td><td nowrap="nowrap">123
459</td>
460<td class="diff_next" id="difflib_chg_to1__2"></td>
461<td class="diff_header" id="to1_29">29</td><td nowrap="nowrap">123
462</td>
463</tr><tr><td class="diff_header" id="from1_30">30</td><td nowrap="nowrap">123
464</td>
465<td class="diff_next"></td>
466<td class="diff_header" id="to1_30">30</td><td nowrap="nowrap">123
467</td>
468</tr><tr><td class="diff_header" id="from1_31">31</td><td nowrap="nowrap">
469</td>
470<td class="diff_next"></td>
471<td class="diff_header" id="to1_31">31</td><td nowrap="nowrap">
472</td>
473</tr><tr><td class="diff_header" id="from1_32">32</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">TT</span>er&nbsp;than&nbsp;ugly.
474</td>
475<td class="diff_next"><a href="#difflib_chg_to1__top">t</a></td>
476<td class="diff_header" id="to1_32">32</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;1.&nbsp;Beautiful&nbsp;is&nbsp;be<span class="diff_chg">tt</span>er&nbsp;than&nbsp;ugly.
477</td>
478</tr><tr><td class="diff_header" id="from1_33">33</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;2.&nbsp;Explicit&nbsp;is&nbsp;better&nbsp;than&nbsp;implicit.
479</span></td>
480<td class="diff_next"></td>
481<td class="diff_header"></td><td nowrap="nowrap">
482</td>
483</tr><tr><td class="diff_header" id="from1_34">34</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
484</td>
485<td class="diff_next"></td>
486<td class="diff_header" id="to1_33">33</td><td nowrap="nowrap">&nbsp;&nbsp;&nbsp;3.<span class="diff_add">&nbsp;&nbsp;</span>&nbsp;Simple&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
487</td>
488</tr><tr><td class="diff_header" id="from1_35">35</td><td nowrap="nowrap"><span class="diff_sub">&nbsp;&nbsp;&nbsp;4.&nbsp;Complex&nbsp;is&nbsp;better&nbsp;than&nbsp;complicated.
489</span></td>
490<td class="diff_next"></td>
491<td class="diff_header" id="to1_34">34</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;4.&nbsp;Complicated&nbsp;is&nbsp;better&nbsp;than&nbsp;complex.
492</span></td>
493</tr><tr><td class="diff_header"></td><td nowrap="nowrap">
494</td>
495<td class="diff_next"></td>
496<td class="diff_header" id="to1_35">35</td><td nowrap="nowrap"><span class="diff_add">&nbsp;&nbsp;&nbsp;5.&nbsp;Flat&nbsp;is&nbsp;better&nbsp;than&nbsp;nested.
497</span></td>
498</tr><tr><td class="diff_header" id="from1_36">36</td><td nowrap="nowrap">123
499</td>
500<td class="diff_next"></td>
501<td class="diff_header" id="to1_36">36</td><td nowrap="nowrap">123
502</td>
503</tr><tr><td class="diff_header" id="from1_37">37</td><td nowrap="nowrap">123
504</td>
505<td class="diff_next"></td>
506<td class="diff_header" id="to1_37">37</td><td nowrap="nowrap">123
507</td>
508</tr><tr><td class="diff_header" id="from1_38">38</td><td nowrap="nowrap">123
509</td>
510<td class="diff_next"></td>
511<td class="diff_header" id="to1_38">38</td><td nowrap="nowrap">123
512</td>
513</tr><tr><td class="diff_header" id="from1_39">39</td><td nowrap="nowrap">123
514</td>
515<td class="diff_next"></td>
516<td class="diff_header" id="to1_39">39</td><td nowrap="nowrap">123
517</td>
518</tr></tbody>
519        </table>
520        <table summary="Legends" style="font-family:Courier">
521            <tr> <th colspan="2"> Legends </th> </tr>
522            <tr> <td> <table border="" summary="Colors">
523                          <tr><th> Colors </th> </tr>
524                          <tr><td class="diff_add">&nbsp;Added&nbsp;</td></tr>
525                          <tr><td class="diff_chg">Changed</td> </tr>
526                          <tr><td class="diff_sub">Deleted</td> </tr>
527                      </table></td>
528                 <td> <table border="" summary="Links">
529                          <tr><th colspan="2"> Links </th> </tr>
530                          <tr><td>(f)irst change</td> </tr>
531                          <tr><td>(n)ext change</td> </tr>
532                          <tr><td>(t)op</td> </tr>
533                      </table></td> </tr>
534        </table>
535        </body>
536        </html>'''
537 
538class TestSFpatches(unittest.TestCase):
539 
540    def test_html_diff(self):
541        # Check SF patch 914575 for generating HTML differences
542        a = patch914575_from + '123\n'*10
543        a = a * 3
544        a = a.splitlines(1)
545        b = patch914575_to + '123\n'*10
546        b = b * 3
547        b = b.splitlines(1)
548        i = difflib.HtmlDiff(prefix=['from1_','to1_'])
549        full = i.make_file(a,b,'from','to',context=False,
550                  numlines=5,title='Full Side by Side Difference',header='<h2>full</h2>',summary='s_full')
551        context = i.make_file(a,b,'from','to',context=True,
552                  numlines=3,title='Context Side by Side Difference',header='<h1>context</h1>',summary='s_context')
553        # Save following two lines for baselining test
554        #open('full.html','w').write(full)
555        #open('context.html','w').write(context)
556                          
557        self.assertEqual(patch914575_full_expectation,full)
558        self.assertEqual(patch914575_context_expectation,context)
559 
22Doctests = doctest.DocTestSuite(difflib) 560Doctests = doctest.DocTestSuite(difflib)
23 561
24test_support.run_unittest(TestSFbugs, Doctests) t 562test_support.run_unittest(TestSFpatches, TestSFbugs, Doctests)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op