Example #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)
 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)
Example #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)
Example #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()
Example #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)
Example #6
0
 def test_dotted_module(self):
     self.assertIs(branch, get_named_object('bzrlib.branch'))
Example #7
0
 def test_module_only(self):
     import sys
     self.assertIs(sys, get_named_object('sys'))
Example #8
0
    def loadTestsFromModuleName(self, name):
        result = self.suiteClass()
        module = pyutils.get_named_object(name)

        result.addTests(self.loadTestsFromModule(module))
        return result
Example #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'))
Example #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
Example #11
0
 def test_package(self):
     # bzrlib.tests is a package, not simply a module
     self.assertIs(tests, get_named_object('bzrlib.tests'))
Example #12
0
 def test_dotted_module(self):
     self.assertIs(branch, get_named_object('bzrlib.branch'))
Example #13
0
 def test_module_only(self):
     import sys
     self.assertIs(sys, get_named_object('sys'))
Example #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
Example #15
0
 def _loader(version):
     klass = pyutils.get_named_object(module, classname)
     return klass(version)
Example #16
0
 def test_module_attr(self):
     self.assertIs(
         branch.Branch, get_named_object('bzrlib.branch', 'Branch'))
Example #17
0
 def test_dotted_attr(self):
     self.assertIs(
         branch.Branch.hooks,
         get_named_object('bzrlib.branch', 'Branch.hooks'))
Example #18
0
 def test_module_attr(self):
     self.assertIs(branch.Branch, get_named_object('bzrlib.branch',
                                                   'Branch'))
Example #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'))
Example #20
0
 def test_dotted_attr(self):
     self.assertIs(branch.Branch.hooks,
                   get_named_object('bzrlib.branch', 'Branch.hooks'))
Example #21
0
 def test_package(self):
     # bzrlib.tests is a package, not simply a module
     self.assertIs(tests, get_named_object('bzrlib.tests'))
Example #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)