Fix doc generation for contrib resources

Since we shouldn't require contrib resources to be installed in order to
generate documentation, this adds an exception to the plugin loader so
that it doesn't try to load the setup.py files that can be found inside
each plugin directory inside contrib/

Closes-Bug: 1403897
Change-Id: Id6ece4379599925dd17d22cef401c8d667a0ac51
This commit is contained in:
Anderson Mesquita 2014-12-18 08:45:51 -05:00
parent caf6a1b060
commit 4d522fa551
2 changed files with 14 additions and 3 deletions

View File

@ -88,9 +88,9 @@ def load_modules(package, ignore_error=False):
for importer, module_name, is_package in pkgutil.walk_packages(path,
pkg_prefix):
# NOTE(chmouel): Skips tests package or this will try to load
# them when loading plugins.
if '.tests.' in module_name:
# Skips tests or setup packages so as not to load tests in general
# or setup.py during doc generation.
if '.tests.' in module_name or module_name.endswith('.setup'):
continue
try:

View File

@ -76,3 +76,14 @@ class PluginLoaderTest(testtools.TestCase):
loaded = plugin_loader.load_modules(
heat.engine, ignore_error=True)
self.assertEqual(1, len(list(loaded)))
@mock.patch.object(plugin_loader, "_import_module", mock.MagicMock())
@mock.patch('pkgutil.walk_packages')
def test_load_modules_skip_setup(self, mp):
importer = pkgutil.ImpImporter(heat.engine.__path__[0])
mp.return_value = ((importer, "hola.foo", None),
(importer, "hola.setup", None))
loaded = plugin_loader.load_modules(
heat.engine, ignore_error=True)
self.assertEqual(1, len(list(loaded)))