@@ 187,13 187,6 @@ class TestCliCommands(unittest.TestCase)
self.assert_('baz' in usage)
def test_fancy_help_3(self):
- def tst(arguments):
- capture = Capture()
- try:
- result = commander.launch(GOPT_A, CMDTABLE_A, arguments)
- except commander.HelpWanted, herr:
- commander.handlehelp(herr, GOPT_A, CMDTABLE_A, output=capture)
- return ''.join(capture)
c1 = tst('foo --help'.split())
c2 = tst('foo -h'.split())
c3 = tst('--help foo'.split())
@@ 208,6 201,11 @@ class TestCliCommands(unittest.TestCase)
self.assertEqual(c1, c2)
self.assertEqual(c2, c3)
+ def test_fancy_help_4(self):
+ self.assertRaises(commander.MissingCommand, tst, [])
+ tst('help zork'.split())
+ self.assertRaises(commander.InvalidCommand, tst, 'zork -h'.split())
+
class Capture(list):
@@ 215,5 213,14 @@ class Capture(list):
self.append(x)
+def tst(arguments):
+ capture = Capture()
+ try:
+ result = commander.launch(GOPT_A, CMDTABLE_A, arguments)
+ except commander.HelpWanted, herr:
+ commander.handlehelp(herr, GOPT_A, CMDTABLE_A, output=capture)
+ return ''.join(capture)
+
+
if __name__ == '__main__':
unittest.main()