ok

Mini Shell

Direktori : /lib/python2.7/site-packages/jinja2/testsuite/
Upload File :
Current File : //lib/python2.7/site-packages/jinja2/testsuite/imports.pyc

�
~KRc
@s�dZddlZddlmZddlmZmZddlmZm	Z	edee
ddd	d
dd���Zd
ejd<defd��YZ
defd��YZd�ZdS(s�
    jinja2.testsuite.imports
    ~~~~~~~~~~~~~~~~~~~~~~~~

    Tests the import features (with includes).

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
i����N(t
JinjaTestCase(tEnvironmentt
DictLoader(tTemplateNotFoundtTemplatesNotFoundtloadertmodules5{% macro test() %}[{{ foo }}|{{ bar }}]{% endmacro %}theaders[{{ foo }}|{{ 23 }}]t	o_printers	({{ o }})itbartImportsTestCasecBs#eZd�Zd�Zd�ZRS(cCstjd�}|jdd�dks-t�tjd�}|jdd�dksZt�tjd�}|jdd�dks�t�tjd�}|jdd�dks�t�tjd	�}|jdd�dks�t�tjd
�}|jdd�dkst�dS(Ns({% import "module" as m %}{{ m.test() }}tfooi*s[|23]s8{% import "module" as m without context %}{{ m.test() }}s5{% import "module" as m with context %}{{ m.test() }}s[42|23]s+{% from "module" import test %}{{ test() }}s;{% from "module" import test without context %}{{ test() }}s8{% from "module" import test with context %}{{ test() }}(ttest_envtfrom_stringtrendertAssertionError(tselftt((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyttest_context_importsscCsEtjd�tjd�tjd�tjd�tjd�dS(Ns-{% from "foo" import bar, baz with context %}s.{% from "foo" import bar, baz, with context %}s){% from "foo" import bar, with context %}s*{% from "foo" import bar, with, context %}s.{% from "foo" import bar, with with context %}(RR
(R((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyttest_trailing_comma+s




cCsotjd�j}|j�dks*t�t|d�s@t�|jdksUt�t|d�skt�dS(Ns
            {% macro toplevel() %}...{% endmacro %}
            {% macro __private() %}...{% endmacro %}
            {% set variable = 42 %}
            {% for item in [1] %}
                {% macro notthere() %}{% endmacro %}
            {% endfor %}
        s...t	__missingi*tnotthere(RR
RttoplevelRthasattrtvariable(Rtm((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyttest_exports2s(t__name__t
__module__RRR(((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyR
s		tIncludesTestCasecBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs�tjd�}|jdd�dks-t�tjd�}|jdd�dksZt�tjd�}|jdd�dks�t�dS(Ns{% include "header" %}Ri*s[42|23]s#{% include "header" with context %}s&{% include "header" without context %}s[|23](RR
RR(RR((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyttest_context_includeCscCs�tjd�}|jdd�dks-t�tjd�}|jdd�dksZt�tjd�}|jt|j�y|j�WnCtk
r�}|jdd	gks�t�|jd	ks�t�nXt	s�td
��d�}tjd�}||�tjd�}||d
ddg�tjd�}||d
d�tjd�}||d
d�tjd�}||d
d�tjd�}||d
d�dS(Ns#{% include ["missing", "header"] %}Ri*s[42|23]s4{% include ["missing", "missing2"] ignore missing %}ts%{% include ["missing", "missing2"] %}tmissingtmissing2sthou shalt raisec[s)d|d<|j|�dks%t�dS(Ni*Rs[42|23](RR(Rtctx((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyt
test_includes\s
s{% include x %}txRs{% include [x, "header"] %}s{% include [x] %}(
RR
RRt
assert_raisesRRt	templatestnametFalse(RRteR#((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyttest_choice_includesKs2	
cCsftjd�}|jt|j�x=dD]5}tjd|d�}|j�dks)t�q)WdS(Ns{% include "missing" %}Rswith contextswithout contexts${% include "missing" ignore missing s %}(Rswith contextswithout context(RR
R%RRR(RRtextra((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyttest_include_ignoring_missingms
cCsItdttdddd���}|jd�j�dksEt�dS(NRtmains;{% for item in [1, 2, 3] %}{% include 'item' %}{% endfor %}titems
{{ item }}t123(RRtdicttget_templateRR(Rtenv((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyt#test_context_include_with_overridesuscCs1tjd�}|j�j�dks-t�dS(Ns�
            {% macro outer(o) %}
            {% macro inner() %}
            {% include "o_printer" %}
            {% endmacro %}
            {{ inner() }}
            {% endmacro %}
            {{ outer("FOO") }}
        s(FOO)(RR
RtstripR(RR((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyttest_unoptimized_scopes|s	(RRRR*R,R3R5(((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyRAs
		"		cCs<tj�}|jtjt��|jtjt��|S(N(tunittestt	TestSuitetaddTestt	makeSuiteR
R(tsuite((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyR:�s(t__doc__R6tjinja2.testsuiteRtjinja2RRtjinja2.exceptionsRRR0RtglobalsR
RR:(((s</usr/lib/python2.7/site-packages/jinja2/testsuite/imports.pyt<module>
s
&H

Zerion Mini Shell 1.0