
    ;el                     J   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
 ej                            ej                            e          d          Zej                            ed          Z G d dej                  Zedk    r ej
                     dS dS )    N)maindatazpy2_test_grammar.pyc                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
TestMainc                     d | _         d S N)temp_dirselfs    ./usr/lib/python3.11/lib2to3/tests/test_main.pysetUpzTestMain.setUp   s        c                 r    t           j        j        d d = | j        rt	          j        | j                   d S d S r   )loggingroothandlersr	   shutilrmtreer
   s    r   tearDownzTestMain.tearDown   s?    L!!!!$= 	)M$-(((((	) 	)r   c                 X   t           j        }t           j        }t           j        }|t           _        |t           _        |t           _        	 t	          j        d|          |t           _        |t           _        |t           _        S # |t           _        |t           _        |t           _        w xY w)Nzlib2to3.fixes)sysstdinstdoutstderrr   )r   args
in_captureout_captureerr_capture
save_stdinsave_stdoutsave_stderrs           r   run_2to3_capturezTestMain.run_2to3_capture   s{    Y
jj	 
 
	%9_d33"CI$CJ$CJJ #CI$CJ$CJ$$$$s   
B &B)c                    t          j        d          }t          j                    } t          j        d          |          }t          j                    }|                     dg|||          }|                     |d           |                                                    d          }| 	                    d|           | 	                    d|                                           d S )Nu   print 'nothing'
print u'über'
ascii-r   z-print 'nothing'z9WARNING: couldn't encode <stdin>'s diff for your terminal)
ioStringIOBytesIOcodecs	getwriterr"   assertEqualgetvaluedecodeassertIn)r   input_streamoutout_encerrretoutputs          r   test_unencodable_diffzTestMain.test_unencodable_diff,   s    {#FGGjll+&"7++C00kmm##SE<#FFa   &&w//(&111 &'*||~~	7 	7 	7 	7 	7r   c                 $   t          j                    | _        t          j                            | j        d          | _        t          j                            | j        d          | _        t          j        | j                   t          j        | j                   g | _	        t          t          j                            | j        d          d                                           | j	                            d           t          j        t          | j                   | j	                            t          j                            t                               t          j                            | j        d          | _        t          j                            | j        d          | _        t          | j        d          5 }|                    d           ddd           n# 1 swxY w Y   | j	                            d           dS )z5Setup a test source tree and output destination tree.python2_projectpython3_projectz__init__.pywz
trivial.pyz#print 'I need a simple conversion.'N)tempfilemkdtempr	   ospathjoinpy2_src_dirpy3_dest_dirmkdirsetup_filesopencloseappendr   copyPY2_TEST_MODULEbasenametrivial_py2_fileinit_py2_filewrite)r   trivials     r   setup_test_source_treesz TestMain.setup_test_source_trees8   s    (**7<<7HIIGLL8IJJ
!"""
"###RW\\$*M::C@@FFHHH...OT%5666 0 0 A ABBB "T-=| L LW\\$*:MJJ$'-- 	AMM?@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A-----s   	G++G/2G/c                 8   |                                   t          j                    }t          j                    }d|                     ddddd| j        | j        gt          j        d          ||          }|                     |d           |                                }|                     d	|           |                     d
| j        d| j        d|           |                     t          fd| j
        D                       t          t          j        | j                                       | j
        D ]g}|                     dt          j                            | j        |          dt          j                            | j        |z             |           ht          j        t          j                  }|                     |d                    d|                     |                     |d                    d|                     dS )z92to3 a single directory with a new output dir and suffix.TEST-nz--add-suffix--write-unchanged-files
--no-diffs--output-dir r   z implies -w.
Output in ! will mirror the input directory  layoutc              3   "   K   | ]	}|z   V  
d S r    ).0namesuffixs     r   	<genexpr>zGTestMain.test_filename_changing_on_output_single_dir.<locals>.<genexpr>\   s'      FFTT&[FFFFFFr   zWriting converted z to zNo changes to .*/__init__\.py/zNo changes to .*/trivial\.pyN)rM   r&   r'   r"   r@   r?   r+   r,   r.   setrB   r<   listdirr=   r>   reescapesepassertRegexreplaceassertNotRegex)r   r0   r2   r3   r   r[   rc   r\   s          @r   +test_filename_changing_on_output_single_dirz4TestMain.test_filename_changing_on_output_single_dirK   s4   $$&&&kmmkmm##~v/H~"D$46 Bc	+ +
 	a   nf---)))4+;+;+;=>D	F 	F 	F 	FFFFT5EFFFFFRZ(9::;;	= 	= 	=$ 	K 	KDMMMGLL!148888GLL!2DK@@@BCIK K K K i8@@cJJ	L 	L 	L7??SII	K 	K 	K 	K 	Kr   c                 J   |                                   t          j                    }| j        | j        g}t          d |D                       }|                     ddddd| j        g|z   t          j        d          t          j                    |          }|                     |d           |	                                }| 
                    d	| j        d
| j        d|           |                     |t          t          j        | j                                       dS )z62to3 two files in one directory with a new output dir.c              3   T   K   | ]#}t           j                            |          V  $d S r   )r<   r=   rH   )rZ   r[   s     r   r]   zFTestMain.test_filename_changing_on_output_two_files.<locals>.<genexpr>m   s2      JJRW--d33JJJJJJr   rP   -wrQ   rR   rS   rT   r   rU   rV   rW   N)rM   r&   r'   rI   rJ   r_   r"   r@   r+   r,   r.   r?   r<   r`   )r   r2   	py2_filesexpected_filesr3   r   s         r   *test_filename_changing_on_output_two_filesz3TestMain.test_filename_changing_on_output_two_filesh   s(   $$&&&kmm*D,>?	JJ	JJJJJ##t6~t/@BDMNB5 5 	a   )))4+;+;+;=>D	F 	F 	F 	RZ8I-J-J)K)KLLLLLr   c                 `   |                                   t          j                    }|                     dddd| j        | j        gt          j        d          t          j                    |          }|                     |d           |                                }|                     d| j        d| j	        d	|           |                     t          t          j                            | j                  g          t          t          j        | j                                       d
S )z)2to3 a single file with a new output dir.rP   rj   rR   rS   rT   r   rU   rV   rW   N)rM   r&   r'   r"   r@   rI   r+   r,   r.   r?   r_   r<   r=   rH   r`   )r   r2   r3   r   s       r   ,test_filename_changing_on_output_single_filez5TestMain.test_filename_changing_on_output_single_filey   s   $$&&&kmm##t\>4;L&(B5 5 	a   )))4+;+;+;=>D	F 	F 	F 	bg..t/DEEFGGRZ(9::;;	= 	= 	= 	= 	=r   N)__name__
__module____qualname__r   r   r"   r5   rM   rg   rm   ro   rY   r   r   r   r      s          ) ) )% % %
7 
7 
7. . .&K K K:M M M"= = = = =r   r   __main__)r)   r&   r   r<   ra   r   r   r:   unittestlib2to3r   r=   r>   dirname__file__TEST_DATA_DIRrG   TestCaser   rp   rY   r   r   <module>rz      s     				  				 				  



         RW__X66??',,}.CDDt= t= t= t= t=x  t= t= t=n zHMOOOOO r   