aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Jaggars <jjaggars@redhat.com>2012-02-09 16:07:21 -0600
committerJesse Jaggars <jjaggars@redhat.com>2012-02-09 16:07:21 -0600
commitcf1319d29a012d9b72856464632a583d1b30c256 (patch)
tree3f889c6651062b7f860f8d8d576bf335d4a89cbc
parent48e56530dbe215976d5437b7ae7e07daf19a6f15 (diff)
downloadsos-cf1319d29a012d9b72856464632a583d1b30c256.tar.gz
Fixing a logic error with global option handlling
-rw-r--r--sos/plugins/__init__.py2
-rw-r--r--tests/option_tests.py24
2 files changed, 25 insertions, 1 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index ebb76ea3..872e684d 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -299,7 +299,7 @@ class Plugin(object):
any of the option names is returned."""
def _check(key):
- if hasattr(key, "__iter__"):
+ if hasattr(optionname, "__iter__"):
return key in optionname
else:
return key == optionname
diff --git a/tests/option_tests.py b/tests/option_tests.py
new file mode 100644
index 00000000..06f048a4
--- /dev/null
+++ b/tests/option_tests.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+import unittest
+
+from sos.plugins import Plugin
+
+class GlobalOptionTest(unittest.TestCase):
+
+ def setUp(self):
+ self.commons = {
+ 'global_plugin_options': {
+ 'test_option': 'foobar',
+ },
+ }
+ self.plugin = Plugin(self.commons)
+
+ def test_simple_lookup(self):
+ self.assertEquals(self.plugin.getOption('test_option'), 'foobar')
+
+ def test_multi_lookup(self):
+ self.assertEquals(self.plugin.getOption(('not_there', 'test_option')), 'foobar')
+
+if __name__ == "__main__":
+ unittest.main()