commands: Add run method to Commands

This commit is contained in:
Thomas Adamcik 2013-11-12 23:17:50 +01:00
parent f5a5f9e9b1
commit 1394f3929b
2 changed files with 9 additions and 0 deletions

View File

@ -127,3 +127,6 @@ class Command(object):
return self._children[child]._parse(
result._args, result, defaults, ' '.join([prog, child]))
def run(self, *args, **kwargs):
raise NotImplementedError

View File

@ -434,3 +434,9 @@ class CommandErrorTest(unittest.TestCase):
def test_str_command_error(self):
error = command.CommandError('message', usage='usage: foo')
self.assertEqual(str(error), 'usage: foo\n\nerror: message\n')
class RunTest(unittest.TestCase):
def test_default_implmentation_raises_error(self):
with self.assertRaises(NotImplementedError):
command.Command().run()