ok

Mini Shell

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

�
��Rc@s�dZddlZddlZddlmZddlmZmZmZm	Z	ddl
mZddlm
Z
ddlmZmZddlmZmZmZmZd	Zejd
�Zidd6d
d6dd6dd6dd6Zidd6d
d6dd6dd6dd6dd6dd6dd6dd6d d!6d"d#6d$d%6Ziid&d'6d(d)6d*d+6d,d-6d.d/6d0d16d2d36d4d56d66Zed7��Zed8��Zed9ee�d:d;g�Zejj ied<6ed=6ed>6�ed9ee�d:d;g�Z!e!j"eed?e#�d@e
fdA��YZ$dBe
fdC��YZ%dDe
fdE��YZ&dFefdG��YZ'dHefdI��YZ(dJefdK��YZ)dLefdM��YZ*dN�Z+dS(Os�
    jinja2.testsuite.ext
    ~~~~~~~~~~~~~~~~~~~~

    Tests for the extensions.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
i����N(t
JinjaTestCase(tEnvironmentt
DictLoadertcontextfunctiontnodes(tTemplateAssertionError(t	Extension(tTokentcount_newlines(tnexttBytesIOt
itervaluest	text_typeis_\((.*?)\)(?s)sS<title>{{ page_title|default(_("missing")) }}</title>{% block body %}{% endblock %}smaster.htmls[{% extends "master.html" %}{% block body %}{% trans %}watch out{% endtrans %}{% endblock %}s
child.htmls_{% trans user_count %}One user online{% pluralize %}{{ user_count }} users online{% endtrans %}splural.htmlsf{% trans user_count=get_user_count() %}{{ user_count }}s{% pluralize %}{{ user_count }}p{% endtrans %}splural2.htmls/{{ _("User: %(num)s")|format(num=user_count) }}sstringformat.htmls({{ _("User: %(num)s", num=user_count) }}s9{{ ngettext("%(num)s apple", "%(num)s apples", apples) }}s
ngettext.htmlsR{% trans num=apples %}{{ num }} apple{% pluralize %}{{ num }} apples{% endtrans %}sngettext_long.htmls({% trans %}User: {{ num }}{% endtrans %}stransvars1.htmls2{% trans num=count %}User: {{ num }}{% endtrans %}stransvars2.htmls4{% trans count=num %}User: {{ count }}{% endtrans %}stransvars3.htmls"{% trans %}%(hello)s{% endtrans %}snovars.htmls){% trans %}{{ foo }}%(foo)s{% endtrans %}s	vars.htmls){% trans foo="42" %}%(foo)s{% endtrans %}sexplicitvars.htmlufehlendtmissingupass aufs	watch outuEin Benutzer onlinesOne user onlineu%(user_count)s Benutzer onlines%(user_count)s users onlineuBenutzer: %(num)ss
User: %(num)suBenutzer: %(count)ssUser: %(count)su
%(num)s Apfels
%(num)s appleu%(num)s Äpfels%(num)s applestdecCs.|jdd�}tj|i�j||�S(NtLANGUAGEten(tgett	languages(tcontexttstringtlanguage((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pytgettextIscCsV|jdd�}|dkr:tj|i�j||�Stj|i�j||�S(NRRi(RR(RtstptnR((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pytngettextOstloadert
extensionssjinja2.ext.i18nt_RRtnewstylet
TestExtensioncBs/eZedg�ZdZd�Zd�ZRS(ttesti*cCsbtj|jdtjd�|jd�tjtd�tj�g�g�jt	|j
�j�S(Nt_dumpt	sandboxedtext_attrs.importable_object(RtOutputtcall_methodtEnvironmentAttributetattrtImportedNamet__name__tContextReferencet
set_linenoR	tstreamtlineno(tselftparser((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pytparsekscCsd||||jfS(Ns%s|%s|%s|%s(tblocks(R.R"R#timported_objectR((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR!ss
(R)t
__module__tsetttagsR#R0R!(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyRgs	tPreprocessorExtensioncBseZdd�ZRS(cCs|jdd�S(Ns[[TEST]]s({{ foo }})(treplace(R.tsourcetnametfilename((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyt
preprocess~sN(R)R3tNoneR;(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR6|stStreamFilterExtensioncBseZd�Zd�ZRS(ccsKxD|D]<}|jdkr>x$|j|�D]}|Vq,Wq|VqWdS(Ntdata(ttypetinterpolate(R.R,ttokentt((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyt
filter_stream�s

ccs2d}t|j�}|j}x�tj|j|�}|dkrFPn|j||j�!}|rvt|d|�Vn|t|j�7}t|dd�Vt|dd�Vt|dd�Vt|d|j	d��Vt|d	d�Vt|d
d�V|j
�}q!||kr.t|d|j|�VndS(NiR>tvariable_beginR9RtlparenRitrparentvariable_end(tlentvalueR-t_gettext_retsearchR<tstartRRtgrouptend(R.RAtposRNR-tmatchRI((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR@�s(	(R)R3RCR@(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR=�s	tExtensionsTestCasecBsbeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
cCsAt�}|jd�|jd�}|j�dks=t�dS(Nsjinja2.ext.autoescapes6{% autoescape true %}{{ "<test>" }}{% endautoescape %}s&lt;test&gt;(Rt
add_extensiontfrom_stringtrendertAssertionError(R.tenvRB((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_extend_late�s	
cCsdtddg�}|jd�}|j�dks9t�|jd�}|j�dks`t�dS(NRsjinja2.ext.loopcontrolss�
            {%- for item in [1, 2, 3, 4] %}
                {%- if item % 2 == 0 %}{% continue %}{% endif -%}
                {{ item }}
            {%- endfor %}t13s�
            {%- for item in [1, 2, 3, 4] %}
                {%- if item > 2 %}{% break %}{% endif -%}
                {{ item }}
            {%- endfor %}t12(RRSRTRU(R.RVttmpl((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_loop_controls�s		cCs=tddg�}|jd�}|j�dks9t�dS(NRs
jinja2.ext.dos�
            {%- set items = [] %}
            {%- for char in "foo" %}
                {%- do items.append(loop.index0 ~ char) %}
            {%- endfor %}{{ items|join(', ') }}s
0f, 1o, 2o(RRSRTRU(R.RVRZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_do�s	cCsntddg�}|jd�}g|jdddd�j�D]}|j�^q@dd	gksjt�dS(
NRsjinja2.ext.with_sy        {% with a=42, b=23 -%}
            {{ a }} = {{ b }}
        {% endwith -%}
            {{ a }} = {{ b }}        taitbis42 = 23s1 = 2(RRSRTt
splitlineststripRU(R.RVRZtx((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyt	test_with�s
	4cCs=tdtg�}|jd�}|j�dks9t�dS(NRs
{% test %}sFalse|42|23|{}(RRRSRTRU(R.RVRZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_extension_nodes�scCstjtdkst�dS(Ns.TestExtension(Rt
identifierR)RU(R.((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_identifier�scCshtdtg�}|j�}xC||fD]5}x,t|j�D]}|j|ksAt�qAWq+WdS(NR(RRtoverlayRRtenvironmentRU(R.toriginalRfRVtext((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_rebinding�s
cCsCtdtg�}|jd�}|jdd�dks?t�dS(NRs
{[[TEST]]}tfooi*s{(42)}(RR6RSRTRU(R.RVRZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_preprocessor_extension�scCsStdtg�}d�|jd<|jd�}|j�}|dksOt�dS(NRcSs
|j�S(N(tupper(Ra((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyt<lambda>�sRsFoo _(bar) BazsFoo BAR Baz(RR=tglobalsRSRTRU(R.RVRZtout((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_streamfilter_extension�s
cCs�dtfd��Y}dtfd��Y}td||g�}t|j��}|dj|kslt�|dj|ks�t�dS(NtT1cBseZdZRS(i(R)R3tpriority(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyRr�stT2cBseZdZRS(i(R)R3Rs(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyRt�sRii(RRtlisttiter_extensionst	__class__RU(R.RrRtRVRi((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_extension_ordering�s(R)R3RWR[R\RbRcReRjRlRqRx(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyRQ�s										tInternationalizationTestCasecBsGeZd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs1tjd�}|jdd�dks-t�dS(Ns
child.htmlRRs<title>fehlend</title>pass auf(ti18n_envtget_templateRTRU(R.RZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyt
test_trans�scCs[tjd�}|jdddd�dks3t�|jdddd�dksWt�dS(	Nsplural.htmlRRt
user_countisEin Benutzer onlineis2 Benutzer online(RzR{RTRU(R.RZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_trans_plural�s$csdtjd�}�fd��d�_|jddd��dksKt��jdks`t�dS(	Nsplural2.htmlcs�jd7_dS(Ni(tcalled((tget_user_count(s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR�siRRR�t1si(RzR{RRTRU(R.RZ((R�s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyt test_trans_plural_with_functionss
	$cCsAtjd�}|j�dks't�|jttjd�dS(Ns_{% trans foo=42, count=2 %}{{ count }} item{% pluralize count %}{{ count }} items{% endtrans %}s2 itemss6{% trans foo %}...{% pluralize bar %}...{% endtrans %}(RzRSRTRUt
assert_raisesR(R.RZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_complex_plural
scCs7tjd�}|jdddd�dks3t�dS(Nsstringformat.htmlRRR}isBenutzer: 5(RzR{RTRU(R.RZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_trans_stringformattingscCs}ddlm}tdjd��}t||dgi��ddd	gfd
dd	gfdddgfgksyt�dS(Ni����(t
babel_extracts�
        {{ gettext('Hello World') }}
        {% trans %}Hello World{% endtrans %}
        {% trans %}{{ users }} user{% pluralize %}{{ users }} users{% endtrans %}
        tasciiRRRiuHello Worldiiu%(users)s useru%(users)s users(sgettextsngettextR(u%(users)s useru%(users)s usersN(t
jinja2.extR�R
tencodeRuR<RU(R.R�R8((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_extractscCs�ddlm}tdjd��}t||ddd	gi��d
dddgfd
dddgfddddgfgks�t�dS(Ni����(R�s�
        {# trans first #}
        {{ gettext('Hello World') }}
        {% trans %}Hello World{% endtrans %}{# trans second #}
        {#: third #}
        {% trans %}{{ users }} user{% pluralize %}{{ users }} users{% endtrans %}
        sutf-8RRRttranst:iuHello Worldtfirstitsecondiu%(users)s useru%(users)s userstthird(sgettextsngettextR(u%(users)s useru%(users)s usersN(R�R�R
R�RuR<RU(R.R�R8((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_comment_extract"s(	R)R3R|R~R�R�R�R�R�(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyRy�s							
t$NewstyleInternationalizationTestCasecBsbeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
cCs1tjd�}|jdd�dks-t�dS(Ns
child.htmlRRs<title>fehlend</title>pass auf(tnewstyle_i18n_envR{RTRU(R.RZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR|4scCs[tjd�}|jdddd�dks3t�|jdddd�dksWt�dS(	Nsplural.htmlRRR}isEin Benutzer onlineis2 Benutzer online(R�R{RTRU(R.RZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR~8s$cCsAtjd�}|j�dks't�|jttjd�dS(Ns_{% trans foo=42, count=2 %}{{ count }} item{% pluralize count %}{{ count }} items{% endtrans %}s2 itemss6{% trans foo %}...{% pluralize bar %}...{% endtrans %}(R�RSRTRUR�RRz(R.RZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR�=scCs7tjd�}|jdddd�dks3t�dS(Nsstringformat.htmlRRR}isBenutzer: 5(R�R{RTRU(R.RZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR�DscCs[tjd�}|jdddd�dks3t�|jdddd�dksWt�dS(	Ns
ngettext.htmlRRtapplesis1 Apfeliu5 Äpfel(R�R{RTRU(R.RZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_newstyle_pluralHs$cCs�tdddg�}|jd�d�dt�|jd�}|jdt�d	ks^t�|jdt�d
ks|t�dS(NRsjinja2.ext.autoescapesjinja2.ext.i18ncSsdS(Nu<strong>Wert: %(name)s</strong>((Ra((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyRnPscSs|S(N((RRR((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyRnQsRsI{% autoescape ae %}{{ gettext("foo", name="<test>") }}{% endautoescape %}taes#<strong>Wert: &lt;test&gt;</strong>s<strong>Wert: <test></strong>(Rtinstall_gettext_callablestTrueRSRTRUtFalse(R.RVRB((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_autoescape_supportMs	cCs7tjd�}|jdddd�dks3t�dS(Nsngettext_long.htmlR�iRRu5 Äpfel(R�R{RTRU(R.RZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_num_used_twiceWscCs7tjddt�}tjd|�dk	s3t�dS(Nso
            {% trans num=3 %}{{ num }} apple{% pluralize
            %}{{ num }} apples{% endtrans %}
        traws:l_ngettext, u?'\%\(num\)s apple', u?'\%\(num\)s apples', 3(R�tcompileR�treRKR<RU(R.R8((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_num_called_num[s	cCs�tjd�}tjd�}tjd�}|jdddd�dksQt�|jd	d
dd�dksut�|jdddd�d
ks�t�dS(Nstransvars1.htmlstransvars2.htmlstransvars3.htmltnumiRRsBenutzer: 1tcountisBenutzer: 23i*sBenutzer: 42(R�R{RTRU(R.tt1tt2tt3((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_trans_varsgs$$cCstjd�}|j�dks't�tjd�}|jdd�dksTt�tjd�}|j�dks{t�dS(	Nsnovars.htmls	%(hello)ss	vars.htmlRkt42s	42%(foo)ssexplicitvars.htmls%(foo)s(R�R{RTRU(R.RB((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_novars_vars_escapingos(R)R3R|R~R�R�R�R�R�R�R�R�(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR�2s						
			tAutoEscapeTestCasecBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs�tddgdt�}|jd�}|j�j�dddgksNt�tddgdt�}|jd�}|j�j�dddgks�t�dS(NRsjinja2.ext.autoescapet
autoescapes�
            {{ "<HelloWorld>" }}
            {% autoescape false %}
                {{ "<HelloWorld>" }}
            {% endautoescape %}
            {{ "<HelloWorld>" }}
        u&lt;HelloWorld&gt;u<HelloWorld>s�
            {{ "<HelloWorld>" }}
            {% autoescape true %}
                {{ "<HelloWorld>" }}
            {% endautoescape %}
            {{ "<HelloWorld>" }}
        (RR�RSRTtsplitRUR�(R.RVRZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_scoped_settingzs				cCsjtddgdt�}|jd�}|j�dks?t�|jd�}|j�dksft�dS(NRsjinja2.ext.autoescapeR�s&{{ {"foo": "<test>"}|xmlattr|escape }}s foo="&lt;test&gt;"sO{% autoescape false %}{{ {"foo": "<test>"}|xmlattr|escape }}{% endautoescape %}s# foo=&#34;&amp;lt;test&amp;gt;&#34;(RR�RSRTRU(R.RVRZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_nonvolatile�s	cCsgtddgdt�}|jd�}|jdt�dksEt�|jdt�dksct�dS(NRsjinja2.ext.autoescapeR�sM{% autoescape foo %}{{ {"foo": "<test>"}|xmlattr|escape }}{% endautoescape %}Rks# foo=&#34;&amp;lt;test&amp;gt;&#34;s foo="&lt;test&gt;"(RR�RSRTR�RU(R.RVRZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyt
test_volatile�s
	cCsCtddg�}|jd�}|jdd�dks?t�dS(NRsjinja2.ext.autoescapesT{% autoescape true %}{% set x = "<x>" %}{{ x }}{% endautoescape %}{{ x }}{{ "<y>" }}Rais
&lt;x&gt;1<y>(RRSRTRU(R.RVRZ((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_scoping�scCs�tddg�}d}|j|�}|jdt�j�ddksOt�|jdt�j�dtjkszt�tddg�}|j	|dt�}d|ks�t�tddgd	t�}|j	|dt�}d
|ks�t�dS(NRsjinja2.ext.autoescapes�
        {% autoescape val %}
            {% macro foo(x) %}
                [{{ x }}]
            {% endmacro %}
            {{ foo().__class__.__name__ }}
        {% endautoescape %}
        {{ '<testing>' }}
        tvalitMarkupR�s<testing>\nR�s&lt;testing&gt;\n(
RRSRTR�R�RUR�RR)R�(R.RVt
tmplsourceRZtpysource((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyttest_volatile_scoping�s	(+	(R)R3R�R�R�R�R�(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR�xs
					cCshtj�}|jtjt��|jtjt��|jtjt��|jtjt��|S(N(tunittestt	TestSuitetaddTestt	makeSuiteRQRyR�R�(tsuite((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyR��s(,t__doc__R�R�tjinja2.testsuiteRtjinja2RRRRtjinja2.exceptionsRR�Rtjinja2.lexerRRtjinja2._compatR	R
RRtimportable_objectR�RJti18n_templatestnewstyle_i18n_templatesRRRRzRotupdateR�R�R�RR6R=RQRyR�R�R�(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/ext.pyt<module>
sx""

!S<FM

Zerion Mini Shell 1.0