• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test.eq_函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_fileargs_lookup

    def test_fileargs_lookup(self):
        l = lookup.TemplateLookup(cache_dir=module_base, cache_type='file')
        l.put_string("test", """
                <%!
                    callcount = [0]
                %>
                <%def name="foo()" cached="True">
                    this is foo
                    <%
                    callcount[0] += 1
                    %>
                </%def>

                ${foo()}
                ${foo()}
                ${foo()}
                callcount: ${callcount}
        """)

        t = l.get_template('test')
        m = self._install_mock_cache(t)
        assert result_lines(l.get_template('test').render()) == [
            'this is foo',
            'this is foo',
            'this is foo',
            'callcount: [1]',
        ]
        eq_(m.kwargs, {'dir': module_base, 'type': 'file'})
开发者ID:whiteclover,项目名称:Choco,代码行数:28,代码来源:test_cache.py


示例2: test_fileargs_pagetag

    def test_fileargs_pagetag(self):
        t = Template("""
        <%%page cache_dir='%s' cache_type='dbm'/>
        <%%!
            callcount = [0]
        %%>
        <%%def name="foo()" cached="True">
            this is foo
            <%%
            callcount[0] += 1
            %%>
        </%%def>

        ${foo()}
        ${foo()}
        ${foo()}
        callcount: ${callcount}
""" % module_base)
        m = self._install_mock_cache(t)
        assert result_lines(t.render()) == [
            'this is foo',
            'this is foo',
            'this is foo',
            'callcount: [1]',
        ]
        eq_(m.kwargs, {'dir': module_base, 'type': 'dbm'})
开发者ID:whiteclover,项目名称:Choco,代码行数:26,代码来源:test_cache.py


示例3: test_metadata_two

    def test_metadata_two(self):
        t = Template("""
Text
Text
% if bar:
    ${expression}
% endif

    <%block name="foo">
        hi block
    </%block>


""", uri="/some/template")
        eq_(
            ModuleInfo.get_module_source_metadata(t.code, full_line_map=True),
            {
                'full_line_map': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                            0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 5, 5, 5, 7, 7, 7,
                            7, 7, 10, 10, 10, 10, 10, 10, 8, 8, 8, 8, 8,
                            8, 8, 8, 8, 8, 8, 8],
                'source_encoding': 'ascii',
                'filename': None,
                'line_map': {33: 10, 39: 8, 45: 8, 14: 0, 51: 45, 23: 1,
                                24: 4, 25: 5, 26: 5, 27: 5, 28: 7},
                'uri': '/some/template'}
        )
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:27,代码来源:test_template.py


示例4: test_unicode_file_lookup

 def test_unicode_file_lookup(self):
     lookup = TemplateLookup(directories=[template_base], output_encoding="utf-8", default_filters=["decode.utf8"])
     if compat.py3k:
         template = lookup.get_template("/chs_unicode_py3k.html")
     else:
         template = lookup.get_template("/chs_unicode.html")
     eq_(flatten_result(template.render_unicode(name="毛泽东")), u("毛泽东 是 新中国的主席<br/> Welcome 你 to 北京."))
开发者ID:JasonZengJ,项目名称:puzzle,代码行数:7,代码来源:test_template.py


示例5: test_locate_identifiers

    def test_locate_identifiers(self):
        """test the location of identifiers in a python code string"""
        code = """
a = 10
b = 5
c = x * 5 + a + b + q
(g,h,i) = (1,2,3)
[u,k,j] = [4,5,6]
foo.hoho.lala.bar = 7 + gah.blah + u + blah
for lar in (1,2,3):
    gh = 5
    x = 12
("hello world, ", a, b)
("Another expr", c)
"""
        parsed = ast.PythonCode(code, **exception_kwargs)
        eq_(
            parsed.declared_identifiers,
            set(['a', 'b', 'c', 'g', 'h', 'i', 'u',
                'k', 'j', 'gh', 'lar', 'x'])
        )
        eq_(
            parsed.undeclared_identifiers,
            set(['x', 'q', 'foo', 'gah', 'blah'])
        )

        parsed = ast.PythonCode("x + 5 * (y-z)", **exception_kwargs)
        assert parsed.undeclared_identifiers == set(['x', 'y', 'z'])
        assert parsed.declared_identifiers == set()
开发者ID:Zer0-,项目名称:mako,代码行数:29,代码来源:test_ast.py


示例6: test_locate_identifiers_10

    def test_locate_identifiers_10(self):
        code = """
lambda q: q + 5
"""
        parsed = ast.PythonCode(code, **exception_kwargs)
        eq_(parsed.declared_identifiers, set())
        eq_(parsed.undeclared_identifiers, set())
开发者ID:Zer0-,项目名称:mako,代码行数:7,代码来源:test_ast.py


示例7: test_locate_identifiers_7

    def test_locate_identifiers_7(self):
        code = """
import foo.bar
"""
        parsed = ast.PythonCode(code, **exception_kwargs)
        eq_(parsed.declared_identifiers, set(['foo']))
        eq_(parsed.undeclared_identifiers, set())
开发者ID:Zer0-,项目名称:mako,代码行数:7,代码来源:test_ast.py


示例8: test_interpret_expression_from_arg_two

    def test_interpret_expression_from_arg_two(self):
        """test that cache_key=${foo} gets its value from
        the 'foo' argument regardless of it being passed
        from the context.

        This is here testing that there's no change
        to existing behavior before and after #191.

        """
        t = Template("""
        <%def name="layout(foo)" cached="True" cache_key="${foo}">
        foo: ${value}
        </%def>

        ${layout(3)}
        """, cache_impl="plain")

        eq_(
            result_lines(t.render(foo='foo', value=1)),
            ["foo: 1"]
        )
        eq_(
            result_lines(t.render(foo='bar', value=2)),
            ["foo: 1"]
        )
开发者ID:whiteclover,项目名称:Choco,代码行数:25,代码来源:test_def.py


示例9: test_fileargs_implicit

    def test_fileargs_implicit(self):
        l = lookup.TemplateLookup(module_directory=module_base)
        l.put_string(
            "test",
            """
                <%!
                    callcount = [0]
                %>
                <%def name="foo()" cached="True" cache_type='dbm'>
                    this is foo
                    <%
                    callcount[0] += 1
                    %>
                </%def>

                ${foo()}
                ${foo()}
                ${foo()}
                callcount: ${callcount}
        """,
        )

        m = self._install_mock_cache(l.get_template("test"))
        assert result_lines(l.get_template("test").render()) == [
            "this is foo",
            "this is foo",
            "this is foo",
            "callcount: [1]",
        ]
        eq_(m.kwargs, {"type": "dbm"})
开发者ID:margarethagan,项目名称:docassemble,代码行数:30,代码来源:test_cache.py


示例10: test_scope_five

    def test_scope_five(self):
        """test that variables are pulled from
        'enclosing' scope before context."""
        # same as test four, but adds a scope around it.
        t = Template("""
            <%def name="enclosing()">
            <%
                x = 5
            %>
            <%def name="a()">
                this is a. x is ${x}.
            </%def>

            <%def name="b()">
                <%
                    x = 9
                %>
                this is b. x is ${x}.
                calling a. ${a()}
            </%def>

            ${b()}
            </%def>
            ${enclosing()}
""")
        eq_(
            flatten_result(t.render()),
            "this is b. x is 9. calling a. this is a. x is 5."
        )
开发者ID:whiteclover,项目名称:Choco,代码行数:29,代码来源:test_def.py


示例11: test_scope_eight

    def test_scope_eight(self):
        """test that the initial context counts
        as 'enclosing' scope, for nested defs"""
        t = Template("""
        <%def name="enclosing()">
            <%def name="a()">
                a: x is ${x}
            </%def>

            <%def name="b()">
                <%
                    x = 10
                %>

                b. x is ${x}.  ${a()}
            </%def>

            ${b()}
        </%def>
        ${enclosing()}
    """)
        eq_(
            flatten_result(t.render(x=5)),
            "b. x is 10. a: x is 5"
        )
开发者ID:whiteclover,项目名称:Choco,代码行数:25,代码来源:test_def.py


示例12: test_outer_scope

    def test_outer_scope(self):
        t = Template("""
        <%def name="a()">
            a: x is ${x}
        </%def>

        <%def name="b()">
            <%def name="c()">
            <%
                x = 10
            %>
            c. x is ${x}.  ${a()}
            </%def>

            b. ${c()}
        </%def>

        ${b()}

        x is ${x}
""")
        eq_(
            flatten_result(t.render(x=5)),
            "b. c. x is 10. a: x is 5 x is 5"
        )
开发者ID:whiteclover,项目名称:Choco,代码行数:25,代码来源:test_def.py


示例13: test_new_syntax

    def test_new_syntax(self):
        """test foo:bar syntax, including multiline args and expression eval."""

        # note the trailing whitespace in the bottom ${} expr, need to strip
        # that off < python 2.7

        t = Template("""
            <%def name="foo(x, y, q, z)">
                ${x}
                ${y}
                ${q}
                ${",".join("%s->%s" % (a, b) for a, b in z)}
            </%def>

            <%self:foo x="this is x" y="${'some ' + 'y'}" q="
                this
                is
                q"

                z="${[
                (1, 2),
                (3, 4),
                (5, 6)
            ]

            }"/>
        """)

        eq_(
            result_lines(t.render()),
             ['this is x', 'some y', 'this', 'is', 'q', '1->2,3->4,5->6']
        )
开发者ID:whiteclover,项目名称:Choco,代码行数:32,代码来源:test_call.py


示例14: test_args_complete

    def test_args_complete(self):
        t = Template(
            """
        <%%def name="foo()" cached="True" cache_timeout="30" cache_dir="%s"
         cache_type="file" cache_key='somekey'>
            this is foo
        </%%def>

        ${foo()}
"""
            % module_base
        )
        m = self._install_mock_cache(t)
        t.render()
        eq_(m.kwargs, {"dir": module_base, "type": "file", "timeout": 30})

        t2 = Template(
            """
        <%%page cached="True" cache_timeout="30" cache_dir="%s"
         cache_type="file" cache_key='somekey'/>
        hi
        """
            % module_base
        )
        m = self._install_mock_cache(t2)
        t2.render()
        eq_(m.kwargs, {"dir": module_base, "type": "file", "timeout": 30})
开发者ID:margarethagan,项目名称:docassemble,代码行数:27,代码来源:test_cache.py


示例15: test_fileargs_lookup

    def test_fileargs_lookup(self):
        l = lookup.TemplateLookup(cache_dir=module_base, cache_type="file")
        l.put_string(
            "test",
            """
                <%!
                    callcount = [0]
                %>
                <%def name="foo()" cached="True">
                    this is foo
                    <%
                    callcount[0] += 1
                    %>
                </%def>

                ${foo()}
                ${foo()}
                ${foo()}
                callcount: ${callcount}
        """,
        )

        t = l.get_template("test")
        m = self._install_mock_cache(t)
        assert result_lines(l.get_template("test").render()) == [
            "this is foo",
            "this is foo",
            "this is foo",
            "callcount: [1]",
        ]
        eq_(m.kwargs, {"dir": module_base, "type": "file"})
开发者ID:margarethagan,项目名称:docassemble,代码行数:31,代码来源:test_cache.py


示例16: test_metadata

    def test_metadata(self):
        t = Template("""
Text
Text
% if bar:
    ${expression}
% endif

<%include file='bar'/>

""", uri="/some/template")
        eq_(
            ModuleInfo.get_module_source_metadata(t.code, full_line_map=True),
            {
                'full_line_map': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                                    0, 0, 0, 0, 0, 0, 1, 4, 5, 5, 5, 7, 8,
                                    8, 8, 8, 8, 8, 8],
                'source_encoding': 'ascii',
                'filename': None,
                'line_map': {34: 28, 14: 0, 21: 1, 22: 4, 23: 5, 24: 5,
                                    25: 5, 26: 7, 27: 8, 28: 8},
                'uri': '/some/template'
            }

        )
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:25,代码来源:test_template.py


示例17: test_function_decl

 def test_function_decl(self):
     """test getting the arguments from a function"""
     code = "def foo(a, b, c=None, d='hi', e=x, f=y+7):pass"
     parsed = ast.FunctionDecl(code, **exception_kwargs)
     eq_(parsed.funcname, 'foo')
     eq_(parsed.argnames,
         ['a', 'b', 'c', 'd', 'e', 'f'])
开发者ID:Zer0-,项目名称:mako,代码行数:7,代码来源:test_ast.py


示例18: test_stdin_success

    def test_stdin_success(self):
        with self._capture_output_fixture() as stdout:
            with mock.patch("sys.stdin", mock.Mock(
                            read=mock.Mock(return_value="hello world ${x}"))):
                cmdline(["--var", "x=5", "-"])

        eq_(stdout.write.mock_calls[0][1][0], "hello world 5")
开发者ID:whiteclover,项目名称:Choco,代码行数:7,代码来源:test_cmd.py


示例19: test_inter_def

    def test_inter_def(self):
        """test defs calling each other"""
        template = Template("""
        ${b()}

        <%def name="a()">\
        im a
        </%def>

        <%def name="b()">
        im b
        and heres a:  ${a()}
        </%def>

        <%def name="c()">
        im c
        </%def>
""")
        # check that "a" is declared in "b", but not in "c"
        if compat.py3k:
            assert "a" not in template.module.render_c.__code__.co_varnames
            assert "a" in template.module.render_b.__code__.co_varnames
        else:
            assert "a" not in template.module.render_c.func_code.co_varnames
            assert "a" in template.module.render_b.func_code.co_varnames

        # then test output
        eq_(
            flatten_result(template.render()),
            "im b and heres a: im a"
        )
开发者ID:whiteclover,项目名称:Choco,代码行数:31,代码来源:test_def.py


示例20: test_locate_identifiers_6

    def test_locate_identifiers_6(self):
        code = """
def foo():
    return bar()
"""
        parsed = ast.PythonCode(code, **exception_kwargs)
        eq_(parsed.undeclared_identifiers, set(['bar']))

        code = """
def lala(x, y):
    return x, y, z
print(x)
"""
        parsed = ast.PythonCode(code, **exception_kwargs)
        eq_(parsed.undeclared_identifiers, set(['z', 'x']))
        eq_(parsed.declared_identifiers, set(['lala']))

        code = """
def lala(x, y):
    def hoho():
        def bar():
            z = 7
print(z)
"""
        parsed = ast.PythonCode(code, **exception_kwargs)
        eq_(parsed.undeclared_identifiers, set(['z']))
        eq_(parsed.declared_identifiers, set(['lala']))
开发者ID:Zer0-,项目名称:mako,代码行数:27,代码来源:test_ast.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test.get_collector_config函数代码示例发布时间:2022-05-27
下一篇:
Python test.drop_connection函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap