mò
­fIc        	   @   s  d  Z  d k l Z l Z l Z d k Z d k Z d k Z d k l Z d k	 l
 Z
 d „  Z e i d ƒ Z d „  Z d d d	 „ Z d
 „  Z xU d" d# f D]G \ Z Z z$ e ƒ  e t t t t e e ƒ Wd e t t t t ƒ Xqš We o	 d GHn z(e d d g ƒ a e d d g ƒ a e d d g ƒ a e d d g ƒ a e
 d t t t t f ƒ Z e i ƒ  Z e e d j ƒ e e i ƒ  d j ƒ e e i ƒ  d j ƒ e e i ƒ  t j ƒ e i ƒ  Z e e ƒ e e i ƒ  d j ƒ e e i ƒ  d j ƒ e e i ƒ  t j ƒ e i ƒ  Wd e t t t t ƒ Xe o	 d GHn z— e d d g ƒ a e d d g ƒ a e
 d t t f ƒ Z e e ƒ Z e e d d d d d d g j ƒ e e i ƒ  d j ƒ e e i ƒ  d j ƒ Wd e t t ƒ Xe o	 d GHn zs e d d g ƒ a e i  ƒ  Z! e! d j o
 d  Z! n e
 d e# t e! ƒ ƒ Z e e ƒ Z e e d d! g j ƒ Wd e t ƒ Xd S($   s,   
Tests for fileinput module.
Nick Mathewson
(   s   verifys   verboses   TESTFNN(   s   StringIO(   s	   FileInputc         C   s:   t  t |  ƒ } t | d ƒ } | i | ƒ | i ƒ  | S(   Nt   w(	   t   TESTFNt   strt   it   namet   opent   ft
   writelinest   linest   close(   R   R   R   R   (    (    t0   /mit/python/lib/python2.4/test/test_fileinput.pyt   writeTmp   s
    
s   LINE (\d+) OF FILE (\d+)c          G   s0   x) |  D]! } y t i | ƒ Wq q Xq Wd  S(   N(   t   namesR   t   ost   unlink(   R   R   (    (    R
   t   remove_tempfiles   s     i    c         C   s‰  d | d } t o d | d | f GHn t d |  | | | f d | ƒ }	 t
 |	 ƒ } |	 i ƒ  t t | ƒ d j ƒ t | d d	 j ƒ t | d
 d j ƒ t |	 i ƒ  d j ƒ t |	 i ƒ  | j ƒ t o d | d | f GHn t d |  | | | f d | ƒ }	 d } x% | o | d j o |	 i ƒ  } qWt |	 i ƒ  | j ƒ t |	 i ƒ  d j ƒ t |	 i ƒ  d j ƒ t |	 i ƒ  ƒ t |	 i ƒ  ƒ t o d | d | f GHn |	 i ƒ  t |	 i ƒ  d j ƒ t |	 i ƒ  d j ƒ |	 i ƒ  t o d | d | f GHn t d |  | | | d f d | ƒ }	 t i } zi t d ƒ t _ t
 |	 ƒ } t t | ƒ d j ƒ t | d d j ƒ t |	 i ƒ  d j ƒ |	 i ƒ  Wd  | t _ Xt o d | d | f GHn t d |  | | | f d | ƒ }	 t |	 i ƒ  d j ƒ t |	 i ƒ  d  j ƒ |	 i ƒ  t |	 i ƒ  d j ƒ t |	 i ƒ  d  j ƒ t o d | d | f GHn t i } z[ t d |  | | | f d d d | ƒ }	 x# |	 D] }
 |
 d   i ƒ  }
 |
 GHq¶W|	 i ƒ  Wd  | t _ Xt d |  | | | f d | ƒ }	 xj |	 D]b }
 t |
 d  d! j ƒ t  i! |
 d   ƒ } t | d  j ƒ t t# | i$ d ƒ ƒ |	 i ƒ  j ƒ qW|	 i ƒ  d  S("   Ni   i   s   %s. Simple iteration (bs=%s)i    t   filest   bufsizei   i   s   Line 5 of file 1
i   s   Line 1 of file 4
s   %s. Status variables (bs=%s)t   xs   Line 6 of file 2
i   s   %s. Nextfile (bs=%s)i   s   Line 1 of file 3
i   s   %s. Stdin (bs=%s)i   t   -s    Line 1 of stdin
Line 2 of stdin
i!   i    s   Line 2 of stdin
s   <stdin>s   %s. Boundary conditions (bs=%s)s   %s. Inplace (bs=%s)i   t   inplaceiÿÿÿÿs   
(%   t   roundt   startt   verboset   bst	   FileInputt   t1t   t2t   t3t   t4t   fit   listR   R	   t   verifyt   lent   linenot   filenamet   st   readlinet
   filelinenot   isfirstlinet   isstdint   nextfilet   syst   stdint	   savestdint   StringIOt   Nonet   stdoutt
   savestdoutt   linet   uppert   patt   matcht   mt   intt   group(   R   R   R   R   R   R   R,   R   R5   R   R1   R0   R   R$   (    (    R
   t   runTests"   sŒ    !
! 

$	 
!
	' 	 
! )c          C   sä   t  d g  } t d ƒ D] }  | d |  d q ~ ƒ a t  d g  } t d ƒ D] }  | d |  d qO ~ ƒ a t  d g  } t d ƒ D] }  | d	 |  d q‡ ~ ƒ a t  d
 g  } t d ƒ D] }  | d |  d q¿ ~ ƒ a d  S(   Ni   i   s   Line %s of file 1
i   i
   s   Line %s of file 2
i   i   s   Line %s of file 3
i   s   Line %s of file 4
(   R   t   _[1]t   rangeR   R   R   R   R   (   R   R9   (    (    R
   t
   writeFilesn   s
     888i   i   s   13. 0-byte filest    i   i   s   The only line there is.
i   R   s%   14. Files that don't end with newlines   A
B
Cs   D
E
Fs   A
s   B
t   Cs   D
s   E
t   Fi   s   15. Unicode filenamess   A
Bt   asciit   B(   i    i    (   i   i   ($   t   __doc__t   test.test_supportR    R   R   R*   R   t   reR-   t	   fileinputR   R   t   compileR3   R   R8   R;   R   R   R   R   R   R   R   R%   R1   R"   R&   R#   R	   R   R   t   getfilesystemencodingt   encodingR.   t   unicode(   R   RG   R;   R   R   R3   R    RC   R   R   R*   R   R   R1   R   R8   R-   R   R   (    (    R
   t   ?   sz   			L	  	 	" 	
 