|
@@ -135,22 +135,12 @@ class DiffMarkupTest(unittest.TestCase):
|
135
|
135
|
['header\n'], '--- old\n', '+++ new\n', [hunk])
|
136
|
136
|
return diff
|
137
|
137
|
|
138
|
|
- def test_markup_mix(self):
|
139
|
|
- marker = cdiff.DiffMarker()
|
140
|
|
- line = 'foo \x00-del\x01 \x00+add\x01 \x00^chg\x01 bar'
|
141
|
|
- base_color = 'red'
|
142
|
|
- self.assertEqual(
|
143
|
|
- marker._markup_mix(line, base_color),
|
144
|
|
- '\x1b[31mfoo \x1b[7m\x1b[31mdel\x1b[0m\x1b[31m '
|
145
|
|
- '\x1b[7m\x1b[31madd\x1b[0m\x1b[31m '
|
146
|
|
- '\x1b[4m\x1b[31mchg\x1b[0m\x1b[31m bar\x1b[0m')
|
147
|
|
-
|
148
|
138
|
def test_markup_traditional_hunk_header(self):
|
149
|
139
|
hunk = cdiff.Hunk(['hunk header\n'], '@@ -0 +0 @@\n', (0, 0), (0, 0))
|
150
|
140
|
diff = cdiff.UnifiedDiff([], '--- old\n', '+++ new\n', [hunk])
|
151
|
141
|
marker = cdiff.DiffMarker()
|
152
|
142
|
|
153
|
|
- out = list(marker._markup_traditional(diff))
|
|
143
|
+ out = list(marker.markup(diff))
|
154
|
144
|
self.assertEqual(len(out), 4)
|
155
|
145
|
|
156
|
146
|
self.assertEqual(out[0], '\x1b[33m--- old\n\x1b[0m')
|
|
@@ -164,7 +154,7 @@ class DiffMarkupTest(unittest.TestCase):
|
164
|
154
|
diff = cdiff.UnifiedDiff([], '--- old\n', '+++ new\n', [hunk])
|
165
|
155
|
marker = cdiff.DiffMarker()
|
166
|
156
|
|
167
|
|
- out = list(marker._markup_traditional(diff))
|
|
157
|
+ out = list(marker.markup(diff))
|
168
|
158
|
self.assertEqual(len(out), 4)
|
169
|
159
|
|
170
|
160
|
self.assertEqual(out[0], '\x1b[33m--- old\n\x1b[0m')
|
|
@@ -178,7 +168,7 @@ class DiffMarkupTest(unittest.TestCase):
|
178
|
168
|
diff = cdiff.UnifiedDiff([], '--- old\n', '+++ new\n', [hunk])
|
179
|
169
|
marker = cdiff.DiffMarker()
|
180
|
170
|
|
181
|
|
- out = list(marker._markup_traditional(diff))
|
|
171
|
+ out = list(marker.markup(diff))
|
182
|
172
|
self.assertEqual(len(out), 4)
|
183
|
173
|
|
184
|
174
|
self.assertEqual(out[0], '\x1b[33m--- old\n\x1b[0m')
|
|
@@ -194,7 +184,7 @@ class DiffMarkupTest(unittest.TestCase):
|
194
|
184
|
diff = cdiff.UnifiedDiff([], '--- old\n', '+++ new\n', [hunk])
|
195
|
185
|
marker = cdiff.DiffMarker()
|
196
|
186
|
|
197
|
|
- out = list(marker._markup_traditional(diff))
|
|
187
|
+ out = list(marker.markup(diff))
|
198
|
188
|
self.assertEqual(len(out), 6)
|
199
|
189
|
|
200
|
190
|
self.assertEqual(out[0], '\x1b[33m--- old\n\x1b[0m')
|
|
@@ -212,9 +202,9 @@ class DiffMarkupTest(unittest.TestCase):
|
212
|
202
|
|
213
|
203
|
def test_markup_side_by_side_padded(self):
|
214
|
204
|
diff = self._init_diff()
|
215
|
|
- marker = cdiff.DiffMarker()
|
|
205
|
+ marker = cdiff.DiffMarker(side_by_side=True, width=7)
|
216
|
206
|
|
217
|
|
- out = list(marker._markup_side_by_side(diff, 7, 8, False))
|
|
207
|
+ out = list(marker.markup(diff))
|
218
|
208
|
self.assertEqual(len(out), 11)
|
219
|
209
|
|
220
|
210
|
sys.stdout.write('\n')
|
|
@@ -266,8 +256,8 @@ class DiffMarkupTest(unittest.TestCase):
|
266
|
256
|
# This test is not valid anymore
|
267
|
257
|
def __test_markup_side_by_side_neg_width(self):
|
268
|
258
|
diff = self._init_diff()
|
269
|
|
- marker = cdiff.DiffMarker()
|
270
|
|
- out = list(marker._markup_side_by_side(diff, -1, 8, False))
|
|
259
|
+ marker = cdiff.DiffMarker(side_by_side=True, width=-1)
|
|
260
|
+ out = list(marker.markup(diff))
|
271
|
261
|
self.assertEqual(len(out), 11)
|
272
|
262
|
|
273
|
263
|
self.assertEqual(out[0], '\x1b[36mheader\n\x1b[0m')
|
|
@@ -310,8 +300,8 @@ class DiffMarkupTest(unittest.TestCase):
|
310
|
300
|
|
311
|
301
|
def test_markup_side_by_side_off_by_one(self):
|
312
|
302
|
diff = self._init_diff()
|
313
|
|
- marker = cdiff.DiffMarker()
|
314
|
|
- out = list(marker._markup_side_by_side(diff, 6, 8, False))
|
|
303
|
+ marker = cdiff.DiffMarker(side_by_side=True, width=6)
|
|
304
|
+ out = list(marker.markup(diff))
|
315
|
305
|
self.assertEqual(len(out), 11)
|
316
|
306
|
|
317
|
307
|
sys.stdout.write('\n')
|
|
@@ -361,8 +351,8 @@ class DiffMarkupTest(unittest.TestCase):
|
361
|
351
|
|
362
|
352
|
def test_markup_side_by_side_wrapped(self):
|
363
|
353
|
diff = self._init_diff()
|
364
|
|
- marker = cdiff.DiffMarker()
|
365
|
|
- out = list(marker._markup_side_by_side(diff, 5, 8, False))
|
|
354
|
+ marker = cdiff.DiffMarker(side_by_side=True, width=5)
|
|
355
|
+ out = list(marker.markup(diff))
|
366
|
356
|
self.assertEqual(len(out), 11)
|
367
|
357
|
|
368
|
358
|
sys.stdout.write('\n')
|
|
@@ -413,8 +403,8 @@ class DiffMarkupTest(unittest.TestCase):
|
413
|
403
|
|
414
|
404
|
def test_markup_side_by_side_tabbed(self):
|
415
|
405
|
diff = self._init_diff()
|
416
|
|
- marker = cdiff.DiffMarker()
|
417
|
|
- out = list(marker._markup_side_by_side(diff, 8, 2, False))
|
|
406
|
+ marker = cdiff.DiffMarker(side_by_side=True, width=8, tab_width=2)
|
|
407
|
+ out = list(marker.markup(diff))
|
418
|
408
|
self.assertEqual(len(out), 11)
|
419
|
409
|
|
420
|
410
|
sys.stdout.write('\n')
|