ok

Mini Shell

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

�
��Rc@sdZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZmZddlmZe
�Zdefd��YZd	efd
��YZdefd��YZd
efd��YZd�ZdS(s�
    jinja2.testsuite.api
    ~~~~~~~~~~~~~~~~~~~~

    Tests the public API and related stuff.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
i����N(t
JinjaTestCase(tnext(	tEnvironmentt	UndefinedtDebugUndefinedtStrictUndefinedtUndefinedErrortmetatis_undefinedtTemplatet
DictLoader(tCyclertExtendedAPITestCasecBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs�ddlm}x�t�|�fD]�}|jd�}|jdidd6�dks]t�|jd�}|jdidd6�dks�t�|jd	�}|jdidd6�d
ks#t�q#WdS(Ni����(tSandboxedEnvironments{{ foo.items()|list }}tfooi*titemss[('items', 42)]s{{ foo|attr("items")()|list }}s{{ foo["items"] }}t42(tjinja2.sandboxR
Rtfrom_stringtrendertAssertionError(tselfR
tenvttmpl((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_item_and_attributes%%cCspd�}td|�}|jd�}|jdd
�dksEt�|jd�}|j�d	kslt�dS(NcSs|dkrd}n|S(Nu(tNone(tvalue((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pytfinalize_none_empty*s	tfinalizes,{% for item in seq %}|{{ item }}{% endfor %}tseqiRs||1|foos<{{ none }}>s<>(Nisfoo(RRRRR(RRRR((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_finalizer)s	cCs�d}t|�}x?||D]3}|j|ks8t�t|�|kst�qWt|�|jdksst�|j�|jdks�t�dS(Niii(iii(RtcurrentRRtreset(RRtctitem((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_cycler4s

cCs�tjd�}|�dks$t�|dd�dks?t�tjddt�}t|��sit�tjd�}|dd�dks�t�dS(NRi*tundefined_to_nones42 + fooiT(Rtcompile_expressionRRtFalseR(Rtexprtexpr2((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_expressions?scCs�td�}tj|�|ks't�tj|g�|ksEt�tj|g�|ksct�tj|�|ks~t�dS(NtContent(R	Rtget_templateRtselect_templatetget_or_select_template(Rtt((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_template_passthroughIs
cCs�d�}td|dtidd6dd6��}|jd�}|jdd�dks_t�|jd�}|jdd�d	ks�t�|jd�}|jdd�dks�t�dS(
NcSs)|dksd|krtS|jd�S(Nt.s.html(RR&tendswith(tname((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pytselect_autoescapeQst
autoescapetloaders	{{ foo }}stest.txts	test.htmlRs<foo>s&lt;foo&gt;(RR
R+RRR(RR3RR.((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_autoescape_autoselectPs	(t__name__t
__module__RRR#R)R/R6(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyRs				
	tMetaTestCasecBs#eZd�Zd�Zd�ZRS(cCs|tjd�}tj|�}|tdg�ks9t�tjd�}tj|�}|tdddg�ksxt�dS(Ns!{% set foo = 42 %}{{ bar + foo }}tbars�{% set foo = 42 %}{{ bar + foo }}{% macro meh(x) %}{{ x }}{% endmacro %}{% for item in seq %}{{ muh(item) + meh(seq) }}{% endfor %}Rtmuh(RtparseRtfind_undeclared_variablestsetR(Rtasttx((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_find_undeclared_variablesdscCs�tjd�}tj|�}t|�dks6t�t|�dksNt�t|�gksft�tjd�}tj|�}t|�ddddgks�t�dS(Ns/{% extends "layout.html" %}{% include helper %}slayout.htmlsx{% extends "layout.html" %}{% from "test.html" import a, b as c %}{% import "meh.html" as meh %}{% include "muh.html" %}s	test.htmlsmeh.htmlsmuh.html(RR<Rtfind_referenced_templatesRRRtlist(RR?ti((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyt test_find_refererenced_templatesoscCs�tjd�}tj|�}t|�ddgks<t�tjd�}tj|�}t|�ddgksxt�tjd�}tj|�}t|�dddgks�t�tjd�}tj|�}t|�dddgks�t�dS(Ns&{% include ["foo.html", "bar.html"] %}sfoo.htmlsbar.htmls&{% include ("foo.html", "bar.html") %}s+{% include ["foo.html", "bar.html", foo] %}s+{% include ("foo.html", "bar.html", foo) %}(RR<RRBRCRR(RR?RD((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_find_included_templates}s!(R7R8RARERF(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyR9bs		tStreamingTestCasecBs,eZd�Zd�Zd�Zd�ZRS(cCs�tjd�}|jdttd���}|jt|�d�|jt|�d�|jt|�d�|jt|�d�|jt|�d�|jt|�d	�dS(
NsQ<ul>{% for item in seq %}<li>{{ loop.index }} - {{ item }}</li>{%- endfor %}</ul>Ris<ul>s<li>1 - 0</li>s<li>2 - 1</li>s<li>3 - 2</li>s<li>4 - 3</li>s</ul>(RRtstreamRCtrangetassert_equalR(RRRH((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_basic_streaming�scCsmtjd�}|jdttd���}|jdd�|jt|�d�|jt|�d�dS(NsQ<ul>{% for item in seq %}<li>{{ loop.index }} - {{ item }}</li>{%- endfor %}</ul>Ritsizeiu <ul><li>1 - 0</li><li>2 - 1</li>u!<li>3 - 2</li><li>4 - 3</li></ul>(RRRHRCRItenable_bufferingRJR(RRRH((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_buffered_streaming�s
cCsetjd�}|j�}|js+t�|jd�|jsGt�|j�|jsat�dS(Nti(RRRHtbufferedRRMtdisable_buffering(RRRH((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_streaming_behavior�s

cCs�tj�}z{tjd�}|j�}|jtjj|d�d�t	tjj|d�d��}|j
|j�d�WdQXWdtj
|�XdS(Nu✓sdump.txtsutf-8trbs✓(ttempfiletmkdtempRRRHtdumptostpathtjointopentassertEqualtreadtshutiltrmtree(RttmpRRHtf((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_dump_stream�s! (R7R8RKRNRRRa(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyRG�s				tUndefinedTestCasecBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCs\d�}td�}|jd|�dks3t�td�}|jt|jd|�dS(NcSs
t��dS(N(t
StopIteration(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest�ssA{{ test() }}BRdtABsA{{ test().missingattribute }}B(R	RRt
assert_raisesR(RRdR.((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_stopiteration_is_undefined�s
	cCs;ytd�jWntk
r$nXts7td��dS(NtFoosExpected actual attribute error(Rt__dict__tAttributeErrorR&R(R((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyt%test_undefined_and_special_attributes�s

cCs�tdt�}|j|jd�j�d�|jt|jd�j�|j|jd�j�d�|j|jd�j�d�|j|jd	�jd
d�d�|j|jd
�j�d�dS(Nt	undefineds
{{ missing }}us{{ missing.attribute }}s{{ missing|list }}s[]s{{ missing is not defined }}tTrues{{ foo.missing }}Ri*ROs{{ not missing }}(RRRJRRRfR(RR((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_default_undefined�s	%cCs�tdt�}|j|jd�j�d�|jt|jd�j�|j|jd�j�d�|j|jd�j�d�|j|jd�jd	d
�d�|j|jd�j�d�dS(
NRls
{{ missing }}s{{ missing.attribute }}s{{ missing|list }}s[]s{{ missing is not defined }}Rms{{ foo.missing }}Ri*u,{{ no such element: int object['missing'] }}s{{ not missing }}(RRRJRRRfR(RR((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_debug_undefined�s	cCs�tdt�}|jt|jd�j�|jt|jd�j�|jt|jd�j�|j|jd�j�d�|jt|jd�jdd	�|jt|jd
�j�|j|jd�j�d�dS(
NRls
{{ missing }}s{{ missing.attribute }}s{{ missing|list }}s{{ missing is not defined }}Rms{{ foo.missing }}Ri*s{{ not missing }}s&{{ missing|default("default", true) }}tdefault(RRRfRRRRJ(RR((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_strict_undefined�s"cCs)td�}|jt|jdd�dS(Ns{{ var[42].foo }}tvari(R	RfRR(RR.((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_indexing_gives_undefined�scCs[yt�jdd��Wn(tk
rD}|jdksWt�nXtsWtd��dS(Ntsplits'None' has no attribute 'split'sexpected exception(RtgetattrRRtmessageRR&(Rte((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_none_gives_proper_error�s
cCs[ytdddd��Wn(tk
rD}|jdksWt�nXtsWtd��dS(Ntobji*R2tuppers%'int object' has no attribute 'upper'sexpected exception(RRRvRR&(RRw((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyttest_object_repr�s
(
R7R8RgRkRnRoRqRsRxR{(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyRb�s			
		
		cCshtj�}|jtjt��|jtjt��|jtjt��|jtjt��|S(N(tunittestt	TestSuitetaddTestt	makeSuiteRR9RGRb(tsuite((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyR��s(t__doc__R|RWRTR]tjinja2.testsuiteRtjinja2._compatRtjinja2RRRRRRRR	R
tjinja2.utilsRRRR9RGRbR�(((s8/usr/lib/python2.7/site-packages/jinja2/testsuite/api.pyt<module>
s@	G-*F

Zerion Mini Shell 1.0