Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/lib2to3/tests/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/lib2to3/tests/__pycache__/test_main.cpython-34.pyc

�
j fl�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ejjejj
e�d�Zejjed�ZGdd�dej�Zedkr�ej
�ndS)�N)�main�datazpy2_test_grammar.pyc@speZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�TestMaincCs
d|_dS)N)�temp_dir)�self�r�</opt/alt/python34/lib64/python3.4/lib2to3/tests/test_main.py�setUpszTestMain.setUpcCs3tjjdd�=|jr/tj|j�ndS)N)�logging�rootZhandlersr�shutilZrmtree)rrrr�tearDowns	zTestMain.tearDowncCsmtj}tj}tj}|t_|t_|t_ztjd|�SWd|t_|t_|t_XdS)Nz
lib2to3.fixes)�sys�stdin�stdout�stderrr)r�argsZ
in_captureZout_captureZerr_captureZ
save_stdinZsave_stdoutZsave_stderrrrr�run_2to3_captures								zTestMain.run_2to3_capturecCs�tjd�}tj�}tjd�|�}tj�}|jdg|||�}|j|d�|j�jd�}|j	d|�|j	d|j��dS)Nuprint 'nothing'
print u'über'
�ascii�-rz-print 'nothing'z9WARNING: couldn't encode <stdin>'s diff for your terminal)
�io�StringIO�BytesIO�codecs�	getwriterr�assertEqual�getvalue�decode�assertIn)rZinput_stream�outZout_enc�err�ret�outputrrr�test_unencodable_diff,s	zTestMain.test_unencodable_diffc	CsDtj�|_tjj|jd�|_tjj|jd�|_tj|j�tj|j�g|_	t
tjj|jd�d�j�|j	jd�t
jt|j�|j	jtjjt��tjj|jd�|_tjj|jd�|_t
|jd��}|jd�WdQX|j	jd�dS)z5Setup a test source tree and output destination tree.Zpython2_projectZpython3_projectz__init__.py�wz
trivial.pyz#print 'I need a simple conversion.'N)�tempfileZmkdtempr�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)rZtrivialrrr�setup_test_source_trees8s	%z TestMain.setup_test_source_treesc	s�|j�tj�}tj�}d�|jdd�ddd|j|jgtjd�||�}|j|d�|j�}|jd	|�|jd
|j|jf|�|jt	�fdd�|j
D��t	tj|j���xS|j
D]H}|jd
tj
j|j|�tj
j|j|��f|�q�Wtjtj�}|j|djd|��|j|djd|��dS)z92to3 a single directory with a new output dir and suffix.ZTESTz-nz--add-suffixz--write-unchanged-filesz
--no-diffsz--output-dir�rz implies -w.z6Output in %r will mirror the input directory %r layoutc3s|]}|�VqdS)Nr)�.0�name)�suffixrr�	<genexpr>\szGTestMain.test_filename_changing_on_output_single_dir.<locals>.<genexpr>zWriting converted %s to %szNo changes to .*/__init__\.py�/zNo changes to .*/trivial\.pyN)r6rrrr*r)rrr�setr,r&�listdirr'r(�re�escape�sepZassertRegex�replaceZassertNotRegex)rrr r!rr9rAr)r:r�+test_filename_changing_on_output_single_dirKs4
%	(z4TestMain.test_filename_changing_on_output_single_dircCs�|j�tj�}|j|jg}tdd�|D��}|jddddd|jg|tjd�tj�|�}|j|d	�|j	�}|j
d
|j|jf|�|j|ttj
|j���dS)z62to3 two files in one directory with a new output dir.css!|]}tjj|�VqdS)N)r&r'r2)r8r9rrrr;mszFTestMain.test_filename_changing_on_output_two_files.<locals>.<genexpr>z-nz-wz--write-unchanged-filesz
--no-diffsz--output-dirr7rz6Output in %r will mirror the input directory %r layoutN)r6rrr3r4r=rr*rrrr)r&r>)rr Z	py2_filesZexpected_filesr!rrrr�*test_filename_changing_on_output_two_fileshs
	z3TestMain.test_filename_changing_on_output_two_filescCs�|j�tj�}|jdddd|j|jgtjd�tj�|�}|j|d�|j�}|jd|j|j	f|�|jt
tjj
|j�g�t
tj|j���dS)	z)2to3 a single file with a new output dir.z-nz-wz
--no-diffsz--output-dirr7rz6Output in %r will mirror the input directory %r layoutN)r6rrrr*r3rrrr)r=r&r'r2r>)rr r!rrrr�,test_filename_changing_on_output_single_fileys
	!z5TestMain.test_filename_changing_on_output_single_fileN)�__name__�
__module__�__qualname__r	r
rr#r6rCrDrErrrrrsr�__main__)rrr
r&r?rrr%ZunittestZlib2to3rr'r(�dirname�__file__Z
TEST_DATA_DIRr1ZTestCaserrFrrrr�<module>s!w