[Z-Lc@sddlmZddlmZddlmZddlZddlZddlZddlZddl Z de j fdYZ de j fdYZ d e j fd YZ d e j fd YZd e j fdYZde j fdYZddZde j fdYZde fdYZde fdYZde j fdYZde fdYZde j fdYZedkre jndS(i(tTemplate(tCheetahWrapper(tDummyTransactionNtCommandLineTestcBseZdZRS(c Csd}x%|jddkr-tj}q Wtd|d}|j||jtj}|jdddd|gtj j |\}}t ||g}t ||}|S( Nt-is%s.tmpltwtcheetahtcompiles--quiets --nobackup( tfindttempfiletmktemptopentwritetcloseRtmaintostpathtsplitt loadModuletgetattr( tselftsourcet sourcefiletfdtwrapt module_patht module_nametmodulettemplate((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pytcreateAndCompiles   (t__name__t __module__R(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR stJBQ_UTF8_Test1cBseZdZRS(cCsdtjdd}tjdd}|}||_d|_d|j_t|s`tdS(NRs#Main file with |$v| $othersOther template with |$v|uUnicode String(RRtothertvtunicodetAssertionError(RtttotherTR!((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pytrunTests      (RRR'(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR stJBQ_UTF8_Test2cBseZdZRS(cCsdtjdd}tjdd}|}||_d|_d|j_t|s`tdS(NRs#Main file with |$v| $othersOther template with |$v|uUnicode String with eacute éuUnicode String(RRR!R"R#R$(RR%R&R!((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR'.s      (RRR'(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR(-stJBQ_UTF8_Test3cBseZdZRS(cCsdtjdd}tjdd}|}||_d|_d|j_t|s`tdS(NRs#Main file with |$v| $othersOther template with |$v|uUnicode String with eacute éuUnicode String and an eacute é(RRR!R"R#R$(RR%R&R!((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR'>s      (RRR'(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR)=stJBQ_UTF8_Test4cBseZdZRS(cCs4tjdd}d|_t|s0tdS(NRsI#encoding utf-8 Main file with |$v| and eacute in the template ésUnicode String(RRR"R#R$(RR%((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR'Ms   (RRR'(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR*LstJBQ_UTF8_Test5cBseZdZRS(cCs4tjdd}d|_t|s0tdS(NRsI#encoding utf-8 Main file with |$v| and eacute in the template éuUnicode String(RRR"R#R$(RR%((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR'Vs   (RRR'(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR+UscCs|rt|tstnytj|}Wnetk rd}z7tj||\}}}tj ||||}Wd|r|j nXnX|S(N( t isinstancetlistR$tsystmodulestKeyErrortNonetimpt find_modulet load_moduleR (t moduleNameRtmodtfptpathnamet description((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR^s tJBQ_UTF8_Test6cBseZdZRS(cCs:d}tjd|}d|_t|s6tdS(Nsu#encoding utf-8 #set $someUnicodeString = u"Bébé" Main file with |$v| and eacute in the template éRuUnicode String(RRR"R#R$(RRR%((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR'os (RRR'(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR:nstJBQ_UTF8_Test7cBseZdZRS(cCs7d}|j|}d|_t|s3tdS(Nsu#encoding utf-8 #set $someUnicodeString = u"Bébé" Main file with |$v| and eacute in the template éuUnicode String(RR"R#R$(RRR((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR'zs (RRR'(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR;ystJBQ_UTF8_Test8cBseZdZdZRS(cCsAd}|j|}t|jd}|jd|dS(NsF#encoding utf-8 #set $someUnicodeString = u"Bébé" $someUnicodeStringsutf-8sBébé(RR#tencodet assertEquals(RRRta((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyttestStaticCompilescCs>d}td|}t|jd}|jd|dS(NsF#encoding utf-8 #set $someUnicodeString = u"Bébé" $someUnicodeStringRsutf-8sBébé(RR#R=R>(RRRR?((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyttestDynamicCompiles(RRR@RA(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR<s tEncodeUnicodeCompatTestcBseZdZdZRS(sx Taken initially from Red Hat's bugzilla #529332 https://bugzilla.redhat.com/show_bug.cgi?id=529332 cCsytddd}d|_|j}t|tsHtd|ft|}t|tsutd|fdS(Ns Foo ${var}tfiltert EncodeUnicodeu+Text with some non-ascii characters: åäös(Template.respond() should return unicodes7Template.__str__() should return a UTF-8 encoded string(RtvartrespondR,R#R$tstr(RR%trc((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyR's   ! (RRt__doc__R'(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyRBstUnicode_in_SearchList_TestcBs#eZdZdZdZRS(cCs_d}|j|}|r*t|ts0t|didd6g}|js[tdS(NsThis is $adjectivet searchListuneatt adjective(Rt issubclassRR$RF(RRR((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyttest_BasicASCIIs cCsfd}|j|}|r*t|ts0t|didd6dd6g}|jsbtdS(NsThis is $foo $adjectiveRKtbartfoou$ยินดีต้อนรับRL(RRMRR$RF(RRR((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyt test_Thais cCsed}d}|j|}|r0t|ts6t|di|d6g}|jsatdS(Ns$ยินดีต้อนรับsThis is $adjectiveRKRL(RRMRR$RF(Rtutf8RR((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyttest_Thai_utf8s (RRRNRQRS(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyRJs  tInlineSpanishTestcBs#eZdZdZdZRS(cCs tt|jd|_dS(NsI Pagina del vendedor $header

Bienvenido $nombre.




Usted tiene $numpedidos_noconf pedidós sin confirmar.

Bodega tiene fecha para $numpedidos_bodega pedidos.
(tsuperRTtsetUpR(R((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyRVscCs?|jtt|jdidd6dd6dd6dd6gdS(s0 Test a template lacking a proper #encoding tag RKttheadertnombretnumpedidos_bodegatnumpedidos_noconfN(tfailUnlessRaisestUnicodeDecodeErrorRR(R((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyt test_failurescCsUd|j}t|didd6dd6dd6dd6g}|jt|dS( s- Test a template with a proper #encoding tag s#encoding utf-8 %sRKRWRXRYRZR[N(RRt assertTrueR#(RR((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyt test_successs  (RRRVR^R`(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyRTs  t__main__(tCheetah.TemplateRtCheetahRRR2RR.R tunittesttTestCaseRR R(R)R*R+R1RR:R;R<RBRJRTRR(((sB/opt/freeware/lib/python2.7/site-packages/Cheetah/Tests/Unicode.pyts,         '