本文整理汇总了Python中pants.help.build_dictionary_info_extracter.BuildDictionaryInfoExtracter.get_function_args方法的典型用法代码示例。如果您正苦于以下问题:Python BuildDictionaryInfoExtracter.get_function_args方法的具体用法?Python BuildDictionaryInfoExtracter.get_function_args怎么用?Python BuildDictionaryInfoExtracter.get_function_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.help.build_dictionary_info_extracter.BuildDictionaryInfoExtracter
的用法示例。
在下文中一共展示了BuildDictionaryInfoExtracter.get_function_args方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_function_args
# 需要导入模块: from pants.help.build_dictionary_info_extracter import BuildDictionaryInfoExtracter [as 别名]
# 或者: from pants.help.build_dictionary_info_extracter.BuildDictionaryInfoExtracter import get_function_args [as 别名]
def test_get_function_args(self):
# Test standalone function.
def func(arg1, arg2, arg3=42, arg4=None, arg5='foo'):
pass
self.assertEqual([FunctionArg('arg1', '', False, None), FunctionArg('arg2', '', False, None),
FunctionArg('arg3', '', True, 42), FunctionArg('arg4', '', True, None),
FunctionArg('arg5', '', True, 'foo')],
BuildDictionaryInfoExtracter.get_function_args(func))
# Test member function.
class TestCls(object):
def __init__(self, arg1, arg2=False):
pass
self.assertEqual([FunctionArg('arg1', '', False, None), FunctionArg('arg2', '', True, False)],
BuildDictionaryInfoExtracter.get_function_args(TestCls.__init__))
# Test *args, **kwargs situation.
def generic_func(arg1, arg2=42, *args, **kwargs):
"""
:param arg1: The first arg.
:param arg2: The second arg.
:param args: Some extra varargs.
:param arg3: The third arg.
:param arg4: The fourth arg (default: 'Foo').
"""
self.assertEqual([FunctionArg('arg1', 'The first arg.', False, None),
FunctionArg('arg2', 'The second arg.', True, 42),
FunctionArg('*args', 'Some extra varargs.', False, None),
FunctionArg('arg3', 'The third arg.', True, None),
FunctionArg('arg4', "The fourth arg.", True, "'Foo'")],
BuildDictionaryInfoExtracter.get_function_args(generic_func))
示例2: test_get_function_args
# 需要导入模块: from pants.help.build_dictionary_info_extracter import BuildDictionaryInfoExtracter [as 别名]
# 或者: from pants.help.build_dictionary_info_extracter.BuildDictionaryInfoExtracter import get_function_args [as 别名]
def test_get_function_args(self):
# Test standalone function.
def func(arg1, arg2, arg3=42, arg4=None, arg5='foo'):
pass
self.assertEqual([FunctionArg('arg1', '', False, None), FunctionArg('arg2', '', False, None),
FunctionArg('arg3', '', True, 42), FunctionArg('arg4', '', True, None),
FunctionArg('arg5', '', True, 'foo')],
BuildDictionaryInfoExtracter.get_function_args(func))
# Test member function.
class TestCls(object):
def __init__(self, arg1, arg2=False):
pass
self.assertEqual([FunctionArg('arg1', '', False, None), FunctionArg('arg2', '', True, False)],
BuildDictionaryInfoExtracter.get_function_args(TestCls.__init__))