/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_delta.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 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
221
221
 
222
222
    def show_string(self, delta, *args,  **kwargs):
223
223
        to_file = StringIO()
224
 
        _mod_delta.report_delta(to_file, delta, *args, **kwargs)
 
224
        delta.show(to_file, *args, **kwargs)
225
225
        return to_file.getvalue()
226
226
 
227
227
    def test_kind_change(self):
307
307
    def test_delta_show_short_status_no_filter(self):
308
308
        d, long_status, short_status = self._get_delta()
309
309
        out = StringIO()
310
 
        _mod_delta.report_delta(out, d, short_status=True)
 
310
        d.show(out, short_status=True)
311
311
        self.assertEquals(short_status, out.getvalue())
312
312
 
313
313
    def test_delta_show_long_status_no_filter(self):
314
314
        d, long_status, short_status = self._get_delta()
315
315
        out = StringIO()
316
 
        _mod_delta.report_delta(out, d, short_status=False)
 
316
        d.show(out, short_status=False)
317
317
        self.assertEquals(long_status, out.getvalue())
318
318
 
319
319
    def test_delta_show_no_filter(self):
321
321
        out = StringIO()
322
322
        def not_a_filter(path, file_id):
323
323
            return True
324
 
        _mod_delta.report_delta(out, d, short_status=True, filter=not_a_filter)
 
324
        d.show(out, short_status=True, filter=not_a_filter)
325
325
        self.assertEquals(short_status, out.getvalue())
326
326
 
327
327
    def test_delta_show_short_status_single_file_filter(self):
329
329
        out = StringIO()
330
330
        def only_f2(path, file_id):
331
331
            return path == 'f2'
332
 
        _mod_delta.report_delta(out, d, short_status=True, filter=only_f2)
 
332
        d.show(out, short_status=True, filter=only_f2)
333
333
        self.assertEquals("A  f2\n", out.getvalue())
334
334
 
335
335
    def test_delta_show_long_status_single_file_filter(self):
337
337
        out = StringIO()
338
338
        def only_f2(path, file_id):
339
339
            return path == 'f2'
340
 
        _mod_delta.report_delta(out, d, short_status=False, filter=only_f2)
 
340
        d.show(out, short_status=False, filter=only_f2)
341
341
        self.assertEquals("added:\n  f2\n", out.getvalue())
342
342
 
343
343
    def test_delta_show_short_status_single_file_id_filter(self):
345
345
        out = StringIO()
346
346
        def only_f2_id(path, file_id):
347
347
            return file_id == 'f2-id'
348
 
        _mod_delta.report_delta(out, d, short_status=True, filter=only_f2_id)
 
348
        d.show(out, short_status=True, filter=only_f2_id)
349
349
        self.assertEquals("A  f2\n", out.getvalue())
350
350