Back to index

python3.2  3.2.2
Public Member Functions
test.test_difflib.TestSFpatches Class Reference

List of all members.

Public Member Functions

def test_html_diff
def test_recursion_limit

Detailed Description

Definition at line 151 of file test_difflib.py.


Member Function Documentation

Definition at line 153 of file test_difflib.py.

00153 
00154     def test_html_diff(self):
00155         # Check SF patch 914575 for generating HTML differences
00156         f1a = ((patch914575_from1 + '123\n'*10)*3)
00157         t1a = (patch914575_to1 + '123\n'*10)*3
00158         f1b = '456\n'*10 + f1a
00159         t1b = '456\n'*10 + t1a
00160         f1a = f1a.splitlines()
00161         t1a = t1a.splitlines()
00162         f1b = f1b.splitlines()
00163         t1b = t1b.splitlines()
00164         f2 = patch914575_from2.splitlines()
00165         t2 = patch914575_to2.splitlines()
00166         f3 = patch914575_from3
00167         t3 = patch914575_to3
00168         i = difflib.HtmlDiff()
00169         j = difflib.HtmlDiff(tabsize=2)
00170         k = difflib.HtmlDiff(wrapcolumn=14)
00171 
00172         full = i.make_file(f1a,t1a,'from','to',context=False,numlines=5)
00173         tables = '\n'.join(
00174             [
00175              '<h2>Context (first diff within numlines=5(default))</h2>',
00176              i.make_table(f1a,t1a,'from','to',context=True),
00177              '<h2>Context (first diff after numlines=5(default))</h2>',
00178              i.make_table(f1b,t1b,'from','to',context=True),
00179              '<h2>Context (numlines=6)</h2>',
00180              i.make_table(f1a,t1a,'from','to',context=True,numlines=6),
00181              '<h2>Context (numlines=0)</h2>',
00182              i.make_table(f1a,t1a,'from','to',context=True,numlines=0),
00183              '<h2>Same Context</h2>',
00184              i.make_table(f1a,f1a,'from','to',context=True),
00185              '<h2>Same Full</h2>',
00186              i.make_table(f1a,f1a,'from','to',context=False),
00187              '<h2>Empty Context</h2>',
00188              i.make_table([],[],'from','to',context=True),
00189              '<h2>Empty Full</h2>',
00190              i.make_table([],[],'from','to',context=False),
00191              '<h2>tabsize=2</h2>',
00192              j.make_table(f2,t2),
00193              '<h2>tabsize=default</h2>',
00194              i.make_table(f2,t2),
00195              '<h2>Context (wrapcolumn=14,numlines=0)</h2>',
00196              k.make_table(f3.splitlines(),t3.splitlines(),context=True,numlines=0),
00197              '<h2>wrapcolumn=14,splitlines()</h2>',
00198              k.make_table(f3.splitlines(),t3.splitlines()),
00199              '<h2>wrapcolumn=14,splitlines(True)</h2>',
00200              k.make_table(f3.splitlines(True),t3.splitlines(True)),
00201              ])
00202         actual = full.replace('</body>','\n%s\n</body>' % tables)
00203 
00204         # temporarily uncomment next two lines to baseline this test
00205         #with open('test_difflib_expect.html','w') as fp:
00206         #    fp.write(actual)
00207 
00208         with open(findfile('test_difflib_expect.html')) as fp:
00209             self.assertEqual(actual, fp.read())

Here is the call graph for this function:

Definition at line 210 of file test_difflib.py.

00210 
00211     def test_recursion_limit(self):
00212         # Check if the problem described in patch #1413711 exists.
00213         limit = sys.getrecursionlimit()
00214         old = [(i%2 and "K:%d" or "V:A:%d") % i for i in range(limit*2)]
00215         new = [(i%2 and "K:%d" or "V:B:%d") % i for i in range(limit*2)]
00216         difflib.SequenceMatcher(None, old, new).get_opcodes()
00217 


The documentation for this class was generated from the following file: