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')
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)
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')