Ejemplo n.º 1
0
    def test_register_decorator(self, mock_exit):
        class Test(argcmd.ArgCmd):
            @argcmd.command()
            def foo(self, args):
                return 'test_register_decorator'

        argcmd.main(module=locals(), args=['foo'])
        mock_exit.assert_called_with('test_register_decorator')
Ejemplo n.º 2
0
    def test_register_functions(self, mock_exit):
        def cmd_foo(args):
            return 'test_register_functions'
        argcmd.main(module=locals(), args=['foo'])
        mock_exit.assert_called_with('test_register_functions')

        self.reset()
        argcmd.main(module=locals(), args=['bar'])
        mock_exit.assert_called_with(2)
Ejemplo n.º 3
0
    def test_register_function_name(self, mock_exit):
        class Test(argcmd.ArgCmd):
            def cmd_foo(self, args):
                return 'register_function_name'

        argcmd.main(module=locals(), args=['foo'], shell=False)
        mock_exit.assert_called_with('register_function_name')

        self.reset()
        argcmd.main(module=locals(), args=['foo'], shell=True)
        mock_exit.assert_called_with('register_function_name')