当前位置: 首页>>代码示例>>Python>>正文


Python BuildDictionaryInfoExtracter.get_function_args方法代码示例

本文整理汇总了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))
开发者ID:cosmicexplorer,项目名称:pants,代码行数:36,代码来源:test_build_dictionary_info_extracter.py

示例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__))
开发者ID:cburroughs,项目名称:pants,代码行数:19,代码来源:test_build_dictionary_info_extracter.py


注:本文中的pants.help.build_dictionary_info_extracter.BuildDictionaryInfoExtracter.get_function_args方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。