ACC SHELL

Path : /usr/lib/python/lib2to3/tests/
File Upload :
Current File : //usr/lib/python/lib2to3/tests/test_refactor.pyc

Ñò
sÄMc@sDdZddkZddkZddkZddkZddkZddkZddkZddkZddk	Z	ddk
lZlZl
Z
ddklZddklZeiieiieƒdƒZeiiedƒZeiieƒzeid	ƒZWdeiiƒXeid
ƒZdeifd„ƒYZdS(
s
Unit tests for refactor.py.
iÿÿÿÿN(trefactortpygramt
fixer_base(ttokeni(tsupporttdatatfixerstmyfixess
lib2to3.fixestTestRefactoringToolcBsÈeZd„Zd„Zd„Zdedd„Zd„Zd„Z	d„Z
d„Zd„Zd	„Z
d
„Zd„Zed„Zd
„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cCstiitƒdS(N(tsystpathtappendt	FIXER_DIR(tself((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pytsetUp"scCstiiƒdS(N(R	R
tpop(R
((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttearDown%scCsLxEt||ƒD]4\}}t||ƒp|id||ƒqqWdS(Ns%s are not instances of %s(tzipt
isinstancetfail(R
t	instancestclassestinsttcls((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pytcheck_instances(scCsti|||ƒS(N(RtRefactoringTool(R
toptionsRtexplicit((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pytrt-scCsO|ihtd6ƒ}|i|itijƒ|i|iitijƒdS(Ntprint_function(RtTruet
assertTruetgrammarRt!python_grammar_no_print_statementtdriver(R
R((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_print_function_option0sc	Cs·dddddg}tidƒ}tidtƒ}tidƒ}|i|g}|D]}|d|qY~ƒ|i||ƒ|i|g}|D]}|d|q˜~ƒdS(	NRtfirsttlasttparrottpreorderRtfix_smyfixes.fix_(Rtget_all_fix_namestFalsetget_fixers_from_packagetassertEqual(R
tcontentstnon_prefixedtprefixedt
full_namest_[1]tnamet_[2]((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_fixer_loading_helpers6s/	cCsñti}|i|dƒƒ|i|dƒƒ|i|dƒƒ|i|dƒƒd}|i||ƒƒd}|i||ƒƒd}|i||ƒƒd}|i||ƒƒd	}|i||ƒƒd
}|i||ƒƒ|i|dƒƒ|i|dƒƒ|i|d
ƒƒ|i|dƒƒ|i|dƒƒ|i|dƒƒ|i|dƒƒd}|i||ƒƒd}|i||ƒƒd}|i||ƒƒd}|i||ƒƒd}|i||ƒƒdS(Nts%from __future__ import print_functions!from __future__ import generatorss*from __future__ import generators, features1from __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)sGfrom __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(Rt_detect_future_printtassertFalseR(R
truntinput((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_detect_future_print@sD	cCsdtifd„ƒY}dtifd„ƒY}dtifd„ƒY}|hgƒ}|hgƒ}|hgƒ}ti|||gƒ}|itiiƒ}|i|||gƒ|it	i
ƒ}	|i|	||gƒx'|iƒD]}
|i|
|gƒqðWdS(NtNoneFixcBseZRS((t__name__t
__module__(((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyR<fstFileInputFixcBseZdZRS(sfile_input< any * >(R=R>tPATTERN(((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyR?ist	SimpleFixcBseZdZRS(s'name'(R=R>R@(((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyRAls(RtBaseFixRt_get_headnode_dictRRtpython_symbolst
file_inputR,RtNAMEt
itervalues(R
R<R?RAtno_headt	with_headtsimpletdt	top_fixest
name_fixestfixes((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_get_headnode_dictes
c	CsŽddkl}ddkl}ddkl}ddkl}|iƒ}|i	ƒ\}}|i
||gƒ|i
||||gƒdS(Niÿÿÿÿ(tFixFirst(tFixLast(t	FixParrot(tFixPreorder(tmyfixes.fix_firstRPtmyfixes.fix_lastRQtmyfixes.fix_parrotRRtmyfixes.fix_preorderRSRt
get_fixersR(R
RPRQRRRSRtpretpost((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_fixer_loadingzscCs^|it|iddgƒ|iti|iddgƒ|iti|iddgƒdS(NRtnot_heretno_fixer_clst	bad_order(tassertRaisestImportErrorRRt
FixerError(R
((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_naughty_fixers†scCsl|iƒ}d}|i|dƒ}|it|ƒ|ƒd}|i|dƒ}|it|ƒ|ƒdS(Nsdef parrot(): pass

s<test>sdef f(): pass

(Rtrefactor_stringtassertNotEqualtstrR,(R
RR:ttree((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_refactor_string‹scsdtif‡fd†ƒY}g‰|tƒ}ti}tidƒt_z|iƒWd|t_Xdddtg}|iˆ|ƒdS(NtMyRTcseZ‡fd†ZRS(csˆi||||gƒdS(N(textend(R
told_texttnew_texttfilenametequal(tresults(s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pytprint_output™s(R=R>Ro((Rn(s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyRh—ssdef parrot(): pass

sdef cheese(): pass

s<stdin>(	RRt_DEFAULT_FIXERSR	tstdintStringIOtrefactor_stdinR*R,(R
RhRtsavetexpected((Rns1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_refactor_stdin•s	
c	s¸‡fd†}|ƒ}|id|ƒ}|iˆƒ|i||ƒƒz-|iˆtƒ|ƒ}|i||ƒWdtˆdƒiiƒ}z|~}|i|ƒWdQXX|S(Ncs:tˆdƒiiƒ}z|~}|iƒSWdQXdS(Ntrb(topent__exit__t	__enter__tread(R1tfp(t	test_file(s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyt	read_fileªs&Rtwb(	Rt
refactor_fileR,RRdRxRyRztwrite(	R
R}RR~told_contentsRtnew_contentsR1R|((R}s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pytcheck_file_refactoring©s	
	&cCs)tiitdƒ}|i|tƒdS(Nsparrot_example.py(tosR
tjoinRR„Rp(R
R}((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_refactor_file¼scss‡fd†}|ggƒdddddg}dg}|||ƒdtiiddƒg}|||ƒdS(	Nc	s‡fd†}tii}|ti_ˆiƒ}g‰tiddƒ}z`titii	|dƒƒx0|D](}t
tii	||ƒdƒiƒqqW|i|ƒWd|ti_t
i|ƒXˆiˆg}|D]}|tii	||ƒqÜ~ƒdS(Ncsˆi|ƒdS(N(R(R
tftargs(tgot(s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pytmock_refactor_fileÂstprefixs2to3-test_refactorta_dirR(RRR€RttempfiletmkdtempR…tmkdirR
R†Rxtclosetrefactor_dirtshutiltrmtreeR,(	t	structureRuR‹t	save_funcRtdirtfnR1R
(R
(RŠs1/usr/lib/python2.6/lib2to3/tests/test_refactor.pytcheckÁs &	tnothingshi.pys.dumbs	.after.pytsappyRsstuff.py(R…R
R†(R
R™RfRu((R
s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_refactor_dirÀs
		
cCs&tiitdƒ}|i|ƒdS(Nsdifferent_encoding.py(R…R
R†t
TEST_DATA_DIRR„(R
R˜((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_file_encodingßscCsAtiitdƒ}|i|ƒ}|i|itiƒƒdS(Nsbom.py(	R…R
R†RR„Rt
startswithtcodecstBOM_UTF8(R
R˜R((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_bomãscCs[ti}dt_z8tiitdƒ}tidƒ}|i||ƒWd|t_XdS(Ns
scrlf.pys
lib2to3.fixes(R…tlinesepR
R†RRR+R„(R
told_sepR˜RN((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_crlf_newlinesès		cCs`|iƒ}d}|i|dƒ}|i||ƒd}|i|dƒ}|i||ƒdS(Ns
>>> example()
42
s<test>s&
>>> def parrot():
...      return 43
(Rtrefactor_docstringR,Rd(R
Rtdoctout((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyttest_refactor_docstringòscCsddkl}|iddgƒ}|it|iƒdƒ|iddgƒ}x3|iD]}t||ƒoPq]q]W|idƒdS(Niÿÿÿÿ(tFixExplicitRsmyfixes.fix_explicitiRsexplicit fixer not loaded(tmyfixes.fix_explicitRªRR,tlent
post_orderRR(R
RªRtfix((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyt
test_explicits
	N(R=R>RRRtNoneRpRR#R4R;ROR[RbRgRvt_2TO3_FIXERSR„R‡RœRžR¢R¥R©R¯(((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyR s(					
	%				
						
	(t__doc__R	R…R toperatorRrRŽR“tunittesttwarningstlib2to3RRRt
lib2to3.pgen2RR5RR
R†tdirnamet__file__RRRR+RpRR±tTestCaseR(((s1/usr/lib/python2.6/lib2to3/tests/test_refactor.pyt<module>s(!

ACC SHELL 2018