ó {G_Tc@s~ddlZddlmZdd d„ƒYZdd d„ƒYZdejfd„ƒYZd „Zed krzeƒndS( iÿÿÿÿN(tTemplatetBagcBseZRS((t__name__t __module__(((s,/usr/local/lib/python2.7/test/test_pep292.pyR stMappingcBseZd„ZRS(cCsW|}xJ|jdƒD]9}yt||ƒ}Wqtk rNt|ƒ‚qXqW|S(Nt.(tsplittgetattrtAttributeErrortKeyError(tselftnametobjtpart((s,/usr/local/lib/python2.7/test/test_pep292.pyt __getitem__ s (RRR(((s,/usr/local/lib/python2.7/test/test_pep292.pyR st TestTemplatecBs†eZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „ZRS(cCsWtdƒ}|j|jtddddƒƒdƒ|jt|jtddƒƒdS(Ns,$who likes to eat a bag of $what worth $$100twhottimtwhatthams(tim likes to eat a bag of ham worth $100(Rt assertEqualt substitutetdictt assertRaisesR (R ts((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_regular_templatess !cCsitdƒ}tddddddƒ}|j|j|ƒdƒ|jt|jtddddƒƒdS( Ns$who likes ${what} for ${meal}RRRRtmealtdinnerstim likes ham for dinner(RRRRRR (R Rtd((s,/usr/local/lib/python2.7/test/test_pep292.pyt"test_regular_templates_with_bracess  cCso|j}tdƒ}||jtddddƒƒdƒtdƒ}||jtddddƒƒdƒdS( Ns-$who likes to eat a bag of $$what worth $$100RRRRs*tim likes to eat a bag of $what worth $100s $who likes $$s tim likes $(RRRR(R teqR((s,/usr/local/lib/python2.7/test/test_pep292.pyt test_escapes%s    cCsT|j}tdƒ}tddƒ}||j|ƒdƒ||j|ƒdƒdS(Ns%(foo)s $foo ${foo}tfootbazs%(foo)s baz baz(RRRRtsafe_substitute(R RRR((s,/usr/local/lib/python2.7/test/test_pep292.pyt test_percents-s   cCsv|j}tdƒ}tddƒ}||j|ƒdƒ||j|ƒdƒtdƒ}||j|ƒdƒdS(Ns&tim has eaten $count bags of ham todaytcountis!tim has eaten 7 bags of ham todays(tim has eaten ${count} bags of ham today(RRRRR"(R RRR((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_stringification4s   cCsZ|j}tdƒ}tdd dd ƒ}||j|ƒdƒ||j|ƒdƒdS( Ns$who ate ${meal}RRtfredRRskung paos'('tim', 'fred') ate ('ham', 'kung pao')(stimR&(shamskung pao(RRRRR"(R RRR((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_tupleargs=s   c CsÌ|j}tdƒ}||jtddƒƒdƒ||jtddƒƒdƒ||jtdddd ƒƒd ƒ||jtddddƒƒd ƒ||jtdddddd ƒƒd ƒdS( Ns$who likes ${what} for ${meal}RRstim likes ${what} for ${meal}RRs$who likes ham for ${meal}RRs$who likes ham for dinnerstim likes ham for ${meal}stim likes ham for dinner(RRR"R(R RR((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_SafeTemplateDs  $cCs…|j}tdƒ}|t|jtddƒƒtdƒ}|t|jtddƒƒtdƒ}|t|jtddƒƒdS(Ns $who likes $RRs$who likes ${what)s$who likes $100(RRt ValueErrorRR(R traisesR((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_invalid_placeholdersPs    cCs~dtfd„ƒY}tƒ}tƒ|_tƒ|j_d|jj_d|j_|dƒ}|j|j|ƒdƒdS(Nt PathPatterncBseZdZRS(s[_a-z][._a-z0-9]*(RRt idpattern(((s,/usr/local/lib/python2.7/test/test_pep292.pyR,ZsRRs,$bag.foo.who likes to eat a bag of $bag.whatstim likes to eat a bag of ham( RRRtbagR RRRR(R R,tmR((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_idpattern_overrideYs    cCsÌdtfd„ƒY}tƒ}tƒ|_tƒ|j_d|jj_d|j_|dƒ}|j|j|ƒdƒdtfd„ƒY}|dƒ}|j t |jiƒ|j t |j iƒdS( Nt MyPatterncBseZdZRS(s¾ (?P@{2}) | @(?P[_a-z][._a-z0-9]*) | @{(?P[_a-z][._a-z0-9]*)} | (?P@) (RRtpattern(((s,/usr/local/lib/python2.7/test/test_pep292.pyR1esRRs,@bag.foo.who likes to eat a bag of @bag.whatstim likes to eat a bag of hamt BadPatterncBseZdZRS(s (?P.*) | (?P@{2}) | @(?P[_a-z][._a-z0-9]*) | @{(?P[_a-z][._a-z0-9]*)} | (?P@) | (RRR2(((s,/usr/local/lib/python2.7/test/test_pep292.pyR3ts( RRRR.R RRRRRR)R"(R R1R/RR3((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_pattern_overrideds     cCs>tdƒ}tddddƒ}|j|j|ƒdƒdS(Ns$who likes $whatRutÿmRufþ edutÿm likes fþ ed(RRRR(R RR((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_unicode_values€s cCsä|j}tdƒ}||jddddƒdƒ||jtddƒddƒdƒ||jtddddƒddddƒdƒtd ƒ}||jtd d ƒd d ƒdƒ||jtd dƒd dƒdƒdS(Ns$who likes $whatRRRRs tim likes hamR&skung paosthe mapping is $mappingR tnonetmappingtbozosthe mapping is bozotonettwosthe mapping is two(RRRR(R RR((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_keyword_arguments…s  %  cCs(|j}|j}tdƒ}||jddddƒdƒ||jtddƒddƒdƒ||jtddddƒddddƒdƒtd ƒ}||jtd d ƒd d ƒdƒ||jtd dƒd dƒdƒtd dƒ}|t|j|iƒ|t|j|iƒdS(Ns$who likes $whatRRRRs tim likes hamR&skung paosthe mapping is $mappingR R6R7R8sthe mapping is bozoR9R:sthe mapping is two(RRRR"Rt TypeErrorR(R RR*RR((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_keyword_arguments_safe“s    %  cCs$|j}|j}dtfd„ƒY}|dƒ}||jddddƒdƒ|t|jƒ||jddddƒdƒ||jƒd ƒ|d ƒ}|t|jtddddƒƒ||jƒd ƒd tfd „ƒY}|d ƒ}|j|jtdd ddƒƒdƒdS(NtAmpersandTemplatecBseZdZRS(t&(RRt delimiter(((s,/usr/local/lib/python2.7/test/test_pep292.pyR>¨ssthis &gift is for &{who} &&tgifttbudRtyousthis bud is for you &sthis &gift is for &{who} &t PieDelimscBseZdZRS(t@(RRR@(((s,/usr/local/lib/python2.7/test/test_pep292.pyRD³ss-@who likes to eat a bag of @{what} worth $100RRRs(tim likes to eat a bag of ham worth $100(RRRRR R"R)R(R RR*R>RRD((s,/usr/local/lib/python2.7/test/test_pep292.pyttest_delimiter_override¥s    " !(RRRRRR#R%R'R(R+R0R4R5R;R=RF(((s,/usr/local/lib/python2.7/test/test_pep292.pyRs         cCs*ddlm}tg}|j|ŒdS(Niÿÿÿÿ(t test_support(ttestRGRt run_unittest(RGt test_classes((s,/usr/local/lib/python2.7/test/test_pep292.pyt test_mainºs t__main__((( tunittesttstringRRRtTestCaseRRKR(((s,/usr/local/lib/python2.7/test/test_pep292.pyts  £