Commits

John Mulligan committed 3e309b0

commander: more tests for help behavior

Comments (0)

Files changed (1)

test/test_cli_commands.py

         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())
         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):
         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()