D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
python35
/
lib
/
python3.5
/
lib2to3
/
tests
/
__pycache__
/
Filename :
test_main.cpython-35.pyc
back
Copy
p��Yl � @ s� 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 j e j j e � d � Z e j j e d � Z Gd d � d e j � Z e d k r� e j � d S)� N)�main�datazpy2_test_grammar.pyc @ sp e Z d Z d d � Z d d � Z d d � Z d d � Z d d � Z d d � Z d d � Z d d � Z d S)�TestMainc C s d | _ d S)N)�temp_dir)�self� r �(/opt/python35/lib/python3.5/test_main.py�setUp s zTestMain.setUpc C s0 t j j d d � =| j r, t j | j � d S)N)�logging�root�handlersr �shutil�rmtree)r r r r �tearDown s zTestMain.tearDownc C sm t j } t j } t j } | t _ | t _ | t _ z t j d | � SWd | t _ | t _ | t _ Xd 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 s� t j d � } t j � } t j d � | � } t j � } | j d g | | | � } | j | d � | j � j d � } | 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 sE t j � | _ t j j | j d � | _ t j j | j d � | _ t j | j � t j | j � g | _ t t j j | j d � d � j � | j j d � t j t | j � | j j t j j t � � t j j | j d � | _ t j j | j d � | _ t | j d � � } | j d � Wd QRX| j j d � d S)z5Setup a test source tree and output destination tree.Zpython2_projectZpython3_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 Ztrivialr r r �setup_test_source_trees8 s %z TestMain.setup_test_source_treesc s� | j � t j � } t j � } d � | j d d � d d d | j | j g t j d � | | � } | j | d � | j � } | j d | � | j d | j | j f | � | j t � f d d � | j D� � t t j | j � � � xS | j D]H } | j d t j j | j | � t j j | j | � � f | � q� Wt j t j � } | j | d j d | � � | j | d j d | � � d S)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 | ] } | � Vq d 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)r9 r r r r- r, r r r �setr/ r) �listdirr* r+ �re�escape�sepZassertRegex�replaceZassertNotRegex)r r! r"