m +Ec@s dZdZddd!ZdkZdkZdkZedjo eiZndk l Z e i dZd Z d k lZlZd klZd fd YZdZdefdYZdeifdYZdZdZedjo endS(sDocument Template Tests s5$Id: testDTML.py 69085 2006-07-10 20:48:45Z tseaver $s$Revision: 1.15 $i iNt__main__(stestsicCs8ttiit|d}|i}|i |S(Ntr( topentostpathtjointheretnametftreadtrestclose(RRR ((t>/data/zmath/zope/lib/python/DocumentTemplate/tests/testDTML.pyt read_files  (sHTMLsString(sBasetDcBs tZdZdZdZRS(NicKs.x'|iD]\}}||i|Variable "name": min= max= count= total= median= Variable "age": min= max= count= total= median= mean= s.d.=tdatasVariable "name": min=ches max=will count=4 total= median=between jim and drew Variable "age": min=1 max=38 count=4 total=50 median=5 mean=12.5 s.d.=17(RRIRR?R@R RAtAssertionError(RRR R@RARI((R ttestSequenceSummariess  NcCsWdk}|id}|d|iddd}d}||jp t|dS(Nsp is //tdates 1995-12-25Rt christmas_daysChristmas day is 1995/12/25(tDateTimeRR?R@R RARJ(RRAR R@RN((R ttestDTMLDateFormattings   cCs<td}|dd}d}||jp t|dS(Ns%(name)sRtChris(tStringtdtR RARJ(RRAR RR((R ttestSimpleStrings cCsTdk}td}|d|iddd}d}||jp t|dS(NsT%(name capitalize spacify)s is %(date fmt=year)s/%(date fmt=month)s/%(date fmt=day)sRLs 2001-04-27Rtthe_datesThe date is 2001/4/27(RNRQR@R RARJ(RR RNR@RA((R ttestStringDateFormattings    cCsW|id}d}|ddddgddd gg}||jp t|dS( Nse s 1 2 3 4 5 6 tspamiiiiii(RR?R@RAR RJ(RRAR R@((R t testSequence1s'cCsW|id}d}|ddddgddd gg}||jp t|dS( Nse-s 1-2-3-4-5-6-RViiiiii(RR?R@RAR RJ(RRAR R@((R t testSequence2s'cCsL|id}d}|dd|dd}||jp t|dS(Ns>s!$42.00 bobs your unclespam%eggs!|RVi*(RR?R@RAtNoneR RJ(RRAR R@((R ttestNullscCs|id}|id}d}|i|||i|||id}|id}d}|i|||i||dS(Nsa sh s5 http://www.zope.org?a=b 123 s] sd (RR?thtml1thtml2RARB(RRAR[R\((R ttestUrlUnquotescCsR|id}d}|dd|dd|dd}|i||dS(Ns html= url= multi= dollars= cents= dollars,= cents,=s 4200000 html=4200000 url=4200000 multi=4200000 dollars=$4200000 cents=$4200000.00 dollars,=$4,200,000 cents,=$4,200,000.00 None html=None url=None multi=None dollars= cents= dollars,= cents,= foo bar html=<a href="spam"> foo bar url=%3Ca%20href%3D%22spam%22%3E%0Afoo%20bar multi=
foo bar dollars= cents= dollars,= cents,=RVi@@s
foo bar(RR?R@RARYR RB(RRAR R@((R ttest_fmt%s )cCs6d}|id}||id<|it|dS(Ns.. include:: /etc/passwds-tfoo(tsourceRR?R@t_varst assertRaisestNotImplementedError(RR`R@((R t&test_fmt_reST_include_directive_raisesSs cCsd}d|}|id}||id<|}|i||j|id|jdk l }|i|||jdS(Ns

HELLO WORLD

s.. raw:: html %s s-R_s""raw" directive disabled(sescape( tEXPECTEDR`RR?R@RatresulttfailIft failUnlesstcgitescape(RR`R@RfRjRe((R t$test_fmt_reST_raw_directive_disabledYs    cCs9d}|id}||id<|it||dS(Ns$.. raw:: html :file: inclusion.txts-R_(R`RR?R@RaRbRc(RR`R@((R t.test_fmt_reST_raw_directive_file_option_raiseshs cCs9d}|id}||id<|it||dS(Ns).. raw:: html :url: http://www.zope.orgs-R_(R`RR?R@RaRbRc(RR`R@((R t-test_fmt_reST_raw_directive_url_option_raisesps cCsadfdY}|id}y|d|Wntj onXdp tddS(NR_cBs0tZdZdZdefdYZRS(NcCsdS(Ni ((R((R t__len__{scCs'|djo t|n|i|S(Ni (tit IndexErrorRttestob(RRo((R t __getitem__|s RqcBs5tZdZdZdZdZdZdZRS(NcCs||_d||_dS(Nsitem %s(tindexRtvalue(RRs((R Rs cCs|iS(N(RRt(R((R tgetValuescCstddS(Ntraaalf(R(R((R tpukes( RRRYt __roles__RtgetValue__roles__Rut puke__roles__Rw(((R Rqs   (RRRnRrtBaseRq(((R R_zs  s RVisPuke error not propogated(R_RR?R@RRJ(RR_R@((R ttestPropogatedErrorxs cCsdtfdY}|id|_|id|_d}|id|}||jp t|d}|idd |}||jp t|d S( s,Test automatic rendering of callable objectstCcBstZdZdZdZRS(NicCs |idS(Ni(Rtx(R((R tys(RRRR~R(((R R}ss'The h method, s The h2 methods1, 2, The h method, 1 2s(, , s8 1, 2, The h2 methods , , RoN( R{R}RR?thth2RAR RJ(RRAR R}((R ttestRenderCallablescCsfdfdY}d|it|idf}|idd|}||jp t|dS(NtpersoncBstZdZdZdZRS(NitJimiI(RRRRt height_inches(((R Rss)Hi, my name is %s and my height is %d cm.f2.54sxHi, my name is and my height is cm.( RRtintRRARR?R RJ(RRARR ((R ttestWiths cCsVy|id}Wntj o}|}nXt|djp t| dS(Ns,success!ssuccess!(RR?R RpRtstrRJ(RR R((R t testRaises  c Csxtdddddtddtddddf}d}d }|i|d |}||jp t|dS( NtsectBRtXXXtsubtb1tb2s . s B.b1 B.b2RI(RRIR@RARR?RfRJ(RR@RfRARI((R ttestNoItemPushs 9c Cstddddtddddtddddtdd dd tdd dd f}d }d}|i|d|}||jp t|dS(NRRDREi'tkakiRFitandrewitchessieisJ , s= jim, 39 kak, 29 will, 8 andrew, 5 chessie, 2 RI(RRIR@RARR?RfRJ(RR@RfRARI((R ttestBasicHTMLIns `cCsitddtddtddf}d}d}|i|d|}||jp t|dS(NRiiis2 s 1 2 3 txxx(RRR@RARR?RfRJ(RRR@RfRA((R ttestBasicHTMLIn2s *cCs`hdd<dd<dd<}d}|i|d|}d}||jp t|dS( Ntprop_idsttitletidtgoodttimessf:=:s:title=good:id=times:(stitlesid(tnsR@RR?RYRfRARJ(RR@RfRAR((R ttestBasicHTMLIn3s !cCsotddtddtddf}d}d}|i|d|dh}||jp t|dS( NRiiis , s 1 2 3 RRI(RRR@RARR?RfRJ(RRR@RfRA((R ttestHTMLInElse s * c Cstddddtddddtddddtdd dd tdd dd f}d }d}t|d|}||jp t|dS(NRRDREi'RiRFiRiRis1 %(in data mapping)[ %(name)s, %(age)s %(in)] s= jim, 39 kak, 29 will, 8 andrew, 5 chessie, 2 RI(RRItsRARQRfRJ(RRRfRARI((R ttestBasicStringIns `(RRtHTMLR?RCRKRORSRURWRXRZR]R^RdRkRlRmR|RRRRRRRRR(((R R1s2 u #     ' .     '     cCs&ti}|itit|S(N(tunittestt TestSuitetsuitetaddTestt makeSuiteR(R((R t test_suite6s cCstiitdS(N(RtTextTestRunnertrunR(((R tmain;s(Rt __rcs_id__t __version__tsysRRRtcurdirRtDocumentTemplatettestst__path__R tDocumentTemplate.DT_HTMLRRQtExtensionClassR{RRt ExceptionRtTestCaseRRR(R{RRRQRRRRRRRRR RRRR((R t?s*