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


Python support.f函数代码示例

本文整理汇总了Python中sigtools.support.f函数的典型用法代码示例。如果您正苦于以下问题:Python f函数的具体用法?Python f怎么用?Python f使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了f函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_call

 def test_call(self):
     outer = support.f('*args, **kwargs')
     inner = support.f('a, *, b')
     forw = specifiers.forwards_to_function(inner)(outer)
     instance = object()
     forw_get_prox = _util.safe_get(forw, instance, object)
     self.assertEqual(
         forw_get_prox(1, b=2),
         {'args': (instance, 1), 'kwargs': {'b': 2}})
开发者ID:epsy,项目名称:sigtools,代码行数:9,代码来源:test_specifiers.py

示例2: test_use_twice

 def test_use_twice(self):
     annotator = modifiers.annotate(a=1)
     self.assertSigsEqual(
         s('a:1, b'),
         signature(annotator(f('a, b')))
         )
     self.assertSigsEqual(
         s('a:1'),
         signature(annotator(f('a')))
         )
开发者ID:epsy,项目名称:sigtools,代码行数:10,代码来源:test_modifiers.py

示例3: test_specifiers_sig_after

 def test_specifiers_sig_after(self):
     inner = f('a, b', name='inner')
     outer = f('x, y, z, *args, **kwargs', name='outer')
     pt = modifiers.kwoargs('z')(outer)
     pt = specifiers.forwards_to_function(inner)(pt)
     sig = specifiers.signature(pt)
     self.assertSigsEqual(sig, s('x, y, a, b, *, z'))
     self.assertSourcesEqual(
         sig.sources, {'inner': 'ab', 'outer': 'xyz',
                       '+depths': ['outer', 'inner']})
     self.assertEqual(sig.sources['x'], [pt])
开发者ID:epsy,项目名称:sigtools,代码行数:11,代码来源:test_modifiers.py

示例4: test_success

 def test_success(self):
     self.assertSigsEqual(
         s('a, b:1'),
         signature(modifiers.annotate(b=1)(f('a, b')))
         )
     self.assertSigsEqual(
         s('a:1, b:2'),
         signature(modifiers.annotate(a=1, b=2)(f('a, b')))
         )
     self.assertSigsEqual(
         s('a:1, b', 2),
         signature(modifiers.annotate(2, a=1)(f('a, b')))
         )
开发者ID:epsy,项目名称:sigtools,代码行数:13,代码来源:test_modifiers.py

示例5: _test_func

 def _test_func(self, sig, wrapper_sigs, doc, wrapper_docs, help_str):
     ifunc = f(sig, pre="from clize import Parameter")
     ifunc.__doc__ = doc
     func = ifunc
     for sig, doc in zip(wrapper_sigs, wrapper_docs):
         wfunc = f('func, ' + sig, pre="from clize import Parameter")
         wfunc.__doc__ = doc
         func = wrapper_decorator(wfunc)(func)
     r = runner.Clize(func)
     h = help.ClizeHelp(r, None)
     h.prepare()
     p_help_str = str(h.show('func'))
     self.assertEqual(help_str.split(), p_help_str.split())
开发者ID:edk0,项目名称:clize,代码行数:13,代码来源:test_help.py

示例6: test_custom_param_help

    def test_custom_param_help(self):
        class CustParam(parser.OptionParameter):
            def show_help(self, desc, after, f, cols):
                cols.append('I am', 'a custom parameter!')
                f.append("There is stuff after me.")
                f.append(desc)
                f.extend(after)
        func = f(
            "*, param: a",
            locals={'a': parser.use_class(named=CustParam)})
        func.__doc__ = """
            param: Param desc

            After param

            _:_

        """
        r = runner.Clize(func)
        self._do_test(r, ['func --param=STR', USAGE_HELP], """
            Usage: func [OPTIONS]

            Options:
                I am    a custom parameter!

            There is stuff after me.

            Param desc

            After param

            Other actions:
                -h, --help  Show the help
        """)
开发者ID:edk0,项目名称:clize,代码行数:34,代码来源:test_help.py

示例7: test_whole_help

def test_whole_help(self, sig, doc, help_str):
    func = f(sig, pre="from clize import Parameter")
    func.__doc__ = doc
    r = runner.Clize(func)
    h = help.ClizeHelp(r, None)
    p_help_str = str(h.show('func'))
    self.assertEqual(p_help_str.split(), help_str.split())
开发者ID:HSpear,项目名称:clize,代码行数:7,代码来源:test_help.py

示例8: test_attr_conservation_after

 def test_attr_conservation_after(self):
     func = f('s, a')
     pt = modifiers.kwoargs('a')(func)
     pt.attr = object()
     self.assertIs(pt.attr, modifiers.kwoargs('a')(pt).attr)
     bpt = pt.__get__(object(), object)
     self.assertIs(pt.attr, bpt.attr)
     self.assertIs(pt.attr, modifiers.kwoargs('a')(bpt).attr)
开发者ID:epsy,项目名称:sigtools,代码行数:8,代码来源:test_modifiers.py

示例9: test_show_list_morekw

 def test_show_list_morekw(self):
     func = support.f('par:a', locals={'a': RepTests.mapped_basic[1]})
     out, err = util.run(func, ['name', 'list', '-k', 'xyz'])
     self.assertEqual('', err.getvalue())
     self.assertEqual(
         """name: Possible values for par:
         hello h1
         goodbye h2""".split(),
         out.getvalue().split())
开发者ID:Shir0kamii,项目名称:clize,代码行数:9,代码来源:test_parameters.py

示例10: test_show_list

 def test_show_list(self):
     func = support.f('par:a', locals={'a': RepTests.oneof_help[1]})
     out, err = util.run(func, ['name', 'list'])
     self.assertEqual('', err.getvalue())
     self.assertEqual(
         """name: Possible values for par:
         hello h1
         bye h2""".split(),
         out.getvalue().split())
开发者ID:Shir0kamii,项目名称:clize,代码行数:9,代码来源:test_parameters.py

示例11: test_alt_middle

 def test_alt_middle(self):
     _func = support.f('')
     self.assertRaises(
         errors.ArgsBeforeAlternateCommand,
         self._test_func,
         '*a', [
             parser.AlternateCommandParameter(
                 func=_func, aliases=['--alt'])],
         ('a', '--alt', 'a', 'b'), ['a', 'b'], {}, _func
     )
开发者ID:prodigeni,项目名称:clize,代码行数:10,代码来源:test_parser.py

示例12: test_show_list

 def test_show_list(self):
     func = support.f('par:a', locals={'a': RepTests.mapped_basic[1]})
     out, err = self.crun(func, ['name', 'list'])
     self.assertEqual('', err.getvalue())
     self.assertLinesEqual(
         """
         name: Possible values for par:
           hello     h1
           goodbye   h2""",
         out.getvalue())
开发者ID:epsy,项目名称:clize,代码行数:10,代码来源:test_parameters.py

示例13: _test

    def _test(self, expected_sig_str, orig_sig_str, exceptions):
        orig_func = f(orig_sig_str)
        expected_sig = s(expected_sig_str)

        func = modifiers.autokwoargs(exceptions=exceptions)(orig_func)
        self.assertSigsEqual(expected_sig, signature(func))

        if not exceptions: # test the arg-less form of @autokwargs
            func = modifiers.autokwoargs(orig_func)
            self.assertSigsEqual(expected_sig, signature(func))
开发者ID:epsy,项目名称:sigtools,代码行数:10,代码来源:test_modifiers.py

示例14: test_show_list_alt

 def test_show_list_alt(self):
     func = support.f('par:a',
                     locals={'a': RepTests.mapped_alternate_list[1]})
     out, err = util.run(func, ['name', 'options'])
     self.assertEqual('', err.getvalue())
     self.assertEqual(
         """name: Possible values for par:
         hello h1
         goodbye h2""".split(),
         out.getvalue().split())
开发者ID:Shir0kamii,项目名称:clize,代码行数:10,代码来源:test_parameters.py

示例15: _test

    def _test(self, outer, inner, args, kwargs,
                    expected, expected_get, exp_src, exp_src_get):
        outer_f = support.f(outer, name='outer')
        inner_f = support.f(inner, name='inner')
        forw = specifiers.forwards_to_function(inner_f, *args, **kwargs)(outer_f)

        sig = specifiers.signature(forw)
        self.assertSigsEqual(sig, support.s(expected))

        self.assertSourcesEqual(sig.sources, {
                'outer': exp_src[0], 'inner': exp_src[1],
                '+depths': ['outer', 'inner']})

        sig_get = specifiers.signature(_util.safe_get(forw, object(), object))
        self.assertSigsEqual(sig_get, support.s(expected_get))

        self.assertSourcesEqual(sig_get.sources, {
                'outer': exp_src_get[0], 'inner': exp_src_get[1],
                '+depths': ['outer', 'inner']})
开发者ID:epsy,项目名称:sigtools,代码行数:19,代码来源:test_specifiers.py


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