manager.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  2. # not use this file except in compliance with the License. You may obtain
  3. # a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  10. # License for the specific language governing permissions and limitations
  11. # under the License.
  12. """TestExtensionManager
  13. Extension manager used only for testing.
  14. """
  15. import warnings
  16. from stevedore import extension
  17. class TestExtensionManager(extension.ExtensionManager):
  18. """ExtensionManager that is explicitly initialized for tests.
  19. .. deprecated:: 0.13
  20. Use the :func:`make_test_instance` class method of the class
  21. being replaced by the test instance instead of using this class
  22. directly.
  23. :param extensions: Pre-configured Extension instances to use
  24. instead of loading them from entry points.
  25. :type extensions: list of :class:`~stevedore.extension.Extension`
  26. :param namespace: The namespace for the entry points.
  27. :type namespace: str
  28. :param invoke_on_load: Boolean controlling whether to invoke the
  29. object returned by the entry point after the driver is loaded.
  30. :type invoke_on_load: bool
  31. :param invoke_args: Positional arguments to pass when invoking
  32. the object returned by the entry point. Only used if invoke_on_load
  33. is True.
  34. :type invoke_args: tuple
  35. :param invoke_kwds: Named arguments to pass when invoking
  36. the object returned by the entry point. Only used if invoke_on_load
  37. is True.
  38. :type invoke_kwds: dict
  39. """
  40. def __init__(self, extensions,
  41. namespace='test',
  42. invoke_on_load=False,
  43. invoke_args=(),
  44. invoke_kwds={}):
  45. super(TestExtensionManager, self).__init__(namespace,
  46. invoke_on_load,
  47. invoke_args,
  48. invoke_kwds,
  49. )
  50. self.extensions = extensions
  51. warnings.warn(
  52. 'TestExtesionManager has been replaced by make_test_instance()',
  53. DeprecationWarning)
  54. def _load_plugins(self, *args, **kwds):
  55. return []