diff --git a/plugins/MoobotFactoids.py b/plugins/MoobotFactoids.py index 756fa3973..9d0899c2a 100644 --- a/plugins/MoobotFactoids.py +++ b/plugins/MoobotFactoids.py @@ -79,7 +79,12 @@ class OptionList(object): if not token: raise SyntaxError, 'Missing ")"' elif token == ')': - return ret + if len(ret) > 1: + return ret + elif len(ret) == 1: + return '(%s)' % ret[0] + else: + return '()' elif token == '(': ret.append(self._insideParens(lexer)) elif token == '|': diff --git a/test/test_MoobotFactoids.py b/test/test_MoobotFactoids.py index 51951ae14..bdcfdba53 100644 --- a/test/test_MoobotFactoids.py +++ b/test/test_MoobotFactoids.py @@ -37,6 +37,14 @@ except ImportError: sqlite = None if sqlite is not None: + MoobotFactoids = Owner.loadPluginModule('MoobotFactoids') + class OptionListTestCase(unittest.TestCase): + def testEmptyParens(self): + self.assertEqual(MoobotFactoids.tokenize('()'), ['()']) + + def testNoBarParens(self): + self.assertEqual(MoobotFactoids.tokenize('(foo)'), ['(foo)']) + class FactoidsTestCase(PluginTestCase, PluginDocumentation): plugins = ('MoobotFactoids', 'User', 'Utilities') def setUp(self):