コード例 #1
0
ファイル: command_test.py プロジェクト: op/argcmd
    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')
コード例 #2
0
ファイル: command_test.py プロジェクト: op/argcmd
    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)
コード例 #3
0
ファイル: command_test.py プロジェクト: op/argcmd
    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')