diff options
author | Daniel Rocco <drocco@thebrightlink.com> | 2013-06-30 08:52:14 -0400 |
---|---|---|
committer | Daniel Rocco <drocco@thebrightlink.com> | 2013-11-23 23:12:46 -0500 |
commit | acaf47782e25b1a4eb6056e72034335d03e00e3b (patch) | |
tree | 9953b7d95fe6302ff502ee6294d94e3ee2792b71 /stevedore/hook.py | |
parent | fdde242a8ebf655e3bc81d753dc9d8b9869ed29e (diff) | |
download | stevedore-acaf47782e25b1a4eb6056e72034335d03e00e3b.tar.gz |
add test instance factory for the base, named, and hook managers
The class method make_test_instance constructs manager instances using a
predefined list of extensions, rather than loading from entry points.
Diffstat (limited to 'stevedore/hook.py')
-rw-r--r-- | stevedore/hook.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/stevedore/hook.py b/stevedore/hook.py index c1cec7f..29f845a 100644 --- a/stevedore/hook.py +++ b/stevedore/hook.py @@ -32,6 +32,30 @@ class HookManager(NamedExtensionManager): invoke_kwds=invoke_kwds, ) + @classmethod + def make_test_instance(cls, available_extensions, name): + """Construct a test HookManager + + Test instances are passed a list of extensions to work from rather + than loading them from entry points, filtering the available + extensions to only those extensions whose name matches the name + argument. + + :param available_extensions: Pre-configured Extension instances + available for use + :type available_extensions: list of + :class:`~stevedore.extension.Extension` + :param name: The name of the hooks to use. + :type name: str + :return: The manager instance, initialized for testing + + """ + + o = super(HookManager, cls).make_test_instance(available_extensions, + [name]) + o._name = name + return o + def __getitem__(self, name): """Return the named extensions. |