~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_registry.py

(gz) Fix test failure on alpha by correcting format string for
 gc_chk_sha1_record (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
        a_registry = registry.Registry()
40
40
        self.register_stuff(a_registry)
41
41
 
42
 
        self.assertTrue(a_registry.default_key is None)
 
42
        self.failUnless(a_registry.default_key is None)
43
43
 
44
44
        # test get() (self.default_key is None)
45
45
        self.assertRaises(KeyError, a_registry.get)
49
49
 
50
50
        # test _set_default_key
51
51
        a_registry.default_key = 'five'
52
 
        self.assertTrue(a_registry.default_key == 'five')
 
52
        self.failUnless(a_registry.default_key == 'five')
53
53
        self.assertEqual(5, a_registry.get())
54
54
        self.assertEqual(5, a_registry.get(None))
55
55
        # If they ask for a specific entry, they should get KeyError
64
64
        a_registry = registry.Registry()
65
65
        self.register_stuff(a_registry)
66
66
 
67
 
        self.assertTrue('one' in a_registry)
 
67
        self.failUnless('one' in a_registry)
68
68
        a_registry.remove('one')
69
 
        self.assertFalse('one' in a_registry)
 
69
        self.failIf('one' in a_registry)
70
70
        self.assertRaises(KeyError, a_registry.get, 'one')
71
71
 
72
72
        a_registry.register('one', 'one')
215
215
        # We create a registry with "official" objects and "hidden"
216
216
        # objects. The later represent the side effects that led to bug #277048
217
217
        # and #430510
218
 
        _registry = registry.Registry()
 
218
        self.registry =  registry.Registry()
219
219
 
220
220
        def register_more():
221
 
           _registry.register('hidden', None)
 
221
            self.registry.register('hidden', None)
222
222
 
223
 
        # Avoid closing over self by binding local variable
224
 
        self.registry = _registry
225
223
        self.registry.register('passive', None)
226
224
        self.registry.register('active', register_more)
227
225
        self.registry.register('passive-too', None)
231
229
            def get_obj(inner_self):
232
230
                # Surprise ! Getting a registered object (think lazy loaded
233
231
                # module) register yet another object !
234
 
                _registry.register('more hidden', None)
 
232
                self.registry.register('more hidden', None)
235
233
                return inner_self._obj
236
234
 
237
235
        self.registry.register('hacky', None)
306
304
        self.assertEqual(['function', 'klass', 'module', 'obj'],
307
305
                         sorted(a_registry.keys()))
308
306
        # The plugin should not be loaded until we grab the first object
309
 
        self.assertFalse(plugin_name in sys.modules)
 
307
        self.failIf(plugin_name in sys.modules)
310
308
 
311
309
        # By default the plugin won't be in the search path
312
310
        self.assertRaises(ImportError, a_registry.get, 'obj')
316
314
        try:
317
315
            obj = a_registry.get('obj')
318
316
            self.assertEqual('foo', obj)
319
 
            self.assertTrue(plugin_name in sys.modules)
 
317
            self.failUnless(plugin_name in sys.modules)
320
318
 
321
319
            # Now grab another object
322
320
            func = a_registry.get('function')