From da175d0a5722f3b54a9086b38325994f20307a3f Mon Sep 17 00:00:00 2001 From: jpic Date: Tue, 5 Apr 2016 11:58:35 +0200 Subject: [PATCH 1/2] Bugfix: proper plugin configuration was reset Before this patch, if config was ['/some/path'] then it would enter the else block and config would be set to []. The regression this patch fixes was introduced by 700db154. --- lib/ansible/plugins/__init__.py | 2 +- test/units/plugins/test_plugins.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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..3543cbc230 100644 --- a/test/units/plugins/test_plugins.py +++ b/test/units/plugins/test_plugins.py @@ -75,3 +75,7 @@ class TestErrors(unittest.TestCase): #with patch('glob.glob', mock_glob): # pass + def test_plugin__config(self): + config = ['/one', '/two'] + pl = PluginLoader('test', '', config, 'test_plugin') + self.assertEqual(pl.config, config) From 4985411816b21d53b5b0c4246ac54a1bddf7e8ea Mon Sep 17 00:00:00 2001 From: jpic Date: Tue, 5 Apr 2016 14:45:40 +0200 Subject: [PATCH 2/2] Test other use-cases for PluginLoader's config --- test/units/plugins/test_plugins.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/units/plugins/test_plugins.py b/test/units/plugins/test_plugins.py index 3543cbc230..e8b48afcf1 100644 --- a/test/units/plugins/test_plugins.py +++ b/test/units/plugins/test_plugins.py @@ -75,7 +75,16 @@ class TestErrors(unittest.TestCase): #with patch('glob.glob', mock_glob): # pass - def test_plugin__config(self): + 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'] - pl = PluginLoader('test', '', config, 'test_plugin') - self.assertEqual(pl.config, config) + 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, [])