tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Y\¬Qc@€sTdZddlmZddlZddlZddlZddlZddlZddlZddl    Z    ddl
Z
ddl Z ddl m Z mZmZddlmZddlmZejjejjeƒdƒZejjed    ƒZejjeƒze jd
ƒZWdejjƒXe jd ƒZd e
jfd „ƒYZ dS(s
Unit tests for refactor.py.
iÿÿÿÿ(twith_statementN(trefactortpygramt
fixer_base(ttokeni(tsupporttdatatfixerstmyfixess lib2to3.fixestTestRefactoringToolcB€sãeZd„Zd„Zd„Zdedd„Zd„Zd„Z    d„Z
d„Z d„Z d    „Z d
„Zd „Zd „Zedded „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cC€stjjtƒdS(N(tsystpathtappendt    FIXER_DIR(tself((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pytsetUp$scC€stjjƒdS(N(R
R tpop(R((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttearDown'scC€sJxCt||ƒD]2\}}t||ƒs|jd||ƒqqWdS(Ns%s are not instances of %s(tzipt
isinstancetfail(Rt    instancestclassestinsttcls((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pytcheck_instances*scC€stj|||ƒS(N(RtRefactoringTool(RtoptionsRtexplicit((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pytrt/scC€sO|jitd6ƒ}|j|jtjkƒ|j|jjtjkƒdS(Ntprint_function(RtTruet
assertTruetgrammarRt!python_grammar_no_print_statementtdriver(RR((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_print_function_option2scC€sF|jƒ}|j|jƒ|jitd6ƒ}|j|jƒdS(Ntwrite_unchanged_files(Rt assertFalseR%RR (RR((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyt!test_write_unchanged_files_option8s cC€s§dddddg}tjdƒ}tjdtƒ}tjdƒ}|j|g|D]}d|^qUƒ|j||ƒ|j|g|D]}d|^qŒƒdS(    NRtfirsttlasttparrottpreorderRtfix_s myfixes.fix_(Rtget_all_fix_namestFalsetget_fixers_from_packaget assertEqual(Rtcontentst non_prefixedtprefixedt
full_namestname((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_fixer_loading_helpers>s'    cC€stj}t}|ƒ}|j|dƒ|ƒ|j|dƒ|dƒƒ|j|dƒ|dƒƒ|j|dƒ|dƒƒd}|j||ƒ|dƒƒd    }|j||ƒ|dƒƒd
}|j||ƒ|d ƒƒd }|j||ƒ|d!ƒƒd }|j||ƒ|d"ƒƒd}|j||ƒ|d#ƒƒd$}x$|D]}|j||ƒ|ƒq[Wd}|j||ƒ|d%ƒƒd}|j||ƒ|ƒd}|j||ƒ|d&ƒƒd}|j||ƒ|d'ƒƒd}|j||ƒ|ƒdS((Nts%from __future__ import print_functionRs!from __future__ import generatorst
generatorss*from __future__ import generators, featuretfeatures1from __future__ import generators, print_functions1from __future__ import print_function, generatorss(from __future__ import (print_function,)s3from __future__ import (generators, print_function)s2from __future__ import (generators, nested_scopes)t nested_scopessGfrom __future__ import generators
from __future__ import print_functiontfromsfrom 4sfrom xsfrom x 5s    from x ims from x importsfrom x import 4s1'docstring'
from __future__ import print_functions9'docstring'
'somng'
from __future__ import print_functions/# comment
from __future__ import print_functions5# comment
'doc'
from __future__ import print_functions3class x: pass
from __future__ import print_function(sprint_function(R8(R8R9(R8sprint_function(sprint_functionR8(sprint_function(R8sprint_function(R8R:(R8sprint_function(R;sfrom 4sfrom xsfrom x 5s    from x ims from x importsfrom x import 4(sprint_function(sprint_function(sprint_function(Rt_detect_future_featurest    frozensetR0(Rtruntfstemptytinptinvalid((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_detect_future_featuresHsR            c C€sdtjfd„ƒY}dtjfd„ƒY}dtjfd„ƒY}|igƒ}|igƒ}|igƒ}tj|||gƒ}|jtjjƒ}|j|||gƒ|jt    j
ƒ}    |j|    ||gƒx'|j ƒD]}
|j|
|gƒqðWdS(NtNoneFixcB€seZRS((t__name__t
__module__(((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyRDvst FileInputFixcB€seZdZRS(sfile_input< any * >(RERFtPATTERN(((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyRGyst    SimpleFixcB€seZdZRS(s'name'(RERFRH(((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyRI|s( RtBaseFixRt_get_headnode_dictRRtpython_symbolst
file_inputR0RtNAMEt
itervalues( RRDRGRItno_headt    with_headtsimpletdt    top_fixest
name_fixestfixes((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_get_headnode_dictuscC€sŽddlm}ddlm}ddlm}ddlm}|jƒ}|j    ƒ\}}|j
||gƒ|j
||||gƒdS(Niÿÿÿÿ(tFixFirst(tFixLast(t    FixParrot(t FixPreorder( tmyfixes.fix_firstRXtmyfixes.fix_lastRYtmyfixes.fix_parrotRZtmyfixes.fix_preorderR[Rt
get_fixersR(RRXRYRZR[Rtpretpost((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_fixer_loadingŠs cC€s^|jt|jddgƒ|jtj|jddgƒ|jtj|jddgƒdS(NRtnot_heret no_fixer_clst    bad_order(t assertRaisest ImportErrorRRt
FixerError(R((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_naughty_fixers–scC€sl|jƒ}d}|j|dƒ}|jt|ƒ|ƒd}|j|dƒ}|jt|ƒ|ƒdS(Nsdef parrot(): pass
 
s<test>sdef f(): pass
 
(Rtrefactor_stringtassertNotEqualtstrR0(RRtinputttree((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_refactor_string›s c€sdtjf‡fd†ƒY}g‰|tƒ}tj}tjdƒt_z|jƒWd|t_Xdddtg}|jˆ|ƒdS(NtMyRTc€seZ‡fd†ZRS(c€sˆj||||gƒdS(N(textend(Rtold_texttnew_texttfilenametequal(tresults(sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyt print_output©s(RERFRx((Rw(sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyRq§ssdef parrot(): pass
 
sdef cheese(): pass
 
s<stdin>(    RRt_DEFAULT_FIXERSR
tstdintStringIOtrefactor_stdinR.R0(RRqRtsavetexpected((Rwsc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_refactor_stdin¥s     
 c €sÿtjddƒ}|jtj|ƒtjˆ|ƒtjj|tjj    ˆƒƒ‰tj
ˆdƒ‡fd†}|ƒ}|j d|d|ƒ}    |r¨||    _ n|    j ˆƒ|j||ƒƒ|sÒdS|    j ˆtƒ|ƒ}
|j||
ƒ|
S(Ntprefixs2to3-test_refactori¤c€s&tˆdƒ}|jƒSWdQXdS(Ntrb(topentread(tfp(t    test_file(sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyt    read_fileÃsRR(ttempfiletmkdtempt
addCleanuptshutiltrmtreetcopytosR tjointbasenametchmodRt    log_debugt refactor_fileR0RRl( RR…RRtmock_log_debugtactually_writettmpdirR†t old_contentsRt new_contents((R…sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pytcheck_file_refactoring¹s$!          cC€s)tjjtdƒ}|j|tƒdS(Nsparrot_example.py(RR RŽR R˜Ry(RR…((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_refactor_fileÖsc
€sÁtjjtdƒ}g‰‡fd†}|j|dd ditd6d|dtƒdtjtjj|ƒf}xEˆD]&}d    |kr||j    ||ƒPq|q|W|j
d
|ˆfƒdS( Nsparrot_example.pyc€sˆj||ƒdS(N(R (tmsgtargs(tdebug_messages(sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pytrecording_log_debugÝsRRR%R“R”sNot writing changes to .*%s%ssNot writing changess%r not matched in %r(( RR RŽR R˜RR.tsepRtassertRegexpMatchesR(RR…Rt message_regextmessage((Rœsc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyt'test_refactor_file_write_unchanged_fileÚs   c€sv‡fd†}|ggƒddddddg}dg}|||ƒdtjjdd    ƒg}|||ƒdS(
Nc€sþ‡fd†}tjj}|tj_ˆjƒ}g‰tjddƒ}z`tjtjj    |dƒƒx0|D](}t
tjj    ||ƒdƒj ƒqqW|j |ƒWd|tj_t j|ƒXˆjˆg|D]}tjj    ||ƒ^q؃dS(Nc€sˆj|ƒdS(N(R (RtfR›(tgot(sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pytmock_refactor_fileðsR€s2to3-test_refactorta_dirtwb(RRR’RR‡RˆRtmkdirR RŽR‚tcloset refactor_dirRŠR‹R0(t    structureR~R¥t    save_funcRtdirtfnR (R(R¤sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pytcheckïs    &     tnothingshi.pys.dumbs    .after.pys    notpy.npytsappyR¦sstuff.py(RR RŽ(RR¯RoR~((Rsc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_refactor_dirîs          cC€s&tjjtdƒ}|j|ƒdS(Nsdifferent_encoding.py(RR RŽt TEST_DATA_DIRR˜(RR®((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_file_encodingscC€sAtjjtdƒ}|j|ƒ}|j|jtjƒƒdS(Nsbom.py(    RR RŽR³R˜R t
startswithtcodecstBOM_UTF8(RR®R((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_bomscC€s[tj}dt_z8tjjtdƒ}tjdƒ}|j||ƒWd|t_XdS(Ns
scrlf.pys lib2to3.fixes(RtlinesepR RŽR³RR/R˜(Rtold_sepR®RV((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_crlf_newliness        cC€s`|jƒ}d}|j|dƒ}|j||ƒd}|j|dƒ}|j||ƒdS(Ns
>>> example()
42
s<test>s&
>>> def parrot():
...      return 43
(Rtrefactor_docstringR0Rl(RRtdoctout((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyttest_refactor_docstring!s cC€s‹ddlm}|jddgƒ}|jt|jƒdƒ|jddgƒ}x1|jD]}t||ƒr]Pq]q]W|jdƒdS(Niÿÿÿÿ(t FixExplicitRsmyfixes.fix_explicitiRsexplicit fixer not loaded(tmyfixes.fix_explicitRÀRR0tlent
post_orderRR(RRÀRtfix((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyt test_explicit2sN(RERFRRRtNoneRyRR$R'R6RCRWRcRjRpRt _2TO3_FIXERSRR˜R™R¢R²R´R¸R»R¿RÅ(((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyR    "s0                        
   -                
                             
   (!t__doc__t
__future__RR
RR¶toperatorR{R‡RŠtunittesttwarningstlib2to3RRRt lib2to3.pgen2RR7RR RŽtdirnamet__file__R³R R R/RyRRÇtTestCaseR    (((sc/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/tests/test_refactor.pyt<module>s*         !