,Qc@sdZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z ddlmZmZddlmZmZddlmZddlmZdefd YZd efd YZd ZdS( s jinja2.testsuite.loader ~~~~~~~~~~~~~~~~~~~~~~~ Test the loaders. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. iN(t JinjaTestCaset dict_loadertpackage_loadertfilesystem_loadertfunction_loadert choice_loadert prefix_loader(t Environmenttloaders(tPYPYtPY2(tsplit_template_path(tTemplateNotFoundtLoaderTestCasecBsYeZdZdZdZdZdZdZdZdZ dZ RS( cCsVtdt}|jd}|jjdks<t|jt|jddS(Ntloaders justdict.htmltFOOs missing.html(RRt get_templatetrendertstriptAssertionErrort assert_raisesR (tselftenvttmpl((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_dict_loaderscCsVtdt}|jd}|jjdks<t|jt|jddS(NRs test.htmltBARs missing.html(RRRRRRRR (RRR((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_package_loader#scCstdt}|jd}|jjdks<t|jd}|jjdksit|jt|jddS(NRs test.htmlRs foo/test.htmlRs missing.html(RRRRRRRR (RRR((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_filesystem_loader)s cCstdt}|jd}|jjdks<t|jd}|jjdksit|jt|jddS(NRs justdict.htmlRs test.htmlRs missing.html(RRRRRRRR (RRR((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_choice_loader1s cCsVtdt}|jd}|jjdks<t|jt|jddS(NRsjustfunction.htmlRs missing.html(RRRRRRRR (RRR((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_function_loader9scCstdt}|jd}|jjdks<t|jd}|jjdksit|jt|jddS(NRs a/test.htmlRsb/justdict.htmlRtmissing(RRRRRRRR (RRR((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_prefix_loader?s cstdtjffdY}td|dd}|jd}||jdksgtt||jdk stttd|dd}|jd|jdk sttd|dd}|jd }|jd }||jd kst||jd ks6t|jd }d |jksZtd |jksotd |jkstdS( Nt TestLoadercseZfdZRS(csddfdfS(Nufoocs S(N(((tchanged(s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pytKs(tNone(Rt environmentttemplate(R!(s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyt get_sourceJs(t__name__t __module__R&((R!(s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyR IsRt cache_sizeiR%iitonettwotthree(tFalseRt BaseLoaderRRRtTruetcache(RR RRtt1tt2tt3((R!s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyt test_cachingGs( cCsuidd6}tdtj|}|jdjdksFtd|d<|jdjdksqtdS(NR*tfooRR+(RRt DictLoaderRRR(RtmappingR((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyt"test_dict_loader_cache_invalidatesas  ! cCsStdddgksttdddgks<t|jttddS(Nsfoo/barR5tbars ./foo/bars../foo(R RRR (R((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_split_template_pathhs( R'R(RRRRRRR4R8R:(((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyR s        tModuleLoaderTestCasecBseZd ZdedZdZdZdZdZ dZ dZ dZ e rse rsd Znd Zd ZRS( tdeflatedcCstt|jg}tdt|_|dk rStjddd|_ ntj |_ |jj |j d|d|j d|tdt j|j |_dj|S( NRtsuffixs.zipitzipt log_functiont py_compilet(tsuperR;tsetupRRtreg_envR#ttempfiletmkstemptarchivetmkdtemptcompile_templatestappendRt ModuleLoadertmod_envtjoin(RR>R@tlog((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyt compile_downqs  cCsjtt|jt|drftjj|jrJtj|jnt j |jd|_ndS(NRL( RBR;tteardownthasattrtostpathtisfileRGtremovetshutiltrmtreeR#(R((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyRPs cCsF|j}d|kstd|ks0td|ksBtdS(NsKCompiled "a/foo/test.html" as tmpl_a790caf9d669e39ea4d280d597ec891c4ef0404asFinished compiling templatessGCould not compile "a/syntaxerror.html": Encountered unknown tag 'endif'(ROR(RRN((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_logs  cCs|jjd}|jjd}|j|jksBt|jjd}|jjd}|j|jkstdS(Ns a/test.htmlsb/justdict.html(RDRRLRR(Rttmpl1ttmpl2((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyt _test_commons cCs|jdd|jdS(NR>R<(ROR[(R((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_deflated_zip_compilescCs|jdd|jdS(NR>tstored(ROR[(R((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_stored_zip_compilescCs|jdd|jdS(NR>(ROR#R[(R((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_filesystem_compilescCs|j|jjd}tjjd}|jjjj}t |jjj|s^t |t j ksst d|_}yddl}|jWnnX|t j kst dS(Ns a/test.htmli(RORLRRRKtget_template_keyRtmoduleR'RQRtsystmodulesR#tgctcollect(RRtkeytnameRd((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_weak_referencess   cCsd|jdt}d|ks$t|jjd}|jjjj}|jj ds`tdS(NR@sByte-compiled "a/test.html"s a/test.htmls.pyc( ROR/RRLRRRat-tmpl_3c4ddf650c1a73df961a6d3d2ce2752f1b8fd490t__file__tendswith(RRNRYtmod((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyttest_byte_compilations cCs|j}tj|jjtjidd6g|j_|jjd}|j|jd|jjd}|j|jddS(Nt DICT_TEMPLATEt DICT_SOURCEs a/test.htmlR( RORt ChoiceLoaderRLRR6Rt assert_equalR(RRNRYRZ((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyRs  "cCs|j}tji|jjd6tjidd6d6|j_|jjd}|j|jd|jjd}|j|jddS(NtMODRns test.htmltDICTsMOD/a/test.htmlRsDICT/test.html( RORt PrefixLoaderRLRR6RRqR(RRNRYRZ((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyRs   #N(R'R(R#RGR-RORPRXR[R\R^R_RhR R RmRR(((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyR;ns        cCs<tj}|jtjt|jtjt|S(N(tunittestt TestSuitetaddTestt makeSuiteR R;(tsuite((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyRys (t__doc__RRRbRERVRutjinja2.testsuiteRRRRRRRtjinja2RRtjinja2._compatR R tjinja2.loadersR tjinja2.exceptionsR R R;Ry(((s;/usr/lib/python2.7/site-packages/jinja2/testsuite/loader.pyt s     4Sp