annotate Lib/test/test_difflib.py @ 38664:7619216bbc19 2.4

Bug #1502728: Correctly link against librt library on HP-UX. (backport from rev. 46743)
author Georg Brandl <georg@python.org>
date Thu, 08 Jun 2006 12:54:16 +0000
parents 787fff51bf2a
children 16bfe9386068
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24364
aa0d2d51fbde Get rid of relative imports in all unittests. Now anything that
Barry Warsaw <barry@python.org>
parents: 19817
diff changeset
1 import difflib
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
2 from test.test_support import run_unittest, findfile
29719
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
3 import unittest
29892
79ec7e302d53 Exercise Jim Fulton's new doctest extension for running doctests in a
Raymond Hettinger <python@rcn.com>
parents: 29719
diff changeset
4 import doctest
29719
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
5
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
6 class TestSFbugs(unittest.TestCase):
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
7
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
8 def test_ratio_for_null_seqn(self):
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
9 # Check clearing of SF bug 763023
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
10 s = difflib.SequenceMatcher(None, [], [])
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
11 self.assertEqual(s.ratio(), 1)
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
12 self.assertEqual(s.quick_ratio(), 1)
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
13 self.assertEqual(s.real_quick_ratio(), 1)
fa4cf878c538 Fix SF bug #763023, difflib.py: ratio() zero division not caught
Neal Norwitz <nnorwitz@gmail.com>
parents: 24364
diff changeset
14
32612
5546c7ae24f7 SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator
Brett Cannon <bcannon@gmail.com>
parents: 31389
diff changeset
15 def test_comparing_empty_lists(self):
5546c7ae24f7 SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator
Brett Cannon <bcannon@gmail.com>
parents: 31389
diff changeset
16 # Check fix for bug #979794
5546c7ae24f7 SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator
Brett Cannon <bcannon@gmail.com>
parents: 31389
diff changeset
17 group_gen = difflib.SequenceMatcher(None, [], []).get_grouped_opcodes()
5546c7ae24f7 SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator
Brett Cannon <bcannon@gmail.com>
parents: 31389
diff changeset
18 self.assertRaises(StopIteration, group_gen.next)
5546c7ae24f7 SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator
Brett Cannon <bcannon@gmail.com>
parents: 31389
diff changeset
19 diff_gen = difflib.unified_diff([], [])
5546c7ae24f7 SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator
Brett Cannon <bcannon@gmail.com>
parents: 31389
diff changeset
20 self.assertRaises(StopIteration, diff_gen.next)
5546c7ae24f7 SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator
Brett Cannon <bcannon@gmail.com>
parents: 31389
diff changeset
21
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
22 patch914575_from1 = """
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
23 1. Beautiful is beTTer than ugly.
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
24 2. Explicit is better than implicit.
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
25 3. Simple is better than complex.
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
26 4. Complex is better than complicated.
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
27 """
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
28
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
29 patch914575_to1 = """
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
30 1. Beautiful is better than ugly.
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
31 3. Simple is better than complex.
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
32 4. Complicated is better than complex.
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
33 5. Flat is better than nested.
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
34 """
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
35
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
36 patch914575_from2 = """
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
37 \t\tLine 1: preceeded by from:[tt] to:[ssss]
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
38 \t\tLine 2: preceeded by from:[sstt] to:[sssst]
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
39 \t \tLine 3: preceeded by from:[sstst] to:[ssssss]
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
40 Line 4: \thas from:[sst] to:[sss] after :
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
41 Line 5: has from:[t] to:[ss] at end\t
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
42 """
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
43
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
44 patch914575_to2 = """
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
45 Line 1: preceeded by from:[tt] to:[ssss]
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
46 \tLine 2: preceeded by from:[sstt] to:[sssst]
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
47 Line 3: preceeded by from:[sstst] to:[ssssss]
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
48 Line 4: has from:[sst] to:[sss] after :
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
49 Line 5: has from:[t] to:[ss] at end
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
50 """
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
51
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
52 patch914575_from3 = """line 0
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
53 1234567890123456789012345689012345
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
54 line 1
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
55 line 2
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
56 line 3
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
57 line 4 changed
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
58 line 5 changed
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
59 line 6 changed
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
60 line 7
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
61 line 8 subtracted
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
62 line 9
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
63 1234567890123456789012345689012345
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
64 short line
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
65 just fits in!!
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
66 just fits in two lines yup!!
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
67 the end"""
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
68
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
69 patch914575_to3 = """line 0
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
70 1234567890123456789012345689012345
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
71 line 1
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
72 line 2 added
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
73 line 3
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
74 line 4 chanGEd
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
75 line 5a chanGed
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
76 line 6a changEd
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
77 line 7
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
78 line 8
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
79 line 9
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
80 1234567890
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
81 another long line that needs to be wrapped
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
82 just fitS in!!
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
83 just fits in two lineS yup!!
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
84 the end"""
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
85
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
86 class TestSFpatches(unittest.TestCase):
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
87
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
88 def test_html_diff(self):
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
89 # Check SF patch 914575 for generating HTML differences
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
90 f1a = ((patch914575_from1 + '123\n'*10)*3)
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
91 t1a = (patch914575_to1 + '123\n'*10)*3
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
92 f1b = '456\n'*10 + f1a
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
93 t1b = '456\n'*10 + t1a
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
94 f1a = f1a.splitlines()
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
95 t1a = t1a.splitlines()
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
96 f1b = f1b.splitlines()
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
97 t1b = t1b.splitlines()
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
98 f2 = patch914575_from2.splitlines()
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
99 t2 = patch914575_to2.splitlines()
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
100 f3 = patch914575_from3
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
101 t3 = patch914575_to3
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
102 i = difflib.HtmlDiff()
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
103 j = difflib.HtmlDiff(tabsize=2)
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
104 k = difflib.HtmlDiff(wrapcolumn=14)
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
105
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
106 full = i.make_file(f1a,t1a,'from','to',context=False,numlines=5)
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
107 tables = '\n'.join(
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
108 [
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
109 '<h2>Context (first diff within numlines=5(default))</h2>',
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
110 i.make_table(f1a,t1a,'from','to',context=True),
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
111 '<h2>Context (first diff after numlines=5(default))</h2>',
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
112 i.make_table(f1b,t1b,'from','to',context=True),
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
113 '<h2>Context (numlines=6)</h2>',
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
114 i.make_table(f1a,t1a,'from','to',context=True,numlines=6),
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
115 '<h2>Context (numlines=0)</h2>',
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
116 i.make_table(f1a,t1a,'from','to',context=True,numlines=0),
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
117 '<h2>Same Context</h2>',
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
118 i.make_table(f1a,f1a,'from','to',context=True),
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
119 '<h2>Same Full</h2>',
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
120 i.make_table(f1a,f1a,'from','to',context=False),
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
121 '<h2>Empty Context</h2>',
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
122 i.make_table([],[],'from','to',context=True),
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
123 '<h2>Empty Full</h2>',
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
124 i.make_table([],[],'from','to',context=False),
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
125 '<h2>tabsize=2</h2>',
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
126 j.make_table(f2,t2),
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
127 '<h2>tabsize=default</h2>',
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
128 i.make_table(f2,t2),
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
129 '<h2>Context (wrapcolumn=14,numlines=0)</h2>',
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
130 k.make_table(f3.splitlines(),t3.splitlines(),context=True,numlines=0),
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
131 '<h2>wrapcolumn=14,splitlines()</h2>',
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
132 k.make_table(f3.splitlines(),t3.splitlines()),
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
133 '<h2>wrapcolumn=14,splitlines(True)</h2>',
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
134 k.make_table(f3.splitlines(True),t3.splitlines(True)),
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
135 ])
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
136 actual = full.replace('</body>','\n%s\n</body>' % tables)
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
137 # temporarily uncomment next three lines to baseline this test
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
138 #f = open('test_difflib_expect.html','w')
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
139 #f.write(actual)
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
140 #f.close()
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
141 expect = open(findfile('test_difflib_expect.html')).read()
33326
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
142
787fff51bf2a Whitespace normalization. test_difflib passes again.
Tim Peters <tim.peters@gmail.com>
parents: 33324
diff changeset
143
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
144 self.assertEqual(actual,expect)
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
145
29892
79ec7e302d53 Exercise Jim Fulton's new doctest extension for running doctests in a
Raymond Hettinger <python@rcn.com>
parents: 29719
diff changeset
146 Doctests = doctest.DocTestSuite(difflib)
79ec7e302d53 Exercise Jim Fulton's new doctest extension for running doctests in a
Raymond Hettinger <python@rcn.com>
parents: 29719
diff changeset
147
33319
6d3bdd19beeb Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
Martin v. Löwis <martin@v.loewis.de>
parents: 32612
diff changeset
148 run_unittest(TestSFpatches, TestSFbugs, Doctests)