Exemplo n.º 1
0
 def __init__(self):
     if PY2:
         Command.__init__(self)
         Command.addCmdList(self, self.__cmdLists)
     else:
         super(FsCmd, self).__init__()
         super(FsCmd, self).addCmdList(self.__cmdLists)
Exemplo n.º 2
0
    def test_parse_separates_kwargs(self):
        command = Command(run=function)
        command.add_argument(Arg('keyword1', required=False, default=0))

        args, kwargs = command.parse(['simple'])

        self.assertIn('keyword1', kwargs)
Exemplo n.º 3
0
    def test_parse_separates_args(self):
        command = Command(run=function)
        command.add_argument(Arg('simple', required=True))

        args, kwargs = command.parse(['simple'])

        self.assertIn('simple', args)
Exemplo n.º 4
0
 def test_had_argument(self):
     command = Command(run=lambda new_argument: new_argument)
     self.assertEqual(len(command.args), 1)
     arg = Arg('new_argument', help='argument help')
     command.add_argument(arg)
     self.assertEqual(len(command.args), 1)
     self.assertEqual(command.args[0].help,
         'argument help')
Exemplo n.º 5
0
 def test_merge_namespace(self):
     new_manager = Manager()
     new_manager.add_command(Command(name='new_command'))
     manager.merge(new_manager, namespace='new_namespace')
     self.assertIn('new_namespace.new_command', manager.commands)
Exemplo n.º 6
0
 def test_capture_all(self):
     command = Command(run=lambda argv: argv, capture_all=True)
     self.assertEqual(len(command.args), 0)
Exemplo n.º 7
0
 def test_add_argument_existsing(self):
     command = Command(run=lambda new_argument: new_argument)
     self.assertEqual(len(command.args), 1)
     arg = Arg('new_argument', help='argument help')
     self.assertRaises(Exception, command.add_argument, arg)