ok

Mini Shell

Direktori : /proc/self/root/lib/python2.7/site-packages/jinja2/testsuite/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/jinja2/testsuite/regression.pyc

�
,��Qc@s�dZddlZddlmZddlmZmZmZmZm	Z	m
Z
ddlmZe�Z
defd��YZdefd	��YZd
�ZdS(s�
    jinja2.testsuite.regression
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Tests corner cases and bugs.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
i����N(t
JinjaTestCase(tTemplatetEnvironmentt
DictLoadertTemplateSyntaxErrortTemplateNotFoundtPrefixLoader(t	text_typetCornerTestCasecBseZd�Zd�ZRS(cCstjd�}|jdd�dks-t�tjd�}|j�dksTt�tjd�}|j�dks{t�dS(Nsv
        {%- for item in (1, 2, 3, 4) -%}
            [{{ item }}]
        {%- endfor %}
        {{- item -}}
        titemi*s[1][2][3][4]42s�
        {%- for item in (1, 2, 3, 4) -%}
            [{{ item }}]
        {%- endfor %}
        {%- set item = 42 %}
        {{- item -}}
        s�
        {%- set item = 42 %}
        {%- for item in (1, 2, 3, 4) -%}
            [{{ item }}]
        {%- endfor %}
        {{- item -}}
        (tenvtfrom_stringtrendertAssertionError(tselftt((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_assigned_scopings			cCstjd�}|j�dks't�tjd�}|j�dksNt�tjd�}|jdd�dks{t�dS(Ns�
        {%- set wrapper = "<FOO>" %}
        {%- for item in (1, 2, 3, 4) %}
            {%- macro wrapper() %}[{{ item }}]{% endmacro %}
            {{- wrapper() }}
        {%- endfor %}
        {{- wrapper -}}
        s[1][2][3][4]<FOO>s�
        {%- for item in (1, 2, 3, 4) %}
            {%- macro wrapper() %}[{{ item }}]{% endmacro %}
            {{- wrapper() }}
        {%- endfor %}
        {%- set wrapper = "<FOO>" %}
        {{- wrapper -}}
        s�
        {%- for item in (1, 2, 3, 4) %}
            {%- macro wrapper() %}[{{ item }}]{% endmacro %}
            {{- wrapper() }}
        {%- endfor %}
        {{- wrapper -}}
        twrapperis[1][2][3][4]23(R
RRR
(RR((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_closure_scoping3s			(t__name__t
__module__RR(((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyRs	tBugTestCasecBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�ZRS(cCs>t�}d�|jd<|jd�j�dks:t�dS(NcSs||S(N((tvaluetsome((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyt<lambda>Vsttestings"{{ 'test'|testing(some='stuff') }}t	teststuff(RtfiltersRRR
(RR
((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_keyword_foldingTs	cCsktdtidd6��}|jd�}|jdt�dksIt�|jdt�dksgt�dS(Ntloaders#(({% block title %}{% endblock %}))sparent.htmls�{% if expr %}{% extends "parent.html" %}{% endif %}[[{% block title %}title{% endblock %}]]{% for item in [1, 2, 3] %}({{ item }}){% endfor %}texprs[[title]](1)(2)(3)s	((title))(RRRRtFalseR
tTrue(RR
R((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_extends_output_bugsZs
cCs+tjd�}|j�dks't�dS(Ns*{{ "http://www.example.org/<foo"|urlize }}sK<a href="http://www.example.org/&lt;foo">http://www.example.org/&lt;foo</a>(R
RRR
(Rttmpl((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_urlize_filter_escapingescCsWtjd�}|j�j�gtdd�D]}t|�^q.dksSt�dS(Ns7

        {% macro test() %}
            {{ caller() }}
        {% endmacro %}

        {% for num1 in range(5) %}
            {% call test() %}
                {% for num2 in range(10) %}
                    {{ loop.index }}
                {% endfor %}
            {% endcall %}
        {% endfor %}

        iii(R
RRtsplittrangeRR
(RR"tx((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_loop_call_loopis	cCs)tdd�}|jt|jd�dS(Ntline_statement_prefixt%s+% for item in seq {# missing #}
...% endfor(Rt
assert_raisesRR(RR
((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_weird_inline_comment|scCs+tjd�}|j�dks't�dS(NsO{% for i in (1, 2) %}{{ i }}{% endfor %}{% macro i() %}3{% endmacro %}{{ i() }}t123(R
RRR
(RR"((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_old_macro_loop_scoping_bug�scCsOtjd�}|jdd�dks-t�|jdt�dksKt�dS(Ns,{% if b %}{% set a = 42 %}{% endif %}{{ a }}tait23tbt42(R
RRR
R (RR"((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyt$test_partial_conditional_assignments�sc	CsRtdd�}|jd�}|jdddtddd	d
�dksNt�dS(NR(t#s�# for j in [1, 2]:
#   set x = 1
#   for i in [1, 2]:
#     print x
#     if i % 2 == 0:
#       set x = x + 1
#     endif
#   endfor
# endfor
# if a
#   print 'A'
# elif b
#   print 'B'
# elif c == d
#   print 'C'
# else
#   print 'D'
# endif
    R.iR0tci*tdgE@t1111C(RRRRR
(RR
R((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_stacked_locals_scoping_bug�s	cCs=td�}|jddg�j�}|dks9t�dS(Ns�
            {% set x = 1 %}
            {% for item in foo %}
                {% if item == 1 %}
                    {% set x = 2 %}
                {% endif %}
            {% endfor %}
            {{ x }}
        tfooiu1(RRtstripR
(RRtrv((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyt(test_stacked_locals_scoping_bug_twoframe�s	cCsztd�}g|jdidd6dd6dd6g�j�D]}|j�^q=d	d
ddd
ddgksvt�dS(Ns�{% macro dump_users(users) -%}
        <ul>
          {%- for user in users -%}
            <li><p>{{ user.username|e }}</p>{{ caller(user) }}</li>
          {%- endfor -%}
          </ul>
        {%- endmacro -%}

        {% call(user) dump_users(list_of_user) -%}
          <dl>
            <dl>Realname</dl>
            <dd>{{ user.realname|e }}</dd>
            <dl>Description</dl>
            <dd>{{ user.description }}</dd>
          </dl>
        {% endcall %}tlist_of_usertapotusernamessomething elsetrealnamettesttdescriptionu<ul><li><p>apo</p><dl>u<dl>Realname</dl>u<dd>something else</dd>u<dl>Description</dl>u
<dd>test</dd>u</dl>u
</li></ul>(RRt
splitlinesR9R
(RRR&((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_call_with_args�s	)cCs=|jttd�|jttd�|jttd�dS(Ns{% if %}....{% endif %}s'{% if foo %}...{% elif %}...{% endif %}s{% for x in %}..{% endfor %}(R*RR(R((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_empty_if_condition_fails�scCstd�}td�}dS(Ns3
        {% for p in foo recursive%}
            {{p.bar}}
            {% for f in p.fields recursive%}
                {{f.baz}}
                {{p.bar}}
                {% if f.rec %}
                    {{ loop(f.sub) }}
                {% endif %}
            {% endfor %}
        {% endfor %}
        s)
        {% for p in foo%}
            {{p.bar}}
            {% for f in p.fields recursive%}
                {{f.baz}}
                {{p.bar}}
                {% if f.rec %}
                    {{ loop(f.sub) }}
                {% endif %}
            {% endfor %}
        {% endfor %}
        (R(Rttpl1ttpl2((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_recursive_loop_bug�s	cCs2td�}|j|jdg�j�d�dS(Ns�
            {% for x in y %}
                {{ loop.index0 }}
            {% else %}
                {% for i in range(3) %}{{ i }}{% endfor %}
            {% endfor %}
        tyt012(RtassertEqualRR9(RR((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_else_loop_bug�s	cCsttdtiti�d6��}y|jd�Wn(tk
r]}|jdkspt�nXtsptd��dS(NRR8sfoo/bar.htmlsexpected error here(RRRtget_templateRtnameR
R(RR
te((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyttest_correct_prefix_loader_name�scsmddlm�dtf�fd��Y}td�}|jd|�dd�}d}|j||�dS(	Ni����(tcontextfunctiont
CallableClasscseZ�d��ZRS(cSs
|jd�S(Nthello(tresolve(Rtctx((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyt__call__s(RRRU((RP(s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyRQss{{ callableclass() }}t
callableclassRRtTEST(tjinja2.utilsRPtobjectRRtassert_equal(RRQttpltoutputtexpected((RPs?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyt%test_contextfunction_callable_classess(RRRR!R#R'R+R-R2R7R;RCRDRGRKROR^(((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyRRs									
	 			
	cCs<tj�}|jtjt��|jtjt��|S(N(tunittestt	TestSuitetaddTestt	makeSuiteRR(tsuite((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyRcs(t__doc__R_tjinja2.testsuiteRtjinja2RRRRRRtjinja2._compatRR
RRRc(((s?/usr/lib/python2.7/site-packages/jinja2/testsuite/regression.pyt<module>
s.	<�

Zerion Mini Shell 1.0