Your IP : 216.73.217.129


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_sys_setprofile.cpython-35.pyc



��Yf�+�@sddlZddlZddlZddlZGdd�dej�ZGdd�d�ZGdd�de�ZGdd	�d	ej�ZGd
d�de�Z	Gdd
�d
e�Z
dd�Zdd�Zee�Z
ddd�Zdd�Zedkrej�dS)�Nc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestGetProfilecCstjd�dS)N)�sys�
setprofile)�self�r�=/opt/alt/python35/lib64/python3.5/test/test_sys_setprofile.py�setUpszTestGetProfile.setUpcCstjd�dS)N)rr)rrrr�tearDownszTestGetProfile.tearDowncCs|jtj��dS)N)ZassertIsNoner�
getprofile)rrrr�
test_emptyszTestGetProfile.test_emptycCs3dd�}tj|�|jtj�|�dS)NcWsdS)Nr)�argsrrr�fnsz&TestGetProfile.test_setget.<locals>.fn)rrZassertIsr
)rr
rrr�test_setgets
zTestGetProfile.test_setgetN)�__name__�
__module__�__qualname__rr	rrrrrrrsrc@sCeZdZdd�Zdd�Zddd�Zdd	�ZdS)
�HookWatchercCsg|_g|_dS)N)�frames�events)rrrr�__init__s	zHookWatcher.__init__cCs8|dks$|dks$|dkr4|j||�dS)N�call�return�	exception)�	add_event)r�frame�event�argrrr�callbackszHookWatcher.callbackNc
Cs�|dkrtjd�}y|jj|�}Wn1tk
rdt|j�}|jj|�YnX|jj||t|�f�dS)zAdd an event to the log.N�)	r�	_getframer�index�
ValueError�len�appendr�ident)rrrZframenorrrr#s
zHookWatcher.add_eventcsAt|jj�tt�g�d|_�fdd�|jD�S)zRemove calls to add_event().Ncs&g|]}|d�kr|�qS)�r)�.0�item)�
disallowedrr�
<listcomp>5s	z*HookWatcher.get_events.<locals>.<listcomp>)r$r�__func__rr)rr)r(r�
get_events0s	zHookWatcher.get_events)rrrrrrr+rrrrrs
rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
edededededeiZ	dS)�ProfileSimulatorcCs#||_g|_tj|�dS)N)�testcase�stackrr)rr-rrrr9s		zProfileSimulator.__init__cCs|j|||�dS)N)�dispatch)rrrrrrrr>szProfileSimulator.callbackcCs$|jd|�|jj|�dS)Nr)rr.r#)rrrrr�
trace_callBszProfileSimulator.trace_callcCs!|jd|�|jj�dS)Nr)rr.�pop)rrrrr�trace_returnFszProfileSimulator.trace_returncCs|jjd�dS)Nz2the profiler should never receive exception events)r-�fail)rrrrr�trace_exceptionJs	z ProfileSimulator.trace_exceptioncCsdS)Nr)rrrrr�
trace_passNszProfileSimulator.trace_passrrrZc_callZc_returnZc_exceptionN)
rrrrrr0r2r4r5r/rrrrr,8sr,c@seZdZdd�ZdS)�TestCaseBasecCsNt||j��}||krJ|jdtj|�tj|�f�dS)Nz'Expected events:
%s
Received events:
%s)�capture_events�new_watcherr3�pprintZpformat)r�callableZexpectedrrrr�check_events\s	zTestCaseBase.check_eventsN)rrrr;rrrrr6[sr6c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�ProfileHookTestCasecCst�S)N)r)rrrrr8dszProfileHookTestCase.new_watchercCsDdd�}t|�}|j|dd|fdd|fg�dS)NcSsdS)Nr)�prrr�fhsz*ProfileHookTestCase.test_simple.<locals>.frrr)r$r;)rr>�f_identrrr�test_simplegszProfileHookTestCase.test_simplecCsDdd�}t|�}|j|dd|fdd|fg�dS)NcSsdddS)Nrrr)r=rrrr>psz-ProfileHookTestCase.test_exception.<locals>.frrr)r$r;)rr>r?rrr�test_exceptionosz"ProfileHookTestCase.test_exceptioncCsDdd�}t|�}|j|dd|fdd|fg�dS)Nc	SsyddWnYnXdS)Nrrr)r=rrrr>xsz4ProfileHookTestCase.test_caught_exception.<locals>.frrr)r$r;)rr>r?rrr�test_caught_exceptionwsz)ProfileHookTestCase.test_caught_exceptioncCsDdd�}t|�}|j|dd|fdd|fg�dS)Nc	SsyddWnYnXdS)Nrrr)r=rrrr>�sz;ProfileHookTestCase.test_caught_nested_exception.<locals>.frrr)r$r;)rr>r?rrr�test_caught_nested_exception�sz0ProfileHookTestCase.test_caught_nested_exceptioncCsDdd�}t|�}|j|dd|fdd|fg�dS)NcSsdddS)Nrrr)r=rrrr>�sz4ProfileHookTestCase.test_nested_exception.<locals>.frrr)r$r;)rr>r?rrr�test_nested_exception�sz)ProfileHookTestCase.test_nested_exceptionc
s�dd���fdd�}t��}t|�}|j|dd|fdd|fdd|fd	d|fd	d|fdd|fg�dS)
NcSsdddS)Nrrr)r=rrrr>�sz>ProfileHookTestCase.test_exception_in_except_clause.<locals>.fcs6y�|�Wn!y�|�WnYnXYnXdS)Nr)r=)r>rr�g�sz>ProfileHookTestCase.test_exception_in_except_clause.<locals>.grrr%r�)r$r;)rrEr?�g_identr)r>r�test_exception_in_except_clause�sz3ProfileHookTestCase.test_exception_in_except_clausec	s�dd���fdd�}t��}t|�}|j|dd|fdd|fdd|fdd	|fdd|fg�dS)
NcSsdddS)Nrrr)r=rrrr>�sz9ProfileHookTestCase.test_exception_propagation.<locals>.fcs#z�|�Wd|jd�XdS)Nzfalling through)r)r=)r>rrrE�sz9ProfileHookTestCase.test_exception_propagation.<locals>.grrr%rzfalling through)r$r;)rrEr?rGr)r>r�test_exception_propagation�sz.ProfileHookTestCase.test_exception_propagationcCsDdd�}t|�}|j|dd|fdd|fg�dS)Nc	Ss#yddWnddYnXdS)Nrrr)r=rrrr>�sz/ProfileHookTestCase.test_raise_twice.<locals>.frrr)r$r;)rr>r?rrr�test_raise_twice�sz$ProfileHookTestCase.test_raise_twicecCsDdd�}t|�}|j|dd|fdd|fg�dS)Nc	SsyddWn�YnXdS)Nrrr)r=rrrr>�sz1ProfileHookTestCase.test_raise_reraise.<locals>.frrr)r$r;)rr>r?rrr�test_raise_reraise�sz&ProfileHookTestCase.test_raise_reraisecCsDdd�}t|�}|j|dd|fdd|fg�dS)NcSs
t��dS)N)�	Exception)r=rrrr>�sz)ProfileHookTestCase.test_raise.<locals>.frrr)r$r;)rr>r?rrr�
test_raise�szProfileHookTestCase.test_raisecsdd���fdd���fdd���fdd���fd	d
�}t��}t��}t��}t��}t|�}|j|dd|fd
d|fdd|fdd|fdd|fdd|fdd|fdd|fd
d|fdd|fg
�dS)NcSsdddS)Nrrrrrrrr>�sz5ProfileHookTestCase.test_distant_exception.<locals>.fcs��dS)Nrr)r>rrrE�sz5ProfileHookTestCase.test_distant_exception.<locals>.gcs��dS)Nrr)rErr�h�sz5ProfileHookTestCase.test_distant_exception.<locals>.hcs��dS)Nrr)rNrr�i�sz5ProfileHookTestCase.test_distant_exception.<locals>.ics��dS)Nr)r=)rOrr�j�sz5ProfileHookTestCase.test_distant_exception.<locals>.jrrr%rF��r)r$r;)rrPr?rG�h_ident�i_ident�j_identr)r>rErNrOr�test_distant_exception�s(z*ProfileHookTestCase.test_distant_exceptioncs�dd���fdd�}t��}t|�}|j|dd|fdd|fdd|fdd|fdd|fdd|fdd|fdd|fg�dS)	Ncss xtd�D]}|Vq
WdS)Nr%)�range)rOrrrr>�sz-ProfileHookTestCase.test_generator.<locals>.fcsx��D]}q
WdS)Nr)r=rO)r>rrrE�sz-ProfileHookTestCase.test_generator.<locals>.grrr%r)r$r;)rrEr?rGr)r>r�test_generator�sz"ProfileHookTestCase.test_generatorcs�dd���fdd�}t��}t|�}|j|dd|fdd|fdd|fdd|fdd|fdd|fdd|fdd|fg�dS)	Ncss xtd�D]}|Vq
WdS)Nr%)rW)rOrrrr>sz2ProfileHookTestCase.test_stop_iteration.<locals>.fcsx��D]}q
WdS)Nr)r=rO)r>rrrEsz2ProfileHookTestCase.test_stop_iteration.<locals>.grrr%r)r$r;)rrEr?rGr)r>r�test_stop_iterationsz'ProfileHookTestCase.test_stop_iterationN)rrrr8r@rArBrCrDrHrIrJrKrMrVrXrYrrrrr<cs				r<c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ProfileSimulatorTestCasecCs
t|�S)N)r,)rrrrr8sz$ProfileSimulatorTestCase.new_watchercCsDdd�}t|�}|j|dd|fdd|fg�dS)NcSsdS)Nr)r=rrrr>sz/ProfileSimulatorTestCase.test_simple.<locals>.frrr)r$r;)rr>r?rrrr@sz$ProfileSimulatorTestCase.test_simplecCsDdd�}t|�}|j|dd|fdd|fg�dS)NcSsdddS)Nrrr)r=rrrr>%sz8ProfileSimulatorTestCase.test_basic_exception.<locals>.frrr)r$r;)rr>r?rrr�test_basic_exception$sz-ProfileSimulatorTestCase.test_basic_exceptioncCsDdd�}t|�}|j|dd|fdd|fg�dS)Nc	SsyddWnYnXdS)Nrrr)r=rrrr>-sz9ProfileSimulatorTestCase.test_caught_exception.<locals>.frrr)r$r;)rr>r?rrrrB,sz.ProfileSimulatorTestCase.test_caught_exceptioncsdd���fdd���fdd���fdd���fd	d
�}t��}t��}t��}t��}t|�}|j|dd|fd
d|fdd|fdd|fdd|fdd|fdd|fdd|fd
d|fdd|fg
�dS)NcSsdddS)Nrrrrrrrr>6sz:ProfileSimulatorTestCase.test_distant_exception.<locals>.fcs��dS)Nrr)r>rrrE8sz:ProfileSimulatorTestCase.test_distant_exception.<locals>.gcs��dS)Nrr)rErrrN:sz:ProfileSimulatorTestCase.test_distant_exception.<locals>.hcs��dS)Nrr)rNrrrO<sz:ProfileSimulatorTestCase.test_distant_exception.<locals>.ics��dS)Nr)r=)rOrrrP>sz:ProfileSimulatorTestCase.test_distant_exception.<locals>.jrrr%rFrQrRr)r$r;)rrPr?rGrSrTrUr)r>rErNrOrrV5s(z/ProfileSimulatorTestCase.test_distant_exceptionN)rrrr8r@r[rBrVrrrrrZs
	rZcCs4t|d�r|j}n	|j}|j|jfS)N�f_code)�hasattrr\�__code__�co_firstlineno�co_name)Zfunction�coderrrr$Rs	r$c	Csy||�WnYnXdS)Nr)r>r=rrr�protectZsrbcCs�|dkrt�}tj�}tj�z.tj|j�t||�tjd�Wd|rltj�X|j	�dd�S)Nr���)
r�gc�	isenabled�disablerrrrb�enabler+)r:r=Zold_gcrrrr7as	

r7cCs#ddl}|jt|��dS)Nr)r9r7)r:r9rrr�show_eventsrsrh�__main__)rdr9rZunittestZTestCaserrr,r6r<rZr$rbZ
protect_identr7rhr�mainrrrr�<module>s  #�: