
    <eoW                         d dl Z d dlZd dlmZ  G d de j                  Z G d d          Z G d d          Z G d	 d
e j                  Zedk    r e j	                     dS dS )    N)Templatec                   b    e 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d ZdS )
ModuleTestc                 
   |                      t          j        d           |                      t          j        d           |                      t          j        d           |                      t          j        t          j        t          j        z              |                      t          j        d           |                      t          j        t          j        dz              |                      t          j        d           |                      t          j	        d           |                      t          j
        t          j        t          j        z   t          j        z   t          j	        z   t          j        z              d S )Nz 	
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefABCDEF01234567z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)assertEqualstring
whitespaceascii_lowercaseascii_uppercaseascii_lettersdigits	hexdigits	octdigitspunctuation	printableselfs    '/usr/lib/python3.11/test/test_string.py
test_attrszModuleTest.test_attrs   s?   
 	*,=>>>/1MNNN/1MNNN-v/EH^/^___555)6=>+IJJJ):666+-QRRR)6=6;Q+QTZTj+jmsm+  CI  CT  ,T  	U  	U  	U  	U  	U    c                    |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        dd          d           |                      t          j        d	          d
           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        dd          d           d S )Nzabc def ghizAbc Def Ghizabc	def
ghizabc	   def  
ghizABC DEF GHIzABC-DEF-GHI-zAbc-Def-GhizABC-def DEF-ghi GHIzAbc-def Def-ghi Ghiz   aBc  DeF   zAbc Defz		aBc	DeF		z		Abc	Def	)r   r   capwordsr   s    r   test_capwordszModuleTest.test_capwords   s0   77GGG99=III)=>>NNN77GGG<<mLLL)>??AVWWW)9::IFFF88)DDD>>OOOOOr   c                    t          j                    }|                     |                    d          d           |                     |                    dd          d           |                     |                    ddd          d           |                     t
          |j                   |                     t
          t           j        j                   d S )Nfoozfoo{0}barfoobarzfoo{1}{0}-{1}   z	foo6bar-6)r   	Formatterr   formatassertRaises	TypeErrorr   fmts     r   test_basic_formatterzModuleTest.test_basic_formatter"   s      E**E222He44h???OUA>>LLL)SZ000)V%5%<=====r   c                    t          j                    }|                     |                    dd          d           |                     t
          |j        d           |                     |                    dd          d           |                     t
          |j        d           |                     |                    dd          d           |                     t
          |j        d           |                     t          d	          5  |                    dd
           d d d            d S # 1 swxY w Y   d S )Nz-{arg}-testargz-test-z-{self}-r   z-{format_string}-)format_stringr1   )r1   r0   )r   r&   r   r'   r(   KeyErrorassertRaisesRegexr)   r*   s     r   test_format_keyword_argumentsz(ModuleTest.test_format_keyword_arguments*   si     I6::HEEE(CJ	:::JV<<hGGG(CJ
;;;$7vNN!	# 	# 	#(CJ0CDDD##I?? 	< 	<JJYFJ;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   D88D<?D<c                    t          j                    }|                     |                    ddd          d                    dd                     |                     |                    dd dd          d                    d dd                     |                     |                    ddd          d                    dd                     |                     |                    dddd          d                    ddd                     |                     |                    d	d
dd          d	                    d
dd                     |                     t
                    5  |                    ddd           d d d            n# 1 swxY w Y   |                     t
                    5  |                    ddd           d d d            d S # 1 swxY w Y   d S )Nzfoo{}{}r#   r%   zfoo{1}{num}{1})numz{:^{}}z	{:^{}} {}Xz{:^{pad}}{}r"   )padzfoo{1}{}zfoo{}{1}r   r&   r   r'   r(   
ValueErrorr*   s     r   test_auto_numberingzModuleTest.test_auto_numbering6   sm     Iua88"))%33	5 	5 	5$4dEqII)00u!0DD	F 	F 	FHeQ77!22	4 	4 	4K3??$++E1c::	< 	< 	<M5%QGG&--eU-BB	D 	D 	D z** 	- 	-JJz5!,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- z** 	- 	-JJz5!,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s$   3FFF<G!!G%(G%c                    t          j                    }|                     |                    dd          d           |                     |                    dd          d           |                     t
          |j        dd           |                     |                    dd          d	           |                     |                    dt           j                  d
           |                     |                    dt          d                    d           |                     |                    dt          d                    d           d S )Nz	-{arg!r}-r.   r/   z-'test'-z{0!s}z{0!h}z{0!a}*   42z6'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'   z'\xff'   z'\u0100')r   r&   r   r'   r(   r:   r   chrr*   s     r   test_conversion_specifiersz%ModuleTest.test_conversion_specifiersI   s%     KV<<jIIIGV44f===*cj'6BBBGR00$777Gf.BCCD	F 	F 	FGc#hh77CCCGc#hh77EEEEEr   c                 @   t          j                    } G d d          } |            }|                     |                    d|          d           |                     t
                    5  |                    dd           d d d            d S # 1 swxY w Y   d S )Nc                       e Zd Zd ZdS ),ModuleTest.test_name_lookup.<locals>.AnyAttrc                     |S N )r   attrs     r   __getattr__z8ModuleTest.test_name_lookup.<locals>.AnyAttr.__getattr__X   s    r   N)__name__
__module____qualname__rJ   rH   r   r   AnyAttrrE   W   s#            r   rN   z{0.lumber}{0.jack}
lumberjack )r   r&   r   r'   r(   AttributeError)r   r+   rN   xs       r   test_name_lookupzModuleTest.test_name_lookupU   s      	 	 	 	 	 	 	 	 GII$8!<<lKKK~.. 	1 	1JJ+R000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   /BBBc                    t          j                    }g d}|                     |                    d|          d           |                     t
                    5  |                    dg            d d d            n# 1 swxY w Y   |                     t                    5  |                    di            d d d            d S # 1 swxY w Y   d S )N)eggsandspamz{0[2]}{0[0]}spameggs)r   r&   r   r'   r(   
IndexErrorr2   )r   r+   lookups      r   test_index_lookupzModuleTest.test_index_lookup_   sH     (((NF;;ZHHHz** 	+ 	+JJ~r***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+x(( 	+ 	+JJ~r***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s$   A??BB$CCCc                      G d dt           j                  } |ddi          }|                     |                    d          d           d S )Nc                       e Zd Zi fdZd ZdS )>ModuleTest.test_override_get_value.<locals>.NamespaceFormatterc                 R    t           j                            |            || _        d S rG   )r   r&   __init__	namespace)r   ra   s     r   r`   zGModuleTest.test_override_get_value.<locals>.NamespaceFormatter.__init__j   s$     ))$///!*r   c                     t          |t                    r&	 ||         S # t          $ r | j        |         cY S w xY wt          j                            |||           d S rG   )
isinstancestrr2   ra   r   r&   	get_value)r   keyargskwdss       r   re   zHModuleTest.test_override_get_value.<locals>.NamespaceFormatter.get_valuen   su    c3'' @3#Cy(# 3 3 3#~c22223 $..sD$?????s    99N)rK   rL   rM   r`   re   rH   r   r   NamespaceFormatterr^   i   s?        )+ + + + +@ @ @ @ @r   ri   greetinghelloz{greeting}, world!zhello, world!r   r&   r   r'   )r   ri   r+   s      r   test_override_get_valuez"ModuleTest.test_override_get_valueh   sw    	@ 	@ 	@ 	@ 	@!1 	@ 	@ 	@ ! *W!566$899?KKKKKr   c                      G d dt           j                  } |            }|                     |                    dd           d           d S )Nc                       e Zd Zd ZdS )<ModuleTest.test_override_format_field.<locals>.CallFormatterc                 2    t           |            |          S rG   )r'   )r   valueformat_specs      r   format_fieldzIModuleTest.test_override_format_field.<locals>.CallFormatter.format_field~   s    eegg{333r   N)rK   rL   rM   rt   rH   r   r   CallFormatterrp   }   s#        4 4 4 4 4r   ru   z*{0}*c                      dS )NresultrH   rH   r   r   <lambda>z7ModuleTest.test_override_format_field.<locals>.<lambda>   s    h r   z*result*rl   )r   ru   r+   s      r   test_override_format_fieldz%ModuleTest.test_override_format_field|   sj    	4 	4 	4 	4 	4F, 	4 	4 	4 mooG->->??LLLLLr   c                      G d dt           j                  } |            }|                     |                    ddd          d           d S )Nc                        e Zd Z fdZ xZS ):ModuleTest.test_override_convert_field.<locals>.XFormatterc                 X    |dk    rd S t                                          ||          S )NrR   )superconvert_field)r   rr   
conversion	__class__s      r   r   zHModuleTest.test_override_convert_field.<locals>.XFormatter.convert_field   s-    $$4ww,,UJ???r   )rK   rL   rM   r   __classcell__)r   s   @r   
XFormatterr|      sA        @ @ @ @ @ @ @ @ @r   r   z{0!r}:{0!x}r"   z
'foo':Nonerl   )r   r   r+   s      r   test_override_convert_fieldz&ModuleTest.test_override_convert_field   sp    	@ 	@ 	@ 	@ 	@) 	@ 	@ 	@ jllM5%@@,OOOOOr   c                      G d dt           j                  } |            }|                     |                    dd          d           d S )Nc                       e Zd Zd ZdS )4ModuleTest.test_override_parse.<locals>.BarFormatterc              3      K   |                     d          D ]@}|d         dk    r*|dd                              d          \  }}}d||d fV  8|d d d fV  Ad S )N|r   +   :rP   )split	partition)r   r1   field
field_name_rs   s         r   parsez:ModuleTest.test_override_parse.<locals>.BarFormatter.parse   s      *0055 6 6EQx35:122Y5H5H5M5M2
A{ *k4?????#T4555556 6r   N)rK   rL   rM   r   rH   r   r   BarFormatterr      s#        6 6 6 6 6r   r   z*|+0:^10s|*r"   z*   foo    *rl   )r   r   r+   s      r   test_override_parsezModuleTest.test_override_parse   sf    
	6 
	6 
	6 
	6 
	66+ 
	6 
	6 
	6 lnnM599>JJJJJr   c           	      v    G d dt           j                  } |            }|                     |                    dd          d           |                     |                    ddd          d	           |                     |                    d
ddd          d           |                     t
          |j        d
dddd           |                     t
          |j        ddd           |                     t
          |j        dddd           |                     t
          |j        dddd           d S )Nc                       e Zd Zd ZdS )@ModuleTest.test_check_unused_args.<locals>.CheckAllUsedFormatterc                     t          |                                          }|                    t          dt	          |                               |D ]}|                    |           |rt          d          d S )Nr   zunused arguments)setkeysupdaterangelenremover:   )r   	used_argsrg   kwargsunused_argsr0   s         r   check_unused_argszRModuleTest.test_check_unused_args.<locals>.CheckAllUsedFormatter.check_unused_args   s    !&++--00""5CII#6#6777$ , ,C&&s++++ 9$%78889 9r   N)rK   rL   rM   r   rH   r   r   CheckAllUsedFormatterr      s#        	9 	9 	9 	9 	9r   r   z{0}
   10z{0}{i}d   i10100z	{0}{i}{1}   1010020r   )r   j{i}r9   )r   r   r+   s      r   test_check_unused_argsz!ModuleTest.test_check_unused_args   sE   
	9 
	9 
	9 
	9 
	9F$4 
	9 
	9 
	9 $#%%E2..555HbC88'BBBKR3??KKK*cj+r2PQRRR*cj%R@@@*cj%R3GGG*cj%R3GGGGGr   c                 N   t          j                    }d}t          d          }|                     t                    5 }|                    d||t                      d           d d d            n# 1 swxY w Y   |                     dt          |j	                             d S )NrH   r   r   r   	recursion)
r   r&   dictr(   r:   _vformatr   assertInrd   	exception)r   r+   rg   r   errs        r   test_vformat_recursion_limitz'ModuleTest.test_vformat_recursion_limit   s      z** 	9cLLfceeR888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9k3s}#5#566666s    &A22A69A6N)rK   rL   rM   r   r    r,   r4   r;   rB   rS   r[   rm   ry   r   r   r   r   rH   r   r   r   r      s        U U U	P 	P 	P> > >
< 
< 
<- - -&
F 
F 
F1 1 1+ + +L L L(M M MP P PK K K H H H,7 7 7 7 7r   r   c                       e Zd ZdS )BagN)rK   rL   rM   rH   r   r   r   r      s        Dr   r   c                       e Zd Zd ZdS )Mappingc                     | }|                     d          D ]0}	 t          ||          }# t          $ r t          |          w xY w|S )N.)r   getattrrQ   r2   )r   nameobjparts       r   __getitem__zMapping.__getitem__   sb    JJsOO 	% 	%D%c4((! % % %tnn$%
s	   ,AN)rK   rL   rM   r   rH   r   r   r   r      s#            r   r   c                       e 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d Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )TestTemplatec                 <   t          d          }|                     |                    t          dd                    d           |                     t
          |j        t          d                     |                     t          t           j                   d S )Nz,$who likes to eat a bag of $what worth $$100timhamwhowhat(tim likes to eat a bag of ham worth $100r   )r   r   
substituter   r(   r2   r)   )r   ss     r   test_regular_templatesz#TestTemplate.test_regular_templates   s    CDDdu5&A&A&ABBC	E 	E 	E(AL$5///BBB)X%899999r   c                     t          d          }t          ddd          }|                     |                    |          d           |                     t
          |j        t          dd                     d S )N$who likes ${what} for ${meal}r   r   dinnerr   r   mealtim likes ham for dinnerr   )r   r   r   r   r(   r2   r   r   ds      r   "test_regular_templates_with_bracesz/TestTemplate.test_regular_templates_with_braces   s}    566UX666a*DEEE(AL5u555	7 	7 	7 	7 	7r   c                     t          d          }t          ddd          }|                     |                    |          d           d S )Nz$WHO likes ${WHAT} for ${MEAL}r   r   r   )WHOWHATMEALr   r   r   r   r   r   s      r   &test_regular_templates_with_upper_casez3TestTemplate.test_regular_templates_with_upper_case   sK    566UX666a*DEEEEEr   c                     t          d          }t          ddd          }|                     |                    |          d           d S )Nz%$_wh0_ likes ${_w_h_a_t_} for ${mea1}r   r   r   )_wh0_	_w_h_a_t_mea1r   r   r   s      r   'test_regular_templates_with_non_lettersz4TestTemplate.test_regular_templates_with_non_letters   sK    <==uH===a*DEEEEEr   c                    | j         }t          d          } ||                    t          dd                    d           t          d          } ||                    t          dd                    d           d S )Nz-$who likes to eat a bag of $$what worth $$100r   r   r   z*tim likes to eat a bag of $what worth $100z$who likes $$ztim likes $r   r   r   r   r   eqr   s      r   test_escapeszTestTemplate.test_escapes   s    DEE
1<<U333447	9 	9 	9_%%
1<<U33344mDDDDDr   c                     | j         }t          d          }t          d          } ||                    |          d            ||                    |          d           d S )Nz%(foo)s $foo ${foo}bazr"   z%(foo)s baz bazr   r   r   r   safe_substituter   r   r   r   s       r   test_percentszTestTemplate.test_percents   si    *++UOOO
1<<??-...
1Q!233333r   c                 *   | j         }t          d          }t          d          } ||                    |          d            ||                    |          d           t          d          } ||                    |          d           d S )Nz&tim has eaten $count bags of ham today   )countz!tim has eaten 7 bags of ham todayz(tim has eaten ${count} bags of ham todayr   r   s       r   test_stringificationz!TestTemplate.test_stringification   s    =>>qMMM
1<<???@@@
1Q!DEEE?@@
1<<???@@@@@r   c                     | j         }t          d          }t          dd          } ||                    |          d            ||                    |          d           d S )Nz$who ate ${meal})r   fred)r   kung pao)r   r   z'('tim', 'fred') ate ('ham', 'kung pao')r   r   s       r   test_tupleargszTestTemplate.test_tupleargs   so    '((_+>???
1<<??EFFF
1Q!JKKKKKr   c           	         | j         }t          d          } ||                    t          d                    d            ||                    t          d                    d            ||                    t          dd	                    d
            ||                    t          dd                    d            ||                    t          ddd                    d           d S )Nr   r   r   ztim likes ${what} for ${meal}r   r   z$who likes ham for ${meal}r   )r   r   z$who likes ham for dinnerr   ztim likes ham for ${meal}r   r   )r   r   r   r   r   s      r   test_SafeTemplatezTestTemplate.test_SafeTemplate  s   566
1Te___--/NOOO
1Tu---..0LMMM
1Tu8<<<==&	( 	( 	(
1Te%88899&	( 	( 	(
1Te%hGGGHH%	' 	' 	' 	' 	'r   c                    | j         }t          d          } |t          |j        t	          d                     t          d          } |t          |j        t	          d                     t          d          } |t          |j        t	          d                     t          d          } |t          |j        t	          d                     t          d          } |t          |j        t	          d                     d S )Nz$who likes $r   r   z$who likes ${what)z$who likes $100u   $who likes $ıu   $who likes $İ)r(   r   r:   r   r   )r   raisesr   s      r   test_invalid_placeholdersz&TestTemplate.test_invalid_placeholders  s    "^$$z1<%999)**z1<%999&''z1<%999 )**z1<%999)**z1<%99999r   c                 @    G d dt                     }t                      }t                      |_        t                      |j        _        d|j        j        _        d|j        _         |d          }|                     |                    |          d           d S )Nc                       e Zd ZdZdS )9TestTemplate.test_idpattern_override.<locals>.PathPatternz[_a-z][._a-z0-9]*N)rK   rL   rM   	idpatternrH   r   r   PathPatternr   #  s        ,IIIr   r  r   r   z,$bag.foo.who likes to eat a bag of $bag.whattim likes to eat a bag of ham)	r   r   r   bagr"   r   r   r   r   )r   r  mr   s       r   test_idpattern_overridez$TestTemplate.test_idpattern_override"  s    	- 	- 	- 	- 	-( 	- 	- 	-IIEE		
KFGGa*IJJJJJr   c                      G d dt                     } |d          }t          dddd          }|                     t          |j        |           |                     |                    |          d	           d S )
Nc                       e Zd ZdZdS )3TestTemplate.test_flags_override.<locals>.MyPatternr   N)rK   rL   rM   flagsrH   r   r   	MyPatternr	  .  s        EEEr   r  z$wHO likes ${WHAT} for ${meal}r   r   r   r   )wHOr   r   wzfredHO likes ${WHAT} for dinner)r   r   r(   r:   r   r   r   )r   r  r   r   s       r   test_flags_overridez TestTemplate.test_flags_override-  s    	 	 	 	 	 	 	 	I677UX@@@*alA666**1--/PQQQQQr   c                      G d dt                     }t          dd          } |d          }|                     |                    |          d           d S )Nc                       e Zd ZdZdZdZdS )FTestTemplate.test_idpattern_override_inside_outside.<locals>.MyPattern[a-z]+[A-Z]+r   NrK   rL   rM   r  braceidpatternr
  rH   r   r   r  r  8          !I&NEEEr   r  r"   BARr"   r  z$foo ${BAR}zfoo BARr   r   r  r  r   s       r   &test_idpattern_override_inside_outsidez3TestTemplate.test_idpattern_override_inside_outside5  su    	 	 	 	 	 	 	 	 U&&&Im$$a)44444r   c                      G d dt                     }t          dd          } |d          }|                     t          |j        |            |d          }|                     t          |j        |           d S )Nc                       e Zd ZdZdZdZdS )WTestTemplate.test_idpattern_override_inside_outside_invalid_unbraced.<locals>.MyPatternr  r  r   Nr  rH   r   r   r  r  C  r  r   r  r"   r  r  z$FOOz${bar})r   r   r(   r:   r   r  s       r   7test_idpattern_override_inside_outside_invalid_unbracedzDTestTemplate.test_idpattern_override_inside_outside_invalid_unbraced@  s    	 	 	 	 	 	 	 	 U&&&If*alA666Ih*alA66666r   c                      G d dt                     }t                      }t                      |_        t                      |j        _        d|j        j        _        d|j        _         |d          }|                     |                    |          d            G d dt                     } |d          }| 	                    t          |j        i            | 	                    t          |j        i            d S )	Nc                       e Zd ZdZdS )5TestTemplate.test_pattern_override.<locals>.MyPatternz
            (?P<escaped>@{2})                   |
            @(?P<named>[_a-z][._a-z0-9]*)       |
            @{(?P<braced>[_a-z][._a-z0-9]*)}    |
            (?P<invalid>@)
            NrK   rL   rM   patternrH   r   r   r  r!  N  s        GGGr   r  r   r   ,@bag.foo.who likes to eat a bag of @bag.whatr  c                       e Zd ZdZdS )6TestTemplate.test_pattern_override.<locals>.BadPatterna  
            (?P<badname>.*)                     |
            (?P<escaped>@{2})                   |
            @(?P<named>[_a-z][._a-z0-9]*)       |
            @{(?P<braced>[_a-z][._a-z0-9]*)}    |
            (?P<invalid>@)                      |
            Nr"  rH   r   r   
BadPatternr&  ]          GGGr   r'  )r   r   r   r  r"   r   r   r   r   r(   r:   r   )r   r  r  r   r'  s        r   test_pattern_overridez"TestTemplate.test_pattern_overrideM  s   	 	 	 	 	 	 	 	 IIEE		
IDEEa*IJJJ	 	 	 	 	 	 	 	 JEFF*alB777*a&7<<<<<r   c                      G d dt                     }d} ||          }|                     t          |j        i            |                    ddi          }|                     |d           d S )Nc                       e Zd ZdZdS )5TestTemplate.test_braced_override.<locals>.MyTemplate
            \$(?:
              (?P<escaped>$)                     |
              (?P<named>[_a-z][_a-z0-9]*)        |
              @@(?P<braced>[_a-z][_a-z0-9]*)@@   |
              (?P<invalid>)                      |
           )
           Nr"  rH   r   r   
MyTemplater,  j          GGGr   r.  PyCon in $@@location@@location	ClevelandPyCon in Cleveland)r   r(   r2   r   r   r   r.  tmpltvals        r   test_braced_overridez!TestTemplate.test_braced_overridei  s    	 	 	 	 	 	 	 	 (Jt(AL"555llJ455233333r   c                      G d dt                     }d} ||          }|                     |                                |           |                    ddi          }|                     |d           d S )Nc                       e Zd ZdZdS ):TestTemplate.test_braced_override_safe.<locals>.MyTemplater-  Nr"  rH   r   r   r.  r;  {  r/  r   r.  r0  r1  r2  r3  )r   r   r   r4  s        r   test_braced_override_safez&TestTemplate.test_braced_override_safez  s    	 	 	 	 	 	 	 	 (Jt**,,d333[ 9::233333r   c                      G d dt                     } |d          }|                     t                    5 }|                    i            d d d            n# 1 swxY w Y   |                     dt          |j                             d S )Nc                       e Zd ZdZdS );TestTemplate.test_invalid_with_no_lines.<locals>.MyTemplatez
              (?P<invalid>) |
              unreachable(
                (?P<named>)   |
                (?P<braced>)  |
                (?P<escaped>)
              )
            Nr"  rH   r   r   r.  r?    s        GGGr   r.  rP   zline 1, col 1)r   r(   r:   r   r   rd   r   )r   r.  r   r   s       r   test_invalid_with_no_linesz'TestTemplate.test_invalid_with_no_lines  s    	 	 	 	 	 	 	 	 JrNNz** 	cLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	os3='9'9:::::s   AA"Ac                     t          d          }t          dd          }|                     |                    |          d           d S )N$who likes $whatu   tÿmu   fþedr   u   tÿm likes fþedr   r   s      r   test_unicode_valuesz TestTemplate.test_unicode_values  sI    '((XK000a*DEEEEEr   c                 l   | j         }t          d          } ||                    dd          d            ||                    t          d          d          d            ||                    t          dd	          dd          d           t          d
          } ||                    t          d          d          d            ||                    t          d          d          d           t          d          } ||                    d          d           d S NrB  r   r   r   ztim likes hamr   r   r   r   zthe mapping is $mappingnoner   bozo)mappingzthe mapping is bozoonetwozthe mapping is twozthe self is $selfr   zthe self is bozor   r   s      r   test_keyword_argumentsz#TestTemplate.test_keyword_arguments  sS   '((
1<<E<..@@@
1<<e<44oFFF
1<<j999!  / /	 	 	 .//
1<<(((&<99 	" 	" 	"
1<<U+++U<;;	! 	! 	! ())
1<<V<$$&899999r   c                    | j         }| j        }t          d          } ||                    dd          d            ||                    t	          d          d          d            ||                    t	          dd	          dd          d           t          d
          } ||                    t	          d          d          d            ||                    t	          d          d          d           t	          d          } |t
          |j        |i             |t
          |j        |i            t          d          } ||                    d          d           d S rE  )r   r(   r   r   r   r)   r   )r   r   r   r   r   s        r   test_keyword_arguments_safez(TestTemplate.test_keyword_arguments_safe  s   "'((
1U33_EEE
1Te___599?KKK
1Tf:>>>!  / /	 	 	 .//
1Tf---v>> 	" 	" 	"
1T%000%@@	! 	! 	!y!,2...y!+Q333())
1&))+=>>>>>r   c                    | j         }| j        } G d dt                    } |d          } ||                    dd          d            |t          |j                    ||                    dd          d            ||                                d            |d          } |t          |j        t          dd                      ||                                d            G d	 d
t                    } |d          }|                      |                    t          dd                    d           d S )Nc                       e Zd ZdZdS )?TestTemplate.test_delimiter_override.<locals>.AmpersandTemplate&NrK   rL   rM   	delimiterrH   r   r   AmpersandTemplaterP            IIIr   rT  zthis &gift is for &{who} &&budyou)giftr   zthis bud is for you &zthis &gift is for &{who} &c                       e Zd ZdZdS )7TestTemplate.test_delimiter_override.<locals>.PieDelims@NrR  rH   r   r   	PieDelimsrZ    rU  r   r\  z-@who likes to eat a bag of @{what} worth $100r   r   r   r   )r   r(   r   r   r2   r   r:   r   )r   r   r   rT  r   r\  s         r   test_delimiter_overridez$TestTemplate.test_delimiter_override  s   "	 	 	 	 	 	 	 	;<<
1<<U<..0GHHHx&&&
1%U335LMMM
1 <===:;;z1<5e)D)D)DEEE
1 <===	 	 	 	 	 	 	 	IEFFdu5&A&A&ABBC	E 	E 	E 	E 	Er   c                 h   | j         }t          d          }|                     |                                           t          d          }|                     |                                            G d dt                    } |d          }|                     t          |j                   d S )N.$who likes to eat a bag of ${what} worth $$100-$who likes to eat a bag of ${what} worth $100c                       e Zd ZdZdS ).TestTemplate.test_is_valid.<locals>.BadPattern  
            (?P<badname>.*)                  |
            (?P<escaped>@{2})                   |
            @(?P<named>[_a-z][._a-z0-9]*)       |
            @{(?P<braced>[_a-z][._a-z0-9]*)}    |
            (?P<invalid>@)                      |
            Nr"  rH   r   r   r'  rb    r(  r   r'  r$  )r   r   
assertTrueis_validassertFalser(   r:   )r   r   r   r'  s       r   test_is_validzTestTemplate.test_is_valid  s    EFF

%%%DEE&&&	 	 	 	 	 	 	 	 JEFF*aj11111r   c                    | j         }| j        }t          d          }|                                } ||ddg           t          d          }|                                } ||ddg           t          d          }|                                } ||ddg            G d dt                    } |d          }|                     t          |j                   d S )	Nr_  r   r   z^$who likes to eat a bag of ${what} worth $$100; ${who} likes to eat a bag of $what worth $$100r`  c                       e Zd ZdZdS )5TestTemplate.test_get_identifiers.<locals>.BadPatternrc  Nr"  rH   r   r   r'  rj    r(  r   r'  r$  )r   r(   r   get_identifiersr:   )r   r   r   r   idsr'  s         r   test_get_identifiersz!TestTemplate.test_get_identifiers  s   "EFF!!
3    uvv!!
3    DEE!!
3   	 	 	 	 	 	 	 	 JEFF*a&788888r   N)rK   rL   rM   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r)  r8  r<  r@  rC  rK  rM  r]  rg  rm  rH   r   r   r   r      s       : : :7 7 7F F F
F F F
E E E4 4 4A A AL L L
' 
' 
': : :	K 	K 	KR R R	5 	5 	57 7 7= = =84 4 4"4 4 4"; ; ;(F F F
: : :"? ? ?*E E E(2 2 2*9 9 9 9 9r   r   __main__)
unittestr   r   TestCaser   r   r   r   rK   mainrH   r   r   <module>rr     s          v7 v7 v7 v7 v7" v7 v7 v7v	 	 	 	 	 	 	 	       @9 @9 @9 @9 @98$ @9 @9 @9F
 zHMOOOOO r   