/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_registry.py

  • Committer: Andrew Bennetts
  • Date: 2011-03-15 07:54:39 UTC
  • mfrom: (0.38.5 trunk)
  • mto: This revision was merged to the branch mainline in revision 5726.
  • Revision ID: andrew.bennetts@canonical.com-20110315075439-nzm293joz143cx0k
Merge bzr-changelog-merge plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2008-2011 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
20
20
import sys
21
21
 
22
22
from bzrlib import (
23
 
    errors,
 
23
    branch,
24
24
    osutils,
25
25
    registry,
26
26
    tests,
286
286
            '\n\n'
287
287
        )
288
288
 
 
289
    def test_lazy_import_registry_foo(self):
 
290
        a_registry = registry.Registry()
 
291
        a_registry.register_lazy('foo', 'bzrlib.branch', 'Branch')
 
292
        a_registry.register_lazy('bar', 'bzrlib.branch', 'Branch.hooks')
 
293
        self.assertEqual(branch.Branch, a_registry.get('foo'))
 
294
        self.assertEqual(branch.Branch.hooks, a_registry.get('bar'))
 
295
 
289
296
    def test_lazy_import_registry(self):
290
297
        plugin_name = self.create_simple_plugin()
291
298
        a_registry = registry.Registry()
331
338
        finally:
332
339
            sys.path.remove(plugin_path)
333
340
 
 
341
    def test_lazy_import_get_module(self):
 
342
        a_registry = registry.Registry()
 
343
        a_registry.register_lazy('obj', "bzrlib.tests.test_registry",
 
344
            'object1')
 
345
        self.assertEquals("bzrlib.tests.test_registry",
 
346
            a_registry._get_module("obj"))
 
347
 
 
348
    def test_normal_get_module(self):
 
349
        class AThing(object):
 
350
            """Something"""
 
351
        a_registry = registry.Registry()
 
352
        a_registry.register("obj", AThing())
 
353
        self.assertEquals("bzrlib.tests.test_registry",
 
354
            a_registry._get_module("obj"))