Your IP : 216.73.216.213


Current Path : /opt/alt/python33/lib64/python3.3/lib2to3/tests/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/lib2to3/tests/__pycache__/test_refactor.cpython-33.pyo

�
��fG.c@sTdZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZmZddlmZddlmZejjejje�d�Zejjed	�Zejje�ze
jd
�ZWdejj�Xe
jd�ZGdd
�d
e
j�Z dS(u
Unit tests for refactor.py.
i(uwith_statementN(urefactorupygramu
fixer_base(utokeni(usupportudataufixersumyfixesu
lib2to3.fixescBs=|EeZdZdd�Zdd�Zdd�Zd/ed/dd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zed/d/d0dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/S(1uTestRefactoringToolcCstjjt�dS(N(usysupathuappendu	FIXER_DIR(uself((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyusetUp$suTestRefactoringTool.setUpcCstjj�dS(N(usysupathupop(uself((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutearDown'suTestRefactoringTool.tearDowncCsJxCt||�D]2\}}t||�s|jd||�qqWdS(Nu%s are not instances of %s(uzipu
isinstanceufail(uselfu	instancesuclassesuinstucls((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyucheck_instances*su#TestRefactoringTool.check_instancescCstj|||�S(N(urefactoruRefactoringTool(uselfuoptionsufixersuexplicit((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyurt/suTestRefactoringTool.rtcCsI|jidd6�}|j|jtj�|j|jjtj�dS(Nuprint_functionT(urtuTrueuassertIsugrammarupygramu!python_grammar_no_print_statementudriver(uselfurt((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_print_function_option2su.TestRefactoringTool.test_print_function_optioncCsF|j�}|j|j�|jidd6�}|j|j�dS(Nuwrite_unchanged_filesT(urtuassertFalseuwrite_unchanged_filesuTrueu
assertTrue(uselfurt((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyu!test_write_unchanged_files_option8su5TestRefactoringTool.test_write_unchanged_files_optioncCs�dddddg}tjd�}tjdd
�}tjd�}|j|dd�|D��|j||�|j|d	d�|D��dS(NuexplicitufirstulastuparrotupreorderumyfixescSsg|]}d|�qS(ufix_((u.0uname((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyu
<listcomp>Cs	uBTestRefactoringTool.test_fixer_loading_helpers.<locals>.<listcomp>cSsg|]}d|�qS(umyfixes.fix_((u.0uname((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyu
<listcomp>Fs	F(urefactoruget_all_fix_namesuFalseuget_fixers_from_packageuassertEqual(uselfucontentsunon_prefixeduprefixedu
full_names((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_fixer_loading_helpers>s	u.TestRefactoringTool.test_fixer_loading_helperscCstj}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((Nuu%from __future__ import print_functionuprint_functionu!from __future__ import generatorsu
generatorsu*from __future__ import generators, featureufeatureu1from __future__ import generators, print_functionu1from __future__ import print_function, generatorsu(from __future__ import (print_function,)u3from __future__ import (generators, print_function)u2from __future__ import (generators, nested_scopes)u
nested_scopesuGfrom __future__ import generators
from __future__ import print_functionufromufrom 4ufrom xufrom x 5u	from x imu
from x importufrom x import 4u1'docstring'
from __future__ import print_functionu9'docstring'
'somng'
from __future__ import print_functionu/# comment
from __future__ import print_functionu5# comment
'doc'
from __future__ import print_functionu3class x: pass
from __future__ import print_function(uprint_function(u
generators(u
generatorsufeature(u
generatorsuprint_function(uprint_functionu
generators(uprint_function(u
generatorsuprint_function(u
generatorsu
nested_scopes(u
generatorsuprint_function(ufromufrom 4ufrom xufrom x 5u	from x imu
from x importufrom x import 4(uprint_function(uprint_function(uprint_function(urefactoru_detect_future_featuresu	frozensetuassertEqual(uselfurunufsuemptyuinpuinvalid((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_detect_future_featuresHsR		



u/TestRefactoringTool.test_detect_future_featurescCsGdd�dtj�}Gdd�dtj�}Gdd�dtj�}|ig�}|ig�}|ig�}tj|||g�}|jtjj�}|j|||g�|jt	j
�}	|j|	||g�x'|j�D]}
|j|
|g�q�WdS(NcBs|EeZdZdS(u;TestRefactoringTool.test_get_headnode_dict.<locals>.NoneFixN(u__name__u
__module__u__qualname__(u
__locals__((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyuNoneFixvsuNoneFixcBs|EeZdZdZdS(u@TestRefactoringTool.test_get_headnode_dict.<locals>.FileInputFixufile_input< any * >N(u__name__u
__module__u__qualname__uPATTERN(u
__locals__((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyuFileInputFixysuFileInputFixcBs|EeZdZdZdS(u=TestRefactoringTool.test_get_headnode_dict.<locals>.SimpleFixu'name'N(u__name__u
__module__u__qualname__uPATTERN(u
__locals__((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyu	SimpleFix|su	SimpleFix(u
fixer_baseuBaseFixurefactoru_get_headnode_dictupopupygramupython_symbolsu
file_inputuassertEqualutokenuNAMEuvalues(uselfuNoneFixuFileInputFixu	SimpleFixuno_headu	with_headusimpleudu	top_fixesu
name_fixesufixes((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_get_headnode_dictusu*TestRefactoringTool.test_get_headnode_dictcCs�ddlm}ddlm}ddlm}ddlm}|j�}|j	�\}}|j
||g�|j
||||g�dS(Ni(uFixFirst(uFixLast(u	FixParrot(uFixPreorder(umyfixes.fix_firstuFixFirstumyfixes.fix_lastuFixLastumyfixes.fix_parrotu	FixParrotumyfixes.fix_preorderuFixPreorderurtu
get_fixersucheck_instances(uselfuFixFirstuFixLastu	FixParrotuFixPreorderurtupreupost((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_fixer_loading�su&TestRefactoringTool.test_fixer_loadingcCs^|jt|jddg�|jtj|jddg�|jtj|jddg�dS(Nufixersunot_hereuno_fixer_clsu	bad_order(uassertRaisesuImportErrorurturefactoru
FixerError(uself((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_naughty_fixers�su'TestRefactoringTool.test_naughty_fixerscCsl|j�}d}|j|d�}|jt|�|�d}|j|d�}|jt|�|�dS(Nudef parrot(): pass

u<test>udef f(): pass

(urturefactor_stringuassertNotEqualustruassertEqual(uselfurtuinpututree((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_refactor_string�su(TestRefactoringTool.test_refactor_stringcs�G�fdd�dtj�}g�|t�}tj}tjd�t_z|j�Wd|t_Xddddg}|j	�|�dS(Ncs&|EeZdZ�fdd�ZdS(u5TestRefactoringTool.test_refactor_stdin.<locals>.MyRTcs�j||||g�dS(N(uextend(uselfuold_textunew_textufilenameuequal(uresults(u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyuprint_output�suBTestRefactoringTool.test_refactor_stdin.<locals>.MyRT.print_outputN(u__name__u
__module__u__qualname__uprint_output(u
__locals__(uresults(u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyuMyRT�suMyRTudef parrot(): pass

udef cheese(): pass

u<stdin>F(
urefactoruRefactoringToolu_DEFAULT_FIXERSusysustdinuiouStringIOurefactor_stdinuFalseuassertEqual(uselfuMyRTurtusaveuexpected((uresultsu@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_refactor_stdin�s	
u'TestRefactoringTool.test_refactor_stdincstjdd�}|jtj|�tj�|�tjj|tjj	����tj
�d��fdd�}|�}|jd|d|�}	|r�||	_n|	j
��|j||��|s�dS|	j
�d�|�}
|j||
�|
S(	Nuprefixu2to3-test_refactori�cs&t�d��}|j�SWdQXdS(Nurb(uopenuread(ufp(u	test_file(u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyu	read_file�su=TestRefactoringTool.check_file_refactoring.<locals>.read_fileufixersuoptionsT(utempfileumkdtempu
addCleanupushutilurmtreeucopyuosupathujoinubasenameuchmodurtu	log_debugu
refactor_fileuassertEqualuTrueuassertNotEqual(uselfu	test_fileufixersuoptionsumock_log_debuguactually_writeutmpdiru	read_fileuold_contentsurtunew_contents((u	test_fileu@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyucheck_file_refactoring�s$!	
	u*TestRefactoringTool.check_file_refactoringcCs)tjjtd�}|j|t�dS(Nuparrot_example.py(uosupathujoinu	FIXER_DIRucheck_file_refactoringu_DEFAULT_FIXERS(uselfu	test_file((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_refactor_file�su&TestRefactoringTool.test_refactor_filec
s�tjjtd�}g��fdd�}|j|dfdidd6d|dd
�d	tjtjj|�f}xE�D]&}d
|kr|j	||�PqqW|j
d|�f�dS(Nuparrot_example.pycs�j||�dS(N(uappend(umsguargs(udebug_messages(u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyurecording_log_debug�suXTestRefactoringTool.test_refactor_file_write_unchanged_file.<locals>.recording_log_debugufixersuoptionsuwrite_unchanged_filesumock_log_debuguactually_writeuNot writing changes to .*%s%suNot writing changesu%r not matched in %rTF(uosupathujoinu	FIXER_DIRucheck_file_refactoringuTrueuFalseusepubasenameuassertRegexufail(uselfu	test_fileurecording_log_debugu
message_regexumessage((udebug_messagesu@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyu'test_refactor_file_write_unchanged_file�s

u;TestRefactoringTool.test_refactor_file_write_unchanged_filecsy�fdd�}|gg�ddddddg}dg}|||�dtjjd	d
�g}|||�dS(Nc
s��fdd�}tjj}|tj_�j�}g�tjdd��z`tjtjj	�d��x0|D](}t
tjj	�|�d�j�qtW|j��Wd|tj_t
j��X�j��fdd�|D��dS(	Ncs�j|�dS(N(uappend(uselfufuargs(ugot(u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyumock_refactor_file�suPTestRefactoringTool.test_refactor_dir.<locals>.check.<locals>.mock_refactor_fileuprefixu2to3-test_refactorua_diruwbcs%g|]}tjj�|��qS((uosupathujoin(u.0upath(udir(u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyu
<listcomp>s	uHTestRefactoringTool.test_refactor_dir.<locals>.check.<locals>.<listcomp>(urefactoruRefactoringToolu
refactor_fileurtutempfileumkdtempuosumkdirupathujoinuopenucloseurefactor_dirushutilurmtreeuassertEqual(u	structureuexpectedumock_refactor_fileu	save_funcurtufn(uself(udirugotu@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyucheck�s
&	u4TestRefactoringTool.test_refactor_dir.<locals>.checkunothinguhi.pyu.dumbu	.after.pyu	notpy.npyusappyua_dirustuff.py(uosupathujoin(uselfucheckutreeuexpected((uselfu@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_refactor_dir�s
		
u%TestRefactoringTool.test_refactor_dircCs&tjjtd�}|j|�dS(Nudifferent_encoding.py(uosupathujoinu
TEST_DATA_DIRucheck_file_refactoring(uselfufn((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_file_encodingsu&TestRefactoringTool.test_file_encodingcCs(tjjtd�}|j|�}dS(Nufalse_encoding.py(uosupathujoinu
TEST_DATA_DIRucheck_file_refactoring(uselfufnudata((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_false_file_encodingsu,TestRefactoringTool.test_false_file_encodingcCsAtjjtd�}|j|�}|j|jtj��dS(Nubom.py(	uosupathujoinu
TEST_DATA_DIRucheck_file_refactoringu
assertTrueu
startswithucodecsuBOM_UTF8(uselfufnudata((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_bomsuTestRefactoringTool.test_bomcCs[tj}dt_z8tjjtd�}tjd�}|j||�Wd|t_XdS(Nu
ucrlf.pyu
lib2to3.fixes(uosulinesepupathujoinu
TEST_DATA_DIRurefactoruget_fixers_from_packageucheck_file_refactoring(uselfuold_sepufnufixes((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_crlf_newliness		u&TestRefactoringTool.test_crlf_newlinescCs`|j�}d}|j|d�}|j||�d}|j|d�}|j||�dS(Nu
>>> example()
42
u<test>u&
>>> def parrot():
...      return 43
(urturefactor_docstringuassertEqualuassertNotEqual(uselfurtudocuout((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyutest_refactor_docstring%su+TestRefactoringTool.test_refactor_docstringcCs�ddlm}|jddg�}|jt|j�d�|jddg�}x1|jD]}t||�r]Pq]q]W|jd�dS(Ni(uFixExplicitufixersumyfixes.fix_explicituexplicituexplicit fixer not loaded(umyfixes.fix_explicituFixExpliciturtuassertEqualulenu
post_orderu
isinstanceufail(uselfuFixExpliciturtufix((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyu
test_explicit6su!TestRefactoringTool.test_explicitNT(u__name__u
__module__u__qualname__usetUputearDownucheck_instancesuNoneu_DEFAULT_FIXERSurtutest_print_function_optionu!test_write_unchanged_files_optionutest_fixer_loading_helpersutest_detect_future_featuresutest_get_headnode_dictutest_fixer_loadingutest_naughty_fixersutest_refactor_stringutest_refactor_stdinu_2TO3_FIXERSuTrueucheck_file_refactoringutest_refactor_fileu'test_refactor_file_write_unchanged_fileutest_refactor_dirutest_file_encodingutest_false_file_encodingutest_bomutest_crlf_newlinesutest_refactor_docstringu
test_explicit(u
__locals__((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyuTestRefactoringTool"s2
-
 
uTestRefactoringTool(!u__doc__u
__future__uwith_statementusysuosucodecsuoperatoruioutempfileushutiluunittestuwarningsulib2to3urefactorupygramu
fixer_baseu
lib2to3.pgen2utokenuusupportupathujoinudirnameu__file__u
TEST_DATA_DIRu	FIXER_DIRuappenduget_fixers_from_packageu_DEFAULT_FIXERSupopu_2TO3_FIXERSuTestCaseuTestRefactoringTool(((u@/opt/alt/python33/lib64/python3.3/lib2to3/tests/test_refactor.pyu<module>s*!