Your IP : 216.73.216.213
3
� fl � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl m
Z
ejjejj
e�d�Zejjed�ZG dd� dej�Zedkr�ej
� dS )� N)�main�datazpy2_test_grammar.pyc @ sL e Zd Zdd� Zdd� Zdd� Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dS )�TestMainc C s
d | _ d S )N)�temp_dir)�self� r �</opt/alt/python36/lib64/python3.6/lib2to3/tests/test_main.py�setUp s zTestMain.setUpc C s$ t jjd d �= | jr tj| j� d S )N)�logging�rootZhandlersr �shutilZrmtree)r r r r �tearDown s zTestMain.tearDownc C sJ t j}t j}t j}|t _|t _|t _ztjd|�S |t _|t _|t _X d S )Nz
lib2to3.fixes)�sys�stdin�stdout�stderrr )r �argsZ
in_captureZout_captureZerr_captureZ
save_stdinZsave_stdoutZsave_stderrr r r �run_2to3_capture s zTestMain.run_2to3_capturec C st t jd�}t j� }tjd�|�}t j� }| jdg|||�}| j|d� |j� jd�}| j d|� | j d|j� � 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 Zinput_stream�outZout_enc�err�ret�outputr r r �test_unencodable_diff, s
zTestMain.test_unencodable_diffc C s� t j� | _tjj| jd�| _tjj| jd�| _tj| j� tj| j� g | _ t
tjj| jd�d�j� | j jd� t
jt| j� | j jtjjt�� tjj| jd�| _tjj| jd�| _t
| jd��}|jd� W dQ R X | j jd� 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)r Ztrivialr r r �setup_test_source_trees8 s
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��� x>| j
D ]4}| jd
tj
j| j|�tj
j| j|� �f |� q�W tjtj�}| 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� r z implies -w.z6Output in %r will mirror the input directory %r layoutc 3 s | ]}|� V qd S )Nr )�.0�name)�suffixr r � <genexpr>\ s zGTestMain.test_filename_changing_on_output_single_dir.<locals>.<genexpr>zWriting converted %s to %szNo changes to .*/__init__\.py�/zNo changes to .*/trivial\.pyN)r6 r r r r* r) r r r �setr, r&