~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__groupcompress.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:
32
32
    scenarios = [
33
33
        ('python', {'_gc_module': _groupcompress_py}),
34
34
        ]
35
 
    if CompiledGroupCompressFeature.available():
36
 
        from bzrlib import _groupcompress_pyx
 
35
    if compiled_groupcompress_feature.available():
 
36
        gc_module = compiled_groupcompress_feature.module
37
37
        scenarios.append(('C',
38
 
            {'_gc_module': _groupcompress_pyx}))
 
38
            {'_gc_module': gc_module}))
39
39
        two_way_scenarios.extend([
40
 
            ('CC', {'make_delta': _groupcompress_pyx.make_delta,
41
 
                    'apply_delta': _groupcompress_pyx.apply_delta}),
 
40
            ('CC', {'make_delta': gc_module.make_delta,
 
41
                    'apply_delta': gc_module.apply_delta}),
42
42
            ('PC', {'make_delta': _groupcompress_py.make_delta,
43
 
                    'apply_delta': _groupcompress_pyx.apply_delta}),
44
 
            ('CP', {'make_delta': _groupcompress_pyx.make_delta,
 
43
                    'apply_delta': gc_module.apply_delta}),
 
44
            ('CP', {'make_delta': gc_module.make_delta,
45
45
                    'apply_delta': _groupcompress_py.apply_delta}),
46
46
            ])
47
47
    to_adapt, result = tests.split_suite_by_condition(
54
54
    return result
55
55
 
56
56
 
57
 
class _CompiledGroupCompressFeature(tests.Feature):
58
 
 
59
 
    def _probe(self):
60
 
        try:
61
 
            import bzrlib._groupcompress_pyx
62
 
        except ImportError:
63
 
            return False
64
 
        else:
65
 
            return True
66
 
 
67
 
    def feature_name(self):
68
 
        return 'bzrlib._groupcompress_pyx'
69
 
 
70
 
 
71
 
CompiledGroupCompressFeature = _CompiledGroupCompressFeature()
 
57
compiled_groupcompress_feature = tests.ModuleAvailableFeature(
 
58
                                    'bzrlib._groupcompress_pyx')
72
59
 
73
60
_text1 = """\
74
61
This is a bit
264
251
        # This test isn't multiplied, because we only have DeltaIndex for the
265
252
        # compiled form
266
253
        # We call this here, because _test_needs_features happens after setUp
267
 
        self.requireFeature(CompiledGroupCompressFeature)
268
 
        from bzrlib import _groupcompress_pyx
269
 
        self._gc_module = _groupcompress_pyx
 
254
        self.requireFeature(compiled_groupcompress_feature)
 
255
        self._gc_module = compiled_groupcompress_feature.module
270
256
 
271
257
    def test_repr(self):
272
258
        di = self._gc_module.DeltaIndex('test text\n')