~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-06 17:15:20 UTC
  • mfrom: (3922.1.5 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090106171520-9pzjoqa7m74hvhht
(Adeodato Simo) Update patience_diff.unified_diff so that it doesn't
        add trailing whitespace when you don't supply datestamps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1083
1083
                 'how are you today?\n']
1084
1084
        unified_diff = bzrlib.patiencediff.unified_diff
1085
1085
        psm = self._PatienceSequenceMatcher
1086
 
        self.assertEquals([ '---  \n',
1087
 
                           '+++  \n',
 
1086
        self.assertEquals(['--- \n',
 
1087
                           '+++ \n',
1088
1088
                           '@@ -1,3 +1,2 @@\n',
1089
1089
                           ' hello there\n',
1090
1090
                           '-world\n',
1095
1095
        txt_a = map(lambda x: x+'\n', 'abcdefghijklmnop')
1096
1096
        txt_b = map(lambda x: x+'\n', 'abcdefxydefghijklmnop')
1097
1097
        # This is the result with LongestCommonSubstring matching
1098
 
        self.assertEquals(['---  \n',
1099
 
                           '+++  \n',
 
1098
        self.assertEquals(['--- \n',
 
1099
                           '+++ \n',
1100
1100
                           '@@ -1,6 +1,11 @@\n',
1101
1101
                           ' a\n',
1102
1102
                           ' b\n',
1111
1111
                           ' f\n']
1112
1112
                          , list(unified_diff(txt_a, txt_b)))
1113
1113
        # And the patience diff
1114
 
        self.assertEquals(['---  \n',
1115
 
                           '+++  \n',
 
1114
        self.assertEquals(['--- \n',
 
1115
                           '+++ \n',
1116
1116
                           '@@ -4,6 +4,11 @@\n',
1117
1117
                           ' d\n',
1118
1118
                           ' e\n',
1129
1129
                          , list(unified_diff(txt_a, txt_b,
1130
1130
                                 sequencematcher=psm)))
1131
1131
 
 
1132
    def test_patience_unified_diff_with_dates(self):
 
1133
        txt_a = ['hello there\n',
 
1134
                 'world\n',
 
1135
                 'how are you today?\n']
 
1136
        txt_b = ['hello there\n',
 
1137
                 'how are you today?\n']
 
1138
        unified_diff = bzrlib.patiencediff.unified_diff
 
1139
        psm = self._PatienceSequenceMatcher
 
1140
        self.assertEquals(['--- a\t2008-08-08\n',
 
1141
                           '+++ b\t2008-09-09\n',
 
1142
                           '@@ -1,3 +1,2 @@\n',
 
1143
                           ' hello there\n',
 
1144
                           '-world\n',
 
1145
                           ' how are you today?\n'
 
1146
                          ]
 
1147
                          , list(unified_diff(txt_a, txt_b,
 
1148
                                 fromfile='a', tofile='b',
 
1149
                                 fromfiledate='2008-08-08',
 
1150
                                 tofiledate='2008-09-09',
 
1151
                                 sequencematcher=psm)))
 
1152
 
1132
1153
 
1133
1154
class TestPatienceDiffLib_c(TestPatienceDiffLib):
1134
1155
 
1174
1195
 
1175
1196
        unified_diff_files = bzrlib.patiencediff.unified_diff_files
1176
1197
        psm = self._PatienceSequenceMatcher
1177
 
        self.assertEquals(['--- a1 \n',
1178
 
                           '+++ b1 \n',
 
1198
        self.assertEquals(['--- a1\n',
 
1199
                           '+++ b1\n',
1179
1200
                           '@@ -1,3 +1,2 @@\n',
1180
1201
                           ' hello there\n',
1181
1202
                           '-world\n',
1190
1211
        open('b2', 'wb').writelines(txt_b)
1191
1212
 
1192
1213
        # This is the result with LongestCommonSubstring matching
1193
 
        self.assertEquals(['--- a2 \n',
1194
 
                           '+++ b2 \n',
 
1214
        self.assertEquals(['--- a2\n',
 
1215
                           '+++ b2\n',
1195
1216
                           '@@ -1,6 +1,11 @@\n',
1196
1217
                           ' a\n',
1197
1218
                           ' b\n',
1207
1228
                          , list(unified_diff_files('a2', 'b2')))
1208
1229
 
1209
1230
        # And the patience diff
1210
 
        self.assertEquals(['--- a2 \n',
1211
 
                           '+++ b2 \n',
 
1231
        self.assertEquals(['--- a2\n',
 
1232
                           '+++ b2\n',
1212
1233
                           '@@ -4,6 +4,11 @@\n',
1213
1234
                           ' d\n',
1214
1235
                           ' e\n',