mς
­fIc           @   sz   d  k  Z  d k l Z d f  d     YZ d f  d     YZ d e  i f d     YZ d   Z e d	 j o e   n d  S(
   N(   s   Templatet   Bagc           B   s   t  Z RS(   N(   t   __name__t
   __module__(    (    (    t-   /mit/python/lib/python2.4/test/test_pep292.pyR    	   s   t   Mappingc           B   s   t  Z d   Z RS(   Nc         C   sY   |  } xL | i d  D]; } y t | |  } Wq t j
 o t |   q Xq W| S(   Nt   .(   t   selft   objt   namet   splitt   partt   getattrt   AttributeErrort   KeyError(   R   R   R   R
   (    (    R   t   __getitem__   s     (   R   R   R   (    (    (    R   R      s   t   TestTemplatec           B   s   t  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d	   Z
 d
   Z d   Z d   Z d   Z d   Z	 RS(   Nc         C   sW   t  d  } |  i | i t d d d d   d  |  i t | i t d d   d  S(   Ns,   $who likes to eat a bag of $what worth $$100t   whot   timt   whatt   hams(   tim likes to eat a bag of ham worth $100(   t   Templatet   sR   t   assertEqualt
   substitutet   dictt   assertRaisesR   (   R   R   (    (    R   t   test_regular_templates   s    !c         C   si   t  d  } t d d d d d d  } |  i | i |  d  |  i t | i t d d d d   d  S(	   Ns   $who likes ${what} for ${meal}R   R   R   R   t   mealt   dinners   tim likes ham for dinner(	   R   R   R   t   dR   R   R   R   R   (   R   R   R   (    (    R   t"   test_regular_templates_with_braces   s
    c         C   so   |  i } t d  } | | i t d d d d   d  t d  } | | i t d d d d   d  d  S(	   Ns-   $who likes to eat a bag of $$what worth $$100R   R   R   R   s*   tim likes to eat a bag of $what worth $100s   $who likes $$s   tim likes $(   R   R   t   eqR   R   R   R   (   R   R   R   (    (    R   t   test_escapes%   s    	c         C   sT   |  i } t d  } t d d  } | | i |  d  | | i |  d  d  S(   Ns   %(foo)s $foo ${foo}t   foot   bazs   %(foo)s baz baz(	   R   R   R   R   R   R   R   R   t   safe_substitute(   R   R   R   R   (    (    R   t   test_percents-   s
    	c         C   sv   |  i } t d  } t d d  } | | i |  d  | | i |  d  t d  } | | i |  d  d  S(   Ns&   tim has eaten $count bags of ham todayt   counti   s!   tim has eaten 7 bags of ham todays(   tim has eaten ${count} bags of ham today(	   R   R   R   R   R   R   R   R   R#   (   R   R   R   R   (    (    R   t   test_stringification4   s    	c      	   C   sΜ   |  i } t d  } | | i t d d   d  | | i t d d   d  | | i t d d d d	   d
  | | i t d d d d   d  | | i t d d d d d d	   d  d  S(   Ns   $who likes ${what} for ${meal}R   R   s   tim likes ${what} for ${meal}R   R   s   $who likes ham for ${meal}R   R   s   $who likes ham for dinners   tim likes ham for ${meal}s   tim likes ham for dinner(   R   R   R   R   R   R#   R   (   R   R   R   (    (    R   t   test_SafeTemplate=   s    	$c         C   s   |  i } t d  } | t | i t d d   t d  } | t | i t d d   t d  } | t | i t d d   d  S(   Ns   $who likes $R   R   s   $who likes ${what)s   $who likes $100(   R   R   t   raisesR   R   t
   ValueErrorR   R   (   R   R   R(   (    (    R   t   test_invalid_placeholdersI   s    	c         C   sN   d t  f d     Y} | d  } |  i | i t d d d d   d  d  S(	   Nt	   PieDelimsc           B   s   t  Z d Z RS(   Nt   @(   R   R   t	   delimiter(    (    (    R   R+   S   s   s-   @who likes to eat a bag of @{what} worth $100R   R   R   R   s(   tim likes to eat a bag of ham worth $100(   R   R+   R   R   R   R   R   (   R   R+   R   (    (    R   t   test_delimiter_overrideR   s    !c         C   s~   d t  f d     Y} t   } t   | _ t   | i _ d | i i _ d | i _ | d  } |  i | i |  d  d  S(   Nt   PathPatternc           B   s   t  Z d Z RS(   Ns   [_a-z][._a-z0-9]*(   R   R   t	   idpattern(    (    (    R   R/   Z   s   R   R   s,   $bag.foo.who likes to eat a bag of $bag.whats   tim likes to eat a bag of ham(   R   R/   R   t   mR    t   bagR!   R   R   R   R   R   R   (   R   R/   R1   R   (    (    R   t   test_idpattern_overrideY   s    	c         C   sΜ   d t  f d     Y} t   } t   | _ t   | i _ d | i i _ d | i _ | d  } |  i | i |  d  d t  f d     Y} | d  } |  i t | i h   |  i t | i h   d  S(	   Nt	   MyPatternc           B   s   t  Z d Z RS(   NsΎ   
            (?P<escaped>@{2})                   |
            @(?P<named>[_a-z][._a-z0-9]*)       |
            @{(?P<braced>[_a-z][._a-z0-9]*)}    |
            (?P<invalid>@)
            (   R   R   t   pattern(    (    (    R   R4   e   s   R   R   s,   @bag.foo.who likes to eat a bag of @bag.whats   tim likes to eat a bag of hamt
   BadPatternc           B   s   t  Z d Z RS(   Ns  
            (?P<badname>.*)                     |
            (?P<escaped>@{2})                   |
            @(?P<named>[_a-z][._a-z0-9]*)       |
            @{(?P<braced>[_a-z][._a-z0-9]*)}    |
            (?P<invalid>@)                      |
            (   R   R   R5   (    (    (    R   R6   t   s   (   R   R4   R   R1   R    R2   R!   R   R   R   R   R   R   R6   R   R)   R#   (   R   R6   R1   R   R4   (    (    R   t   test_pattern_overrided   s    	c         C   s>   t  d  } t d d d d  } |  i | i |  d  d  S(   Ns   $who likes $whatR   u   tΓΏmR   u   fΓΎedu   tΓΏm likes fΓΎed(   R   R   R   R   R   R   R   (   R   R   R   (    (    R   t   test_unicode_values   s    c         C   sδ   |  i } t d  } | | i d d d d  d  | | i t d d  d d d  | | i t d d d d  d d d d d  t d	  } | | i t d
 d  d d d  | | i t d d  d d d  d  S(   Ns   $who likes $whatR   R   R   R   s   tim likes hamt   freds   kung paos   the mapping is $mappingR!   t   nonet   mappingt   bozos   the mapping is bozot   onet   twos   the mapping is two(   R   R   R   R   R   R   R   (   R   R   R   (    (    R   t   test_keyword_arguments   s    	%c         C   s(  |  i } |  i } t d  } | | i d d d d  d  | | i t d d  d d d  | | i t d d d d  d d d d d  t d	  } | | i t d
 d  d d d  | | i t d d  d d d  t d d  } | t
 | i | h   | t
 | i | h   d  S(   Ns   $who likes $whatR   R   R   R   s   tim likes hamR9   s   kung paos   the mapping is $mappingR!   R:   R;   R<   s   the mapping is bozoR=   R>   s   the mapping is two(   R   R   R   R   R(   R   R   R#   R   R   t	   TypeErrorR   (   R   R   R   R(   R   (    (    R   t   test_keyword_arguments_safe   s     		%c         C   sΪ   |  i } |  i } d t f d     Y} | d  } | | i d d d d  d  | t	 | i  | | i
 d d d d  d  | | i
   d	  | d	  } | t | i t d d d d   | | i
   d	  d  S(
   Nt   AmpersandTemplatec           B   s   t  Z d Z RS(   Nt   &(   R   R   R-   (    (    (    R   RB   ¨   s   s   this &gift is for &{who} &&t   giftt   budR   t   yous   this bud is for you &s   this &gift is for &{who} &(   R   R   R   R   R(   R   RB   R   R   R   R#   R)   R   (   R   RB   R   R(   R   (    (    R   R.   ₯   s    		"(   R   R   R   R   R    R$   R&   R'   R*   R.   R3   R7   R8   R?   RA   (    (    (    R   R      s   															c          C   s'   d k  l }  t g } |  i |   d  S(   N(   s   test_support(   t   testt   test_supportR   t   test_classest   run_unittest(   RH   RI   (    (    R   t	   test_main΄   s    	t   __main__(	   t   unittestt   stringR   R    R   t   TestCaseR   RK   R   (   R   RM   R   R    RK   R   (    (    R   t   ?   s   		