Your IP : 216.73.216.196


Current Path : /opt/alt/python35/lib64/python3.5/lib2to3/tests/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/lib2to3/tests/__pycache__/test_main.cpython-35.opt-2.pyc



���]l�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ejjejj
e�d�Zejjed�ZGdd�dej�Zedkr�ej
�dS)�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/python35/lib64/python3.5/test_main.py�setUpszTestMain.setUpcCs0tjjdd�=|jr,tj|j�dS)N)�logging�root�handlersr�shutil�rmtree)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	CsEtj�|_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�WdQRX|j	jd�dS)NZpython2_projectZpython3_projectz__init__.py�wz
trivial.pyz#print 'I need a simple conversion.')�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)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)NZTESTz-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\.py)r9rrrr-r,rrr �setr/r)�listdirr*r+�re�escape�sepZassertRegex�replaceZassertNotRegex)rr!r"r#rr<rDr)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)Ncss!|]}tjj|�VqdS)N)r)r*r5)r;r<rrrr>mszFTestMain.test_filename_changing_on_output_two_files.<locals>.<genexpr>z-nz-wz--write-unchanged-filesz
--no-diffsz--output-dirr:rz6Output in %r will mirror the input directory %r layout)r9rrr6r7r@rr-rrr r,r)rA)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)Nz-nz-wz
--no-diffsz--output-dirr:rz6Output in %r will mirror the input directory %r layout)r9rrrr-r6rrr r,r@r)r*r5rA)rr"r#rrrr�,test_filename_changing_on_output_single_fileys
	!z5TestMain.test_filename_changing_on_output_single_fileN)�__name__�
__module__�__qualname__r	rrr%r9rFrGrHrrrrrsr�__main__)rrr
r)rBr
rr'ZunittestZlib2to3rr*r+�dirname�__file__Z
TEST_DATA_DIRr4ZTestCaserrIrrrr�<module>s!w