diff --git a/lib/ansible/plugins/__init__.py b/lib/ansible/plugins/__init__.py index c10d19cd38..03558df986 100644 --- a/lib/ansible/plugins/__init__.py +++ b/lib/ansible/plugins/__init__.py @@ -66,7 +66,7 @@ class PluginLoader: if config and not isinstance(config, list): config = [config] - else: + elif not config: config = [] self.config = config diff --git a/test/units/plugins/test_plugins.py b/test/units/plugins/test_plugins.py index 76a2600f53..e8b48afcf1 100644 --- a/test/units/plugins/test_plugins.py +++ b/test/units/plugins/test_plugins.py @@ -75,3 +75,16 @@ class TestErrors(unittest.TestCase): #with patch('glob.glob', mock_glob): # pass + def assertPluginLoaderConfigBecomes(self, arg, expected): + pl = PluginLoader('test', '', arg, 'test_plugin') + self.assertEqual(pl.config, expected) + + def test_plugin__init_config_list(self): + config = ['/one', '/two'] + self.assertPluginLoaderConfigBecomes(config, config) + + def test_plugin__init_config_str(self): + self.assertPluginLoaderConfigBecomes('test', ['test']) + + def test_plugin__init_config_none(self): + self.assertPluginLoaderConfigBecomes(None, [])