From d2803875182a73ae7dc760c319da2e4c92c675c5 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 8 Nov 2004 20:51:39 +0000 Subject: [PATCH] rest should require args unless indicated otherwise. Currently, we can't indicate otherwise, but that's because we haven't had a need for it yet. --- src/commands.py | 15 +++++++++------ test/test_commands.py | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/commands.py b/src/commands.py index ced166cc1..f23d96c9a 100644 --- a/src/commands.py +++ b/src/commands.py @@ -622,12 +622,15 @@ class context(object): class rest(context): def __call__(self, irc, msg, args, state): - original = args[:] - args[:] = [' '.join(args)] - try: - super(rest, self).__call__(irc, msg, args, state) - except Exception, e: - args[:] = original + if args: + original = args[:] + args[:] = [' '.join(args)] + try: + super(rest, self).__call__(irc, msg, args, state) + except Exception, e: + args[:] = original + else: + raise callbacks.ArgumentError # additional means: Look for this (and make sure it's of this type). If # there are no arguments for us to check, then use our default. diff --git a/test/test_commands.py b/test/test_commands.py index 0280086e5..1c3f1144c 100644 --- a/test/test_commands.py +++ b/test/test_commands.py @@ -57,6 +57,10 @@ class CommandsTestCase(SupyTestCase): def testRestHandling(self): self.assertState([rest(None)], ['foo', 'bar', 'baz'], ['foo bar baz']) + def testRestRequiresArgs(self): + self.assertRaises(callbacks.ArgumentError, + self.assertState, [rest('something')], [], ['asdf']) + def testOptional(self): spec = [optional('int', 999), None] self.assertState(spec, ['12', 'foo'], [12, 'foo'])