Exemplo n.º 1
0
 def _loader(tree, dest, root, subdir, force_mtime, fileobj):
     func = pyutils.get_named_object(module, funcname)
     return func(tree,
                 dest,
                 root,
                 subdir,
                 force_mtime=force_mtime,
                 fileobj=fileobj)
Exemplo n.º 2
0
 def test_valid_lazy_hooks(self):
     # Make sure that all the registered lazy hooks are referring to existing
     # hook points which allow lazy registration.
     for key, callbacks in _mod_hooks._lazy_hooks.iteritems():
         (module_name, member_name, hook_name) = key
         obj = pyutils.get_named_object(module_name, member_name)
         self.assertEqual(obj._module, module_name)
         self.assertEqual(obj._member_name, member_name)
         self.assertTrue(hook_name in obj)
         self.assertIs(callbacks, obj[hook_name]._callbacks)
Exemplo n.º 3
0
 def test_valid_lazy_hooks(self):
     # Make sure that all the registered lazy hooks are referring to existing
     # hook points which allow lazy registration.
     for key, callbacks in _mod_hooks._lazy_hooks.iteritems():
         (module_name, member_name, hook_name) = key
         obj = pyutils.get_named_object(module_name, member_name)
         self.assertEquals(obj._module, module_name)
         self.assertEquals(obj._member_name, member_name)
         self.assertTrue(hook_name in obj)
         self.assertIs(callbacks, obj[hook_name]._callbacks)
Exemplo n.º 4
0
    def get_obj(self):
        """Get the referenced object.

        Upon first request, the object will be imported. Future requests will
        return the imported object.
        """
        if not self._imported:
            self._obj = get_named_object(self._module_name, self._member_name)
            self._imported = True
        return super(_LazyObjectGetter, self).get_obj()
Exemplo n.º 5
0
 def _ensure(self):
     if self._feature is None:
         from bzrlib import pyutils
         depr_msg = self._dep_version % ('%s.%s'
                                         % (self._module, self._name))
         use_msg = ' Use %s.%s instead.' % (self._replacement_module,
                                            self._replacement_name)
         symbol_versioning.warn(depr_msg + use_msg, DeprecationWarning,
                                stacklevel=5)
         # Import the new feature and use it as a replacement for the
         # deprecated one.
         self._feature = pyutils.get_named_object(
             self._replacement_module, self._replacement_name)
Exemplo n.º 6
0
 def test_dotted_module(self):
     self.assertIs(branch, get_named_object('bzrlib.branch'))
Exemplo n.º 7
0
 def test_module_only(self):
     import sys
     self.assertIs(sys, get_named_object('sys'))
Exemplo n.º 8
0
    def loadTestsFromModuleName(self, name):
        result = self.suiteClass()
        module = pyutils.get_named_object(name)

        result.addTests(self.loadTestsFromModule(module))
        return result
Exemplo n.º 9
0
 def test_package_attr(self):
     # bzrlib.tests is a package, not simply a module
     self.assertIs(tests.TestCase,
                   get_named_object('bzrlib.tests', 'TestCase'))
Exemplo n.º 10
0
def default_test_list():
    """Generate the default list of interrepo permutations to test."""
    from bzrlib.repofmt import (
        groupcompress_repo,
        knitrepo,
        knitpack_repo,
    )
    result = []

    def add_combo(interrepo_cls,
                  from_format,
                  to_format,
                  extra_setup=None,
                  label=None):
        if label is None:
            label = interrepo_cls.__name__
        result.append((label, from_format, to_format, extra_setup))

    # test the default InterRepository between format 6 and the current
    # default format.
    # XXX: robertc 20060220 reinstate this when there are two supported
    # formats which do not have an optimal code path between them.
    #result.append((InterRepository,
    #               RepositoryFormat6(),
    #               RepositoryFormatKnit1()))
    for optimiser_class in InterRepository._optimisers:
        format_to_test = optimiser_class._get_repo_format_to_test()
        if format_to_test is not None:
            add_combo(optimiser_class, format_to_test, format_to_test)
    # if there are specific combinations we want to use, we can add them
    # here. We want to test rich root upgrading.
    # XXX: although we attach InterRepository class names to these scenarios,
    # there's nothing asserting that these labels correspond to what is
    # actually used.
    def force_known_graph(testcase):
        from bzrlib.fetch import Inter1and2Helper
        testcase.overrideAttr(Inter1and2Helper, 'known_graph_threshold', -1)

    # Gather extra scenarios from the repository implementations,
    # as InterRepositories can be used by Repository implementations
    # they aren't aware of.
    for module_name in format_registry._get_all_modules():
        module = pyutils.get_named_object(module_name)
        try:
            get_extra_interrepo_test_combinations = getattr(
                module, "get_extra_interrepo_test_combinations")
        except AttributeError:
            continue
        for (interrepo_cls, from_format,
             to_format) in (get_extra_interrepo_test_combinations()):
            add_combo(interrepo_cls, from_format, to_format)
    add_combo(InterRepository, knitrepo.RepositoryFormatKnit1(),
              knitrepo.RepositoryFormatKnit3())
    add_combo(knitrepo.InterKnitRepo, knitrepo.RepositoryFormatKnit1(),
              knitpack_repo.RepositoryFormatKnitPack1())
    add_combo(knitrepo.InterKnitRepo,
              knitpack_repo.RepositoryFormatKnitPack1(),
              knitrepo.RepositoryFormatKnit1())
    add_combo(knitrepo.InterKnitRepo, knitrepo.RepositoryFormatKnit3(),
              knitpack_repo.RepositoryFormatKnitPack3())
    add_combo(knitrepo.InterKnitRepo,
              knitpack_repo.RepositoryFormatKnitPack3(),
              knitrepo.RepositoryFormatKnit3())
    add_combo(knitrepo.InterKnitRepo,
              knitpack_repo.RepositoryFormatKnitPack3(),
              knitpack_repo.RepositoryFormatKnitPack4())
    add_combo(InterDifferingSerializer,
              knitpack_repo.RepositoryFormatKnitPack1(),
              knitpack_repo.RepositoryFormatKnitPack6RichRoot())
    add_combo(InterDifferingSerializer,
              knitpack_repo.RepositoryFormatKnitPack1(),
              knitpack_repo.RepositoryFormatKnitPack6RichRoot(),
              force_known_graph,
              label='InterDifferingSerializer+get_known_graph_ancestry')
    add_combo(InterDifferingSerializer,
              knitpack_repo.RepositoryFormatKnitPack6RichRoot(),
              groupcompress_repo.RepositoryFormat2a())
    add_combo(InterDifferingSerializer,
              groupcompress_repo.RepositoryFormat2a(),
              knitpack_repo.RepositoryFormatKnitPack6RichRoot())
    return result
Exemplo n.º 11
0
 def test_package(self):
     # bzrlib.tests is a package, not simply a module
     self.assertIs(tests, get_named_object('bzrlib.tests'))
Exemplo n.º 12
0
 def test_dotted_module(self):
     self.assertIs(branch, get_named_object('bzrlib.branch'))
Exemplo n.º 13
0
 def test_module_only(self):
     import sys
     self.assertIs(sys, get_named_object('sys'))
Exemplo n.º 14
0
def default_test_list():
    """Generate the default list of interrepo permutations to test."""
    from bzrlib.repofmt import (
        groupcompress_repo,
        knitrepo,
        knitpack_repo,
        )
    result = []
    def add_combo(interrepo_cls, from_format, to_format, extra_setup=None,
                  label=None):
        if label is None:
            label = interrepo_cls.__name__
        result.append((label, from_format, to_format, extra_setup))
    # test the default InterRepository between format 6 and the current
    # default format.
    # XXX: robertc 20060220 reinstate this when there are two supported
    # formats which do not have an optimal code path between them.
    #result.append((InterRepository,
    #               RepositoryFormat6(),
    #               RepositoryFormatKnit1()))
    for optimiser_class in InterRepository._optimisers:
        format_to_test = optimiser_class._get_repo_format_to_test()
        if format_to_test is not None:
            add_combo(optimiser_class, format_to_test, format_to_test)
    # if there are specific combinations we want to use, we can add them
    # here. We want to test rich root upgrading.
    # XXX: although we attach InterRepository class names to these scenarios,
    # there's nothing asserting that these labels correspond to what is
    # actually used.
    def force_known_graph(testcase):
        from bzrlib.fetch import Inter1and2Helper
        testcase.overrideAttr(Inter1and2Helper, 'known_graph_threshold', -1)
    # Gather extra scenarios from the repository implementations,
    # as InterRepositories can be used by Repository implementations
    # they aren't aware of.
    for module_name in format_registry._get_all_modules():
        module = pyutils.get_named_object(module_name)
        try:
            get_extra_interrepo_test_combinations = getattr(
                module,
                "get_extra_interrepo_test_combinations")
        except AttributeError:
            continue
        for (interrepo_cls, from_format, to_format) in (
            get_extra_interrepo_test_combinations()):
            add_combo(interrepo_cls, from_format, to_format)
    add_combo(InterRepository,
              knitrepo.RepositoryFormatKnit1(),
              knitrepo.RepositoryFormatKnit3())
    add_combo(knitrepo.InterKnitRepo,
              knitrepo.RepositoryFormatKnit1(),
              knitpack_repo.RepositoryFormatKnitPack1())
    add_combo(knitrepo.InterKnitRepo,
              knitpack_repo.RepositoryFormatKnitPack1(),
              knitrepo.RepositoryFormatKnit1())
    add_combo(knitrepo.InterKnitRepo,
              knitrepo.RepositoryFormatKnit3(),
              knitpack_repo.RepositoryFormatKnitPack3())
    add_combo(knitrepo.InterKnitRepo,
              knitpack_repo.RepositoryFormatKnitPack3(),
              knitrepo.RepositoryFormatKnit3())
    add_combo(knitrepo.InterKnitRepo,
              knitpack_repo.RepositoryFormatKnitPack3(),
              knitpack_repo.RepositoryFormatKnitPack4())
    add_combo(InterDifferingSerializer,
              knitpack_repo.RepositoryFormatKnitPack1(),
              knitpack_repo.RepositoryFormatKnitPack6RichRoot())
    add_combo(InterDifferingSerializer,
              knitpack_repo.RepositoryFormatKnitPack1(),
              knitpack_repo.RepositoryFormatKnitPack6RichRoot(),
              force_known_graph,
              label='InterDifferingSerializer+get_known_graph_ancestry')
    add_combo(InterDifferingSerializer,
              knitpack_repo.RepositoryFormatKnitPack6RichRoot(),
              groupcompress_repo.RepositoryFormat2a())
    add_combo(InterDifferingSerializer,
              groupcompress_repo.RepositoryFormat2a(),
              knitpack_repo.RepositoryFormatKnitPack6RichRoot())
    return result
Exemplo n.º 15
0
 def _loader(version):
     klass = pyutils.get_named_object(module, classname)
     return klass(version)
Exemplo n.º 16
0
 def test_module_attr(self):
     self.assertIs(
         branch.Branch, get_named_object('bzrlib.branch', 'Branch'))
Exemplo n.º 17
0
 def test_dotted_attr(self):
     self.assertIs(
         branch.Branch.hooks,
         get_named_object('bzrlib.branch', 'Branch.hooks'))
Exemplo n.º 18
0
 def test_module_attr(self):
     self.assertIs(branch.Branch, get_named_object('bzrlib.branch',
                                                   'Branch'))
Exemplo n.º 19
0
 def test_package_attr(self):
     # bzrlib.tests is a package, not simply a module
     self.assertIs(
         tests.TestCase, get_named_object('bzrlib.tests', 'TestCase'))
Exemplo n.º 20
0
 def test_dotted_attr(self):
     self.assertIs(branch.Branch.hooks,
                   get_named_object('bzrlib.branch', 'Branch.hooks'))
Exemplo n.º 21
0
 def test_package(self):
     # bzrlib.tests is a package, not simply a module
     self.assertIs(tests, get_named_object('bzrlib.tests'))
Exemplo n.º 22
0
 def _loader(tree, dest, root, subdir, force_mtime, fileobj):
     func = pyutils.get_named_object(module, funcname)
     return func(tree, dest, root, subdir, force_mtime=force_mtime,
         fileobj=fileobj)