diff options
author | jhjaggars <jhjaggars@gmail.com> | 2012-02-09 14:10:19 -0800 |
---|---|---|
committer | jhjaggars <jhjaggars@gmail.com> | 2012-02-09 14:10:19 -0800 |
commit | ebefea9b122ea5cf74c692b59991be08fdb5d47e (patch) | |
tree | 3f889c6651062b7f860f8d8d576bf335d4a89cbc | |
parent | 48e56530dbe215976d5437b7ae7e07daf19a6f15 (diff) | |
parent | cf1319d29a012d9b72856464632a583d1b30c256 (diff) | |
download | sos-ebefea9b122ea5cf74c692b59991be08fdb5d47e.tar.gz |
Merge pull request #22 from jhjaggars/master
getOption now handles multiply named keys properly
-rw-r--r-- | sos/plugins/__init__.py | 2 | ||||
-rw-r--r-- | tests/option_tests.py | 24 |
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() |