~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_delta.py

  • Committer: Vincent Ladeuil
  • Date: 2010-03-10 09:33:04 UTC
  • mto: (5082.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5083.
  • Revision ID: v.ladeuil+lp@free.fr-20100310093304-4245t4tazd4sxoav
Cleanup test from overly cautious checks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010, 2016 Canonical Ltd
 
1
# Copyright (C) 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
65
65
        reporter.report(file_id, (old_path, path), versioned_change, renamed,
66
66
            modified, exe_change, kind)
67
67
        if expected_lines is not None:
68
 
            self.assertEqualDiff('\n'.join(expected_lines), '\n'.join(result))
 
68
            for i in range(len(expected_lines)):
 
69
                self.assertEqualDiff(expected_lines[i], result[i])
69
70
        else:
70
71
            self.assertEqual([], result)
71
72
 
122
123
            renamed=False, modified='created', exe_change=False,
123
124
            kind=(None, 'file'), unversioned_filter=lambda x:True)
124
125
 
125
 
    def test_missing(self):
126
 
        self.assertReport('+!  missing.c', file_id=None, path='missing.c',
127
 
             old_path=None, versioned_change='added',
128
 
             renamed=False, modified='missing', exe_change=False,
129
 
             kind=(None, None))
130
 
 
131
126
    def test_view_filtering(self):
132
127
        # If a file in within the view, it should appear in the output
133
128
        expected_lines = [
226
221
 
227
222
    def show_string(self, delta, *args,  **kwargs):
228
223
        to_file = StringIO()
229
 
        _mod_delta.report_delta(to_file, delta, *args, **kwargs)
 
224
        delta.show(to_file, *args, **kwargs)
230
225
        return to_file.getvalue()
231
226
 
232
227
    def test_kind_change(self):
285
280
                                  ('branch/f2', '2\n'),
286
281
                                  ('branch/f3', '3\n'),
287
282
                                  ('branch/f4', '4\n'),
288
 
                                  ('branch/f5', '5\n'),
289
283
                                  ('branch/dir/',),
290
284
                                 ])
291
285
        wt.add(['f1', 'f2', 'f3', 'f4', 'dir'],
292
286
               ['f1-id', 'f2-id', 'f3-id', 'f4-id', 'dir-id'])
293
287
        wt.commit('commit one', rev_id='1')
294
288
 
295
 
        # TODO add rename,removed,etc. here?
296
 
        wt.add('f5')
297
 
        os.unlink('branch/f5')
298
 
 
299
289
        long_status = """added:
300
290
  dir/
301
291
  f1
302
292
  f2
303
293
  f3
304
294
  f4
305
 
missing:
306
 
  f5
307
295
"""
308
296
        short_status = """A  dir/
309
297
A  f1
310
298
A  f2
311
299
A  f3
312
300
A  f4
313
 
!  f5
314
301
"""
315
302
 
316
303
        repo = wt.branch.repository
320
307
    def test_delta_show_short_status_no_filter(self):
321
308
        d, long_status, short_status = self._get_delta()
322
309
        out = StringIO()
323
 
        _mod_delta.report_delta(out, d, short_status=True)
324
 
        self.assertEqual(short_status, out.getvalue())
 
310
        d.show(out, short_status=True)
 
311
        self.assertEquals(short_status, out.getvalue())
325
312
 
326
313
    def test_delta_show_long_status_no_filter(self):
327
314
        d, long_status, short_status = self._get_delta()
328
315
        out = StringIO()
329
 
        _mod_delta.report_delta(out, d, short_status=False)
330
 
        self.assertEqual(long_status, out.getvalue())
 
316
        d.show(out, short_status=False)
 
317
        self.assertEquals(long_status, out.getvalue())
331
318
 
332
319
    def test_delta_show_no_filter(self):
333
320
        d, long_status, short_status = self._get_delta()
334
321
        out = StringIO()
335
322
        def not_a_filter(path, file_id):
336
323
            return True
337
 
        _mod_delta.report_delta(out, d, short_status=True, filter=not_a_filter)
338
 
        self.assertEqual(short_status, out.getvalue())
 
324
        d.show(out, short_status=True, filter=not_a_filter)
 
325
        self.assertEquals(short_status, out.getvalue())
339
326
 
340
327
    def test_delta_show_short_status_single_file_filter(self):
341
328
        d, long_status, short_status = self._get_delta()
342
329
        out = StringIO()
343
330
        def only_f2(path, file_id):
344
331
            return path == 'f2'
345
 
        _mod_delta.report_delta(out, d, short_status=True, filter=only_f2)
346
 
        self.assertEqual("A  f2\n", out.getvalue())
 
332
        d.show(out, short_status=True, filter=only_f2)
 
333
        self.assertEquals("A  f2\n", out.getvalue())
347
334
 
348
335
    def test_delta_show_long_status_single_file_filter(self):
349
336
        d, long_status, short_status = self._get_delta()
350
337
        out = StringIO()
351
338
        def only_f2(path, file_id):
352
339
            return path == 'f2'
353
 
        _mod_delta.report_delta(out, d, short_status=False, filter=only_f2)
354
 
        self.assertEqual("added:\n  f2\n", out.getvalue())
 
340
        d.show(out, short_status=False, filter=only_f2)
 
341
        self.assertEquals("added:\n  f2\n", out.getvalue())
355
342
 
356
343
    def test_delta_show_short_status_single_file_id_filter(self):
357
344
        d, long_status, short_status = self._get_delta()
358
345
        out = StringIO()
359
346
        def only_f2_id(path, file_id):
360
347
            return file_id == 'f2-id'
361
 
        _mod_delta.report_delta(out, d, short_status=True, filter=only_f2_id)
362
 
        self.assertEqual("A  f2\n", out.getvalue())
 
348
        d.show(out, short_status=True, filter=only_f2_id)
 
349
        self.assertEquals("A  f2\n", out.getvalue())
363
350