ó v®¸Qc@sôddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ej j ej j eƒdƒZej j edƒZdejfd„ƒYZedkrðej ƒndS(iÿÿÿÿN(tmaintdataspy2_test_grammar.pytTestMaincBsqeZeejdƒs'd d„Znd„Zd„Zd„Z d„Z d„Z d„Z d„Z d „ZRS( tassertNotRegexcCs]ddl}t|dƒs-|j|ƒ}n|j|ƒrY|jd|j|fƒndS(Niÿÿÿÿtsearchsregexp %s MATCHED text %r(trethasattrtcompileRtfailtpattern(tselfttexttregexptmsgR((s-/sys/lib/python2.7/lib2to3/tests/test_main.pyRs  cCs d|_dS(N(tNonettemp_dir(R ((s-/sys/lib/python2.7/lib2to3/tests/test_main.pytsetUpscCs*tjj2|jr&tj|jƒndS(N(tloggingtrootthandlersRtshutiltrmtree(R ((s-/sys/lib/python2.7/lib2to3/tests/test_main.pyttearDown"s  cCsmtj}tj}tj}|t_|t_|t_ztjd|ƒSWd|t_|t_|t_XdS(Ns lib2to3.fixes(tsyststdintstdouttstderrR(R targst in_capturet out_capturet err_capturet save_stdint save_stdoutt save_stderr((s-/sys/lib/python2.7/lib2to3/tests/test_main.pytrun_2to3_capture(s        cCs£tjdƒ}tjƒ}tjdƒ|ƒ}tjƒ}|jdg|||ƒ}|j|dƒ|jƒ}|jd|kƒ|jd|jƒkƒdS(Nuprint 'nothing' print u'über' tasciit-is-print 'nothing's9WARNING: couldn't encode 's diff for your terminal(tStringIOtcodecst getwriterR"t assertEqualtgetvaluet assertTrue(R t input_streamtouttout_encterrtrettoutput((s-/sys/lib/python2.7/lib2to3/tests/test_main.pyttest_unencodable_diff6s    cCsDtjƒ|_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(s5Setup a test source tree and output destination tree.tpython2_projecttpython3_projects __init__.pytws trivial.pys#print 'I need a simple conversion.'N(ttempfiletmkdtempRtostpathtjoint py2_src_dirt py3_dest_dirtmkdirt setup_filestopentclosetappendRtcopytPY2_TEST_MODULEtbasenamettrivial_py2_filet init_py2_filetwrite(R ttrivial((s-/sys/lib/python2.7/lib2to3/tests/test_main.pytsetup_test_source_treesBs %c s’|jƒtjƒ}tjƒ}d‰|jddˆddd|j|jgtjdƒ||ƒ}|j|dƒ|jƒ}|jd |ƒ|jd |j|jf|ƒ|jt‡fd †|j Dƒƒtt j |jƒƒƒxS|j D]H}|jd t j j |j|ƒt j j |j|ˆƒf|ƒqøWtjt jƒ}|j|d jd|ƒƒ|j|djd|ƒƒdS(s92to3 a single directory with a new output dir and suffix.tTESTs-ns --add-suffixs--write-unchanged-filess --no-diffss --output-dirtis implies -w.s6Output in %r will mirror the input directory %r layoutc3s|]}|ˆVqdS(N((t.0tname(tsuffix(s-/sys/lib/python2.7/lib2to3/tests/test_main.pys fssWriting converted %s to %ssNo changes to .*/__init__\.pyt/sNo changes to .*/trivial\.pyN(RHR%R"R;R:R(R)tassertIntsetR=R7tlistdirR8R9RtescapetseptassertRegexpMatchestreplaceR(R R,R.R/RRLRS((RMs-/sys/lib/python2.7/lib2to3/tests/test_main.pyt+test_filename_changing_on_output_single_dirUs4     " (cCsà|jƒtjƒ}|j|jg}td„|Dƒƒ}|jddddd|jg|tjdƒtjƒ|ƒ}|j|dƒ|jƒ}|j d |j|j f|ƒ|j|tt j |jƒƒƒd S( s62to3 two files in one directory with a new output dir.css!|]}tjj|ƒVqdS(N(R7R8RC(RKRL((s-/sys/lib/python2.7/lib2to3/tests/test_main.pys wss-ns-ws--write-unchanged-filess --no-diffss --output-dirRJis6Output in %r will mirror the input directory %r layoutN( RHR%RDRERPR"R;R(R)ROR:R7RQ(R R.t py2_filestexpected_filesR/R((s-/sys/lib/python2.7/lib2to3/tests/test_main.pyt*test_filename_changing_on_output_two_filesrs    cCsÏ|jƒtjƒ}|jdddd|j|jgtjdƒtjƒ|ƒ}|j|dƒ|jƒ}|jd|j|jf|ƒ|jt t j j |jƒgƒt t j |jƒƒƒdS( s)2to3 a single file with a new output dir.s-ns-ws --no-diffss --output-dirRJis6Output in %r will mirror the input directory %r layoutN(RHR%R"R;RDR(R)ROR:RPR7R8RCRQ(R R.R/R((s-/sys/lib/python2.7/lib2to3/tests/test_main.pyt,test_filename_changing_on_output_single_fileƒs    !N(t__name__t __module__RtunittesttTestCaseRRRRR"R1RHRVRYRZ(((s-/sys/lib/python2.7/lib2to3/tests/test_main.pyRs      t__main__(RR&RR7RRR%R5R]tlib2to3RR8R9tdirnamet__file__t TEST_DATA_DIRRBR^RR[(((s-/sys/lib/python2.7/lib2to3/tests/test_main.pyts          !€