Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_sys_setprofile.cpython-34.pyc

�
g f[,�@s,ddlZddlZddlZddlZddlmZGdd�dej�ZGdd�d�ZGdd�de�Z	Gd	d
�d
ej�Z
Gdd�de
�ZGd
d�de
�Zdd�Z
dd�Ze
e�Zddd�Zdd�Zdd�Zedkr(e�ndS)�N)�supportc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestGetProfilecCstjd�dS)N)�sys�
setprofile)�self�r�=/opt/alt/python34/lib64/python3.4/test/test_sys_setprofile.py�setUp	szTestGetProfile.setUpcCstjd�dS)N)rr)rrrr�tearDownszTestGetProfile.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)rrrrr�test_setgets
zTestGetProfile.test_setgetN)�__name__�
__module__�__qualname__r	r
rrrrrrrsrc@sCeZdZdd�Zdd�Zddd�Zdd	�ZdS)
�HookWatchercCsg|_g|_dS)N)�frames�events)rrrr�__init__s	zHookWatcher.__init__cCs;|dks$|dks$|dkr7|j||�ndS)N�call�return�	exception)�	add_event)r�frame�event�argrrr�callbackszHookWatcher.callbackNc
Cs�|dkrtjd�}ny|jj|�}Wn1tk
rgt|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>6s	z*HookWatcher.get_events.<locals>.<listcomp>)r%r�__func__rr)rr)r)r�
get_events1s	zHookWatcher.get_events)rrrrrrr,rrrrrs
rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zied
6ed6ed6ed6ed6ed6Z	dS)�ProfileSimulatorcCs#||_g|_tj|�dS)N)�testcase�stackrr)rr.rrrr:s		zProfileSimulator.__init__cCs|j|||�dS)N)�dispatch)rrrrrrrr?szProfileSimulator.callbackcCs$|jd|�|jj|�dS)Nr)rr/r$)rrrrr�
trace_callCszProfileSimulator.trace_callcCs!|jd|�|jj�dS)Nr)rr/�pop)rrrrr�trace_returnGszProfileSimulator.trace_returncCs|jjd�dS)Nz2the profiler should never receive exception events)r.�fail)rrrrr�trace_exceptionKs	z ProfileSimulator.trace_exceptioncCsdS)Nr)rrrrr�
trace_passOszProfileSimulator.trace_passrrrZc_callZc_returnZc_exceptionN)
rrrrrr1r3r5r6r0rrrrr-9sr-c@seZdZdd�ZdS)�TestCaseBasecCsQt||j��}||krM|jdtj|�tj|�f�ndS)Nz'Expected events:
%s
Received events:
%s)�capture_events�new_watcherr4�pprintZpformat)r�callableZexpectedrrrr�check_events]s	zTestCaseBase.check_eventsN)rrrr<rrrrr7\sr7c@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)rrrrr9eszProfileHookTestCase.new_watchercCsDdd�}t|�}|j|dd|fdd|fg�dS)NcSsdS)Nr)�prrr�fisz*ProfileHookTestCase.test_simple.<locals>.frrr)r%r<)rr?�f_identrrr�test_simplehszProfileHookTestCase.test_simplecCsDdd�}t|�}|j|dd|fdd|fg�dS)NcSsdddS)Nrrr)r>rrrr?qsz-ProfileHookTestCase.test_exception.<locals>.frrr)r%r<)rr?r@rrr�test_exceptionpsz"ProfileHookTestCase.test_exceptioncCsDdd�}t|�}|j|dd|fdd|fg�dS)Nc	SsyddWnYnXdS)Nrrr)r>rrrr?ysz4ProfileHookTestCase.test_caught_exception.<locals>.frrr)r%r<)rr?r@rrr�test_caught_exceptionxs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<)rrFr@�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_propogation.<locals>.fcs#z�|�Wd|jd�XdS)Nzfalling through)r)r>)r?rrrF�sz9ProfileHookTestCase.test_exception_propogation.<locals>.grrr&rzfalling through)r%r<)rrFr@rHr)r?r�test_exception_propogation�sz.ProfileHookTestCase.test_exception_propogationcCsDdd�}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?rrrF�sz5ProfileHookTestCase.test_distant_exception.<locals>.gcs��dS)Nrr)rFrr�h�sz5ProfileHookTestCase.test_distant_exception.<locals>.hcs��dS)Nrr)rOrr�i�sz5ProfileHookTestCase.test_distant_exception.<locals>.ics��dS)Nr)r>)rPrr�j�sz5ProfileHookTestCase.test_distant_exception.<locals>.jrrr&rG��r)r%r<)rrQr@rH�h_ident�i_ident�j_identr)r?rFrOrPr�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)rPrrrr?�sz-ProfileHookTestCase.test_generator.<locals>.fcsx��D]}q
WdS)Nr)r>rP)r?rrrF�sz-ProfileHookTestCase.test_generator.<locals>.grrr&r)r%r<)rrFr@rHr)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
Wt�dS)Nr&)rX�
StopIteration)rPrrrr?s	z2ProfileHookTestCase.test_stop_iteration.<locals>.fcsx��D]}q
WdS)Nr)r>rP)r?rrrFsz2ProfileHookTestCase.test_stop_iteration.<locals>.grrr&r)r%r<)rrFr@rHr)r?r�test_stop_iterationsz'ProfileHookTestCase.test_stop_iterationN)rrrr9rArBrCrDrErIrJrKrLrNrWrYr[rrrrr=ds				r=c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ProfileSimulatorTestCasecCs
t|�S)N)r-)rrrrr9sz$ProfileSimulatorTestCase.new_watchercCsDdd�}t|�}|j|dd|fdd|fg�dS)NcSsdS)Nr)r>rrrr?sz/ProfileSimulatorTestCase.test_simple.<locals>.frrr)r%r<)rr?r@rrrrAs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@rrrrC.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?8sz:ProfileSimulatorTestCase.test_distant_exception.<locals>.fcs��dS)Nrr)r?rrrF:sz:ProfileSimulatorTestCase.test_distant_exception.<locals>.gcs��dS)Nrr)rFrrrO<sz:ProfileSimulatorTestCase.test_distant_exception.<locals>.hcs��dS)Nrr)rOrrrP>sz:ProfileSimulatorTestCase.test_distant_exception.<locals>.ics��dS)Nr)r>)rPrrrQ@sz:ProfileSimulatorTestCase.test_distant_exception.<locals>.jrrr&rGrRrSr)r%r<)rrQr@rHrTrUrVr)r?rFrOrPrrW7s(z/ProfileSimulatorTestCase.test_distant_exceptionN)rrrr9rAr]rCrWrrrrr\s
	r\cCs4t|d�r|j}n	|j}|j|jfS)N�f_code)�hasattrr^�__code__�co_firstlineno�co_name)Zfunction�coderrrr%Ts	r%c	Csy||�WnYnXdS)Nr)r?r>rrr�protect\srdcCs�|dkrt�}ntj�}tj�z.tj|j�t||�tjd�Wd|rrtj�nX|j	�dd�S)Nr���)
r�gc�	isenabled�disablerrrrd�enabler,)r;r>Zold_gcrrrr8cs

r8cCs#ddl}|jt|��dS)Nr)r:r8)r;r:rrr�show_eventstsrjcCstjttt�dS)N)rZrun_unittestrr=r\rrrr�	test_mainysrk�__main__)rfr:rZunittestZtestrZTestCaserrr-r7r=r\r%rdZ
protect_identr8rjrkrrrrr�<module>s$ #�: