/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: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2008-2012, 2016 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
19
19
import os
20
20
import sys
21
21
 
22
 
from breezy import (
 
22
from bzrlib import (
23
23
    branch,
24
24
    osutils,
25
25
    registry,
26
26
    tests,
27
27
    )
28
28
 
29
 
from ..sixish import viewitems
30
 
 
31
29
 
32
30
class TestRegistry(tests.TestCase):
33
31
 
203
201
        self.assertEqual('//baz/qux', suffix)
204
202
        self.assertIs(sftp_object, found_object)
205
203
 
206
 
    def test_registry_alias(self):
207
 
        a_registry = registry.Registry()
208
 
        a_registry.register('one', 1, info='string info')
209
 
        a_registry.register_alias('two', 'one')
210
 
        a_registry.register_alias('three', 'one', info='own info')
211
 
        self.assertEqual(a_registry.get('one'), a_registry.get('two'))
212
 
        self.assertEqual(a_registry.get_help('one'), a_registry.get_help('two'))
213
 
        self.assertEqual(a_registry.get_info('one'), a_registry.get_info('two'))
214
 
        self.assertEqual('own info', a_registry.get_info('three'))
215
 
        self.assertEqual({'two': 'one', 'three': 'one'}, a_registry.aliases())
216
 
        self.assertEqual({'one': ['three', 'two']},
217
 
                         {k: sorted(v) for (k, v) in viewitems(a_registry.alias_map())})
218
 
 
219
 
    def test_registry_alias_exists(self):
220
 
        a_registry = registry.Registry()
221
 
        a_registry.register('one', 1, info='string info')
222
 
        a_registry.register('two', 2)
223
 
        self.assertRaises(KeyError, a_registry.register_alias, 'one', 'one')
224
 
 
225
 
    def test_registry_alias_targetmissing(self):
226
 
        a_registry = registry.Registry()
227
 
        self.assertRaises(KeyError, a_registry.register_alias, 'one', 'two')
228
 
 
229
204
 
230
205
class TestRegistryIter(tests.TestCase):
231
206
    """Test registry iteration behaviors.
315
290
 
316
291
    def test_lazy_import_registry_foo(self):
317
292
        a_registry = registry.Registry()
318
 
        a_registry.register_lazy('foo', 'breezy.branch', 'Branch')
319
 
        a_registry.register_lazy('bar', 'breezy.branch', 'Branch.hooks')
 
293
        a_registry.register_lazy('foo', 'bzrlib.branch', 'Branch')
 
294
        a_registry.register_lazy('bar', 'bzrlib.branch', 'Branch.hooks')
320
295
        self.assertEqual(branch.Branch, a_registry.get('foo'))
321
296
        self.assertEqual(branch.Branch.hooks, a_registry.get('bar'))
322
297
 
336
311
        # By default the plugin won't be in the search path
337
312
        self.assertRaises(ImportError, a_registry.get, 'obj')
338
313
 
339
 
        plugin_path = self.test_dir + '/tmp'
 
314
        plugin_path = os.getcwd() + '/tmp'
340
315
        sys.path.append(plugin_path)
341
316
        try:
342
317
            obj = a_registry.get('obj')
367
342
 
368
343
    def test_lazy_import_get_module(self):
369
344
        a_registry = registry.Registry()
370
 
        a_registry.register_lazy('obj', "breezy.tests.test_registry",
 
345
        a_registry.register_lazy('obj', "bzrlib.tests.test_registry",
371
346
            'object1')
372
 
        self.assertEqual("breezy.tests.test_registry",
 
347
        self.assertEquals("bzrlib.tests.test_registry",
373
348
            a_registry._get_module("obj"))
374
349
 
375
350
    def test_normal_get_module(self):
377
352
            """Something"""
378
353
        a_registry = registry.Registry()
379
354
        a_registry.register("obj", AThing())
380
 
        self.assertEqual("breezy.tests.test_registry",
 
355
        self.assertEquals("bzrlib.tests.test_registry",
381
356
            a_registry._get_module("obj"))