403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_sys_settrace.cpython-36.pyc
3

x2_7��@s�ddlmZddlZddlZddlZddlZddlmZGdd�d�ZGdd�d�Z	dd	�Z
d
d�Zdd
�ZdJdKdLge_
dd�ZdMdNdOdPdQge_
dd�ZdRdSdTdUdVge_
dd�ZdWdXdYdZd[d\d]d^d_d`g
e_
dd�Zdadbdcdddege_
dd �Zd!d�Zdfdgdidkdmdnge_
d"d#�Zd$d%�Zdodpdqdsdudwdydzd{d|d}ge_
d'd(�Zd)d*�Zd~ge_
d+d,�Zd-d.�Zdd�d�d�ge_
d/d0�Zd�d�d�d�d�d�d�ge_
d1d2�Zd�d�d�d�d�d�d�d�d�d�d�d�d�g
e_
d4d5�Zd�d�d�d�d�d�d�d�d�d�d�d�ge_
d6d7�Zd8d9�Zd�d�d�d�d�d�d�d�d�d�g
d�d�gd:d�d�ge_
Gd;d<�d<�ZGd=d>�d>ej �Z!Gd?d@�d@ej �Z"GdAdB�dB�Z#dCdD�Z$dEdF�Z%GdGdH�dHej �Z&e'dIk�r�ej(�dS)��)�supportN)�wrapsc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�tracecontextz/Context manager that traces its enter and exit.cCs||_||_dS)N)�output�value)�selfrr�r�;/opt/alt/python36/lib64/python3.6/test/test_sys_settrace.py�__init__
sztracecontext.__init__cCs|jj|j�dS)N)r�appendr)rrrr	�	__enter__sztracecontext.__enter__cGs|jj|j�dS)N)rrr)r�exc_inforrr	�__exit__sztracecontext.__exit__N)�__name__�
__module__�__qualname__�__doc__r
rrrrrr	rsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�asynctracecontextz>Asynchronous context manager that traces its aenter and aexit.cCs||_||_dS)N)rr)rrrrrr	r
szasynctracecontext.__init__c�s|jj|j�dS)N)rrr)rrrr	�
__aenter__szasynctracecontext.__aenter__c�s|jj|j�dS)N)rrr)rr
rrr	�	__aexit__ szasynctracecontext.__aexit__N)rrrrr
rrrrrr	rsrcCsx|D]
}|VqWdS)z0Convert an iterable to an asynchronous iterator.Nr)�iterable�xrrr	�	asynciter#s
rcCs�ddl}ddl}ddl}|jj�dks*t�|jj|�s:t�|jj�}z|jj	|�|j
|�Sz|j
|j��Wd|jj	d�|j�XXdS)Nr)
�asyncioZasyncio.eventsZasyncio.coroutines�eventsZ_get_running_loop�AssertionErrorZ
coroutinesZiscoroutineZnew_event_loopZset_event_loopZrun_until_completeZshutdown_asyncgens�close)�mainrZlooprrr	�asyncio_run(s

rcCsdS)N�rrrrr	�basic;sr �callr�line�returncCsd}~d}dS)Nrr)rrrr	�
arigo_exampleKsr$��cCsd}~d}dS)Nrr)rrrr	�one_instr_lineYsr'�cCs(d}xtd�D]}|rd}qd}qWdS)Nrr%)�range)r�arrr	�no_pop_topsds
r+��cCsd}x|stqWd}dS)Nr)Zbla)�yrrrr	�
no_pop_blockswsr/cCsd}dS)Nrr)rrrr	�called�sr0cCs
t�dS)N)r0rrrr	r!�scCst�dS)N)�	Exceptionrrrr	�raises�sr2cCs6y
t�Wn&tk
r0}z
d}WYdd}~XnXdS)Nr)r2r1)�excrrrr	�
test_raise�s
r4�	exceptioncCstj|�|tj�j_dS)N)�sys�settrace�	_getframe�f_back�f_trace)�	tracefuncrrr	�_settrace_and_return�s
r<cCst|�dS)N)r<)r;rrr	�settrace_and_return�sr=cCstj|�|tj�j_t�dS)N)r6r7r8r9r:�RuntimeError)r;rrr	�_settrace_and_raise�s
r?cCs4yt|�Wn"tk
r.}zWYdd}~XnXdS)N)r?r>)r;r3rrr	�settrace_and_raise�sr@cCsd}d}||kr|d}ndS)Nr&rr)r*�brrr	�ireturn_example�s

rBcCsBtdd�}yd}x||}|d7}qWWntk
r<YnXdS)Nrr(r)r)�
IndexError)�items�irArrr	�tightloop_example�s
rF�cCs:tdd�}yd}x||}qWWntk
r4YnXdS)Nrr-r)r)rC)rDrErrr	�tighterloop_example�s
rHc	csz
dVWdXdS)NTrrrrr	�generator_functionsrIcCs$tt��}xtd�D]}|}qWdS)N�
)�anyrIr))rr.rrr	�generator_examples
rLrJc@s$eZdZdd�Zdd�Zdd�ZdS)�TracercCs
g|_dS)N)r)rrrr	r
szTracer.__init__cCs|jj|j|f�|jS)N)rr�f_lineno�trace)r�frame�event�argrrr	rO szTracer.tracecCs&dd�dD�|jj|j|f�|jS)Ncss|]
}|VqdS)Nr)�.0�orrr	�	<genexpr>$sz)Tracer.traceWithGenexp.<locals>.<genexpr>r)r)rrrNrO)rrPrQrRrrr	�traceWithGenexp#szTracer.traceWithGenexpN)rrrr
rOrVrrrr	rMsrMc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3S)4�
TraceTestCasecCs(tj�|_tj�|jtjtj��dS)N)�gc�	isenabled�using_gc�disable�
addCleanupr6r7�gettrace)rrrr	�setUp,s
zTraceTestCase.setUpcCs|jrtj�dS)N)rZrX�enable)rrrr	�tearDown1szTraceTestCase.tearDowncsN�fdd�|D�}||krJ|jddjtjdd�|D�dd�|D����dS)Ncsg|]\}}|�|f�qSrr)rS�l�e)�line_offsetrr	�
<listcomp>6sz0TraceTestCase.compare_events.<locals>.<listcomp>z"events did not match expectation:
�
cSsg|]}t|��qSr)�str)rSrrrr	rd:scSsg|]}t|��qSr)rf)rSrrrr	rd;s)�fail�join�difflibZndiff)rrcrZexpected_eventsr)rcr	�compare_events5szTraceTestCase.compare_eventscCs:t�}tj|j�|�tjd�|j|jj|j|�dS)N)rMr6r7rOrj�__code__�co_firstlinenor)r�funcr�tracerrrr	�run_and_compare=s

zTraceTestCase.run_and_comparecCs|j||j�dS)N)ror)rrmrrr	�run_testEszTraceTestCase.run_testcCs4t�}||j�tjd�|j|jj|j|j�dS)N)rMrOr6r7rjrkrlr)rrmrnrrr	�	run_test2Hs



zTraceTestCase.run_test2cCstjd�tj�dkst�dS)N)r6r7r]r)rrrr	�test_set_and_retrieve_noneOs
z(TraceTestCase.test_set_and_retrieve_nonecCs8dd�}tj|�ztj�|ks$t�Wdtjd�XdS)NcWsdS)Nr)�argsrrr	�fnTsz4TraceTestCase.test_set_and_retrieve_func.<locals>.fn)r6r7r]r)rrtrrr	�test_set_and_retrieve_funcSs

z(TraceTestCase.test_set_and_retrieve_funccCs|jt�dS)N)rpr )rrrr	�
test_01_basic]szTraceTestCase.test_01_basiccCs|jt�dS)N)rpr$)rrrr	�
test_02_arigo_szTraceTestCase.test_02_arigocCs|jt�dS)N)rpr')rrrr	�test_03_one_instraszTraceTestCase.test_03_one_instrcCs|jt�dS)N)rpr/)rrrr	�test_04_no_pop_blockscsz#TraceTestCase.test_04_no_pop_blockscCs|jt�dS)N)rpr+)rrrr	�test_05_no_pop_topsesz!TraceTestCase.test_05_no_pop_topscCs|jt�dS)N)rpr!)rrrr	�test_06_callgszTraceTestCase.test_06_callcCs|jt�dS)N)rpr4)rrrr	�
test_07_raiseiszTraceTestCase.test_07_raisecCs|jt�dS)N)rqr=)rrrr	�test_08_settrace_and_returnlsz)TraceTestCase.test_08_settrace_and_returncCs|jt�dS)N)rqr@)rrrr	�test_09_settrace_and_raisensz(TraceTestCase.test_09_settrace_and_raisecCs|jt�dS)N)rprB)rrrr	�test_10_ireturnpszTraceTestCase.test_10_ireturncCs|jt�dS)N)rprF)rrrr	�test_11_tightlooprszTraceTestCase.test_11_tightloopcCs|jt�dS)N)rprH)rrrr	�test_12_tighterlooptsz!TraceTestCase.test_12_tighterloopcCsF|jt�t�}tj|j�t�tjd�|jtjj|j	tj	�dS)N)
rprLrMr6r7rVrjrkrlr)rrnrrr	�test_13_genexpws


zTraceTestCase.test_13_genexpcCs dd�}|j|d	d
ddg�dS)
NcSsd}dS)NFrr)rrrr	�onliners�sz2TraceTestCase.test_14_onliner_if.<locals>.onlinersrr!rr"r(r#)rr!)rr")r(r")r(r#)ro)rr�rrr	�test_14_onliner_if�sz TraceTestCase.test_14_onliner_ifcCsJdd�}|j|d
ddddddg�d	d
�}|j|ddddddddg�dS)NcSsxtd�D]}q
WdS)Nr%)r))rrrr	�for_example�sz0TraceTestCase.test_15_loops.<locals>.for_examplerr!rr"r%r#cSsd}x|dkr|d8}qWdS)Nr%rrr)rrrr	�
while_example�s
z2TraceTestCase.test_15_loops.<locals>.while_exampler(r-)rr!)rr")r%r")rr")r%r")rr")rr#)rr!)r%r")r(r")r-r")r(r")r-r")r(r")r(r#)ro)rr�r�rrr	�
test_15_loops�s*zTraceTestCase.test_15_loopscCs4i}tdddd|�|j|dddd
g�dS)Nz	def f():
re�z    pass�frr!�r"r#)rr!)r�r")r�r#)�execro)r�	namespacerrr	�test_16_blank_lines�sz!TraceTestCase.test_16_blank_linescCsdd�}|j|ddg�dS)	NcSsdtj�_d}dS)Nr%)r6r8r:)�linenorrr	rm�s
z0TraceTestCase.test_17_none_f_trace.<locals>.funcrr!rr")rr!)rr")ro)rrmrrr	�test_17_none_f_trace�sz"TraceTestCase.test_17_none_f_traceN)rrrr^r`rjrorprqrrrurvrwrxryrzr{r|r}r~rr�r�r�r�r�r�r�rrrr	rW(s2

	rWc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�RaisingTraceFuncTestCasecCs|jtjtj��dS)N)r\r6r7r])rrrr	r^�szRaisingTraceFuncTestCase.setUpcCs||jkrt�n|jSdS)zXA trace function that raises an exception in response to a
        specific trace event.N)�raiseOnEvent�
ValueErrorrO)rrPrQrRrrr	rO�s
zRaisingTraceFuncTestCase.tracecCs |jdkrd}d|}ndSdS)zThe function to trace; raises an exception if that's the case
        we're testing, so that the 'exception' trace event fires.r5rrN)r�)rrr.rrr	r��s

zRaisingTraceFuncTestCase.fcCs�||_yVxPttj�d�D]<}tj|j�y|j�Wntk
rJYqX|jd�qWWnt	k
rz|jd�YnXdS)zTTests that an exception raised in response to the given event is
        handled OK.rzexception not raised!zrecursion counter not resetN)
r�r)r6�getrecursionlimitr7rOr�r�rgr>)rrQrErrr	�run_test_for_event�sz+RaisingTraceFuncTestCase.run_test_for_eventcCs|jd�dS)Nr!)r�)rrrr	�	test_call�sz"RaisingTraceFuncTestCase.test_callcCs|jd�dS)Nr")r�)rrrr	�	test_line�sz"RaisingTraceFuncTestCase.test_linecCs|jd�dS)Nr#)r�)rrrr	�test_return�sz$RaisingTraceFuncTestCase.test_returncCs|jd�dS)Nr5)r�)rrrr	�test_exception�sz'RaisingTraceFuncTestCase.test_exceptioncs^dd����fdd��tj��y
��Wn$tk
rNddl}|j�YnX|jd�dS)NcSsxtd�D]}t|�q
WdS)Nr&)r)�print)rErrr	r��sz4RaisingTraceFuncTestCase.test_trash_stack.<locals>.fcs&|dkr"|j�jjdkr"td���S)Nr"r%z
i am crashing)rNrkrlr>)rPZwhyZextra)r��grr	r��sz4RaisingTraceFuncTestCase.test_trash_stack.<locals>.grzexception not propagated)r6r7r>rXZcollectrg)rrXr)r�r�r	�test_trash_stack�s

z)RaisingTraceFuncTestCase.test_trash_stackcs^dd�}��fdd��tj�}z.tj��y
|�Wntk
rHYnXWdtj|�XdS)NcSsd}|jdS)Nr)Zno_such_attr)rrrr	r�sz<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.fcs"|dkr|\}}}�j|t��S)Nr5)ZassertIsInstancer1)rPrQrR�typer5rO)r�rrr	r�s
z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.g)r6r]r7�AttributeError)rr�Zexistingr)r�rr	�test_exception_argumentss


z1RaisingTraceFuncTestCase.test_exception_argumentsN)
rrrr^rOr�r�r�r�r�r�r�r�rrrr	r��s	r�c@s"eZdZdZd	dd�Zdd�ZdS)
�
JumpTracerz>Defines a trace function that jumps from one place to another.r"FcCs6|j|_||_||_||_|r"dn|jj|_d|_dS)NF)rk�code�jumpFrom�jumpTorQrl�	firstLine�done)rZfunctionr�r�rQ�	decoratedrrr	r
%szJumpTracer.__init__cCs�|jr
dS|jdkr4|j|jkr4|dkr4|jd|_||jkr�|jr�|j|j|jkr�|}x|dk	rx|j|jkrx|j}q\W|dk	r�y|j|j|_Wnt	k
r�|j|_YnXd|_|j
S)Nr"rT)r�r��f_coder�rNrQr�r9r��	TypeErrorrO)rrPrQrRr�rrr	rO.s"
zJumpTracer.traceN)r"F)rrrrr
rOrrrr	r�"s
r�cCsHy|jd�Wn4tk
rB}z|jdt|�k�WYdd}~XnXdS)Nr%Zinteger)rr�rf)rrbrrr	�no_jump_to_non_integersHsr�cCsTytj�j}|j|_Wn0tk
rF}zdt|�kr6�WYdd}~Xn
Xtd��dS)NrOz'Trace-function-less jump failed to fail)r6r8r9rNr�rfr)Zprevious_framerbrrr	�no_jump_without_trace_functionPs
r�c@s�eZdZdd�Zdd�Zd�dd	�Zd�d
d�Zd�dd
�Zd�dd�Zedddg�dd��Z	edddddg�dd��Z
eddddg�dd��Zeddddddddddg�dd��Zeddddg�dd ��Z
eddddddddg�d!d"��Zedddg�d#d$��Zedddddg�d%d&��Zedd'dd'g�d(d)��Zeddddged*f�d+d,��Zedd-dd-ged*f�d.d/��Zeddddg�d0d1��Zeddddg�d2d3��Zeddddg�d4d5��Zedddddddd�g�d6d7��Zedddddddd�g�d8d9��Zedddg�d:d;��Zeddddddg�d<d=��Zedddg�d>d?��Zedddddg�d@dA��ZedddddBg�dCdD��Zedddddg�dEdF��Zedddddd�g�dGdH��Z edddddd�g�dIdJ��Z!eddddddg�dKdL��Z"eddddddg�dMdN��Z#eddddddd�dg�dOdP��Z$eddddddd�dg�dQdR��Z%eddddddg�dSdT��Z&eddddddg�dUdV��Z'edBd-dddd-dWg�dXdY��Z(edddddg�dZd[��Z)edddddg�d\d]��Z*edddddBd'g�d^d_��Z+eddBdddBd`d-dag�dbdc��Z,eddddBg�ddde��Z-eddddBg�dfdg��Z.edddge/dhf�didj��Z0edd�dge/dkf�dldm��Z1edddge/dnf�dodp��Z2edddge/dnf�dqdr��Z3edddge/dnf�dsdt��Z4edddge/dnf�dudv��Z5eddge/dwf�dxdy��Z6eddge/dwf�dzd{��Z7eddddge/dwf�d|d}��Z8eddddge/dwf�d~d��Z9eddge/dwf�d�d���Z:eddddge/dwf�d�d���Z;eddge/dwf�d�d���Z<eddge/dwf�d�d���Z=eddddd�ge/dwf�d�d���Z>eddddd�ge/dwf�d�d���Z?eddge/dwf�d�d���Z@eddddge/dwf�d�d���ZAeddge/dwf�d�d���ZBedddge/dwf�d�d���ZCedddge/dwf�d�d���ZDedddddge/d�f�d�d���ZEeddge/d�f�d�d���ZFeddddge/d�f�d�d���ZGeddddd�ge/dwf�d�d���ZHeddddd�ge/dwf�d�d���ZIeddddge/dwf�d�d���ZJeddddge/dwf�d�d���ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOedddgd�e/d�fd��d�d���ZPedddgd�e/d�fd��d�d���ZQedddgd�e/d�fd��d�d���ZRedddgd�e/d�fd��d�d���ZSdS)��JumpTestCasecCs |jtjtj��tjd�dS)N)r\r6r7r])rrrr	r^_szJumpTestCase.setUpcCs.||kr*|jdt|�ddt|��dS)NzOutputs don't match:
z
Expected: rez
Received: zOutputs don't match:
Expected: )rg�repr)r�expectedZreceivedrrr	�compare_jump_outputcsz JumpTestCase.compare_jump_outputNr"Fc

Csjt|||||�}tj|j�g}	|dkr2||	�n|j|��||	�WdQRXtjd�|j||	�dS)N)r�r6r7rO�assertRaisesRegexr�)
rrmr�r�r��errorrQr�rnrrrr	rpis

zJumpTestCase.run_testc

Csrt|||||�}tj|j�g}	|dkr6t||	��n"|j|��t||	��WdQRXtjd�|j||	�dS)N)r�r6r7rOrr�r�)
rrmr�r�r�r�rQr�rnrrrr	�run_async_testvs
zJumpTestCase.run_async_testcs�����fdd�}|S)zqDecorator that creates a test that makes a jump
        from one place to another in the following code.
        cs"t��������fdd��}|S)Nc	s|j������dd�dS)NT)r�rQr�)rp)r)r�rQr�rmr�r�rr	�test�sz7JumpTestCase.jump_test.<locals>.decorator.<locals>.test)r)rmr�)r�rQr�r�r�)rmr	�	decorator�sz)JumpTestCase.jump_test.<locals>.decoratorr)r�r�r�r�rQr�r)r�rQr�r�r�r	�	jump_test�szJumpTestCase.jump_testcs�����fdd�}|S)z~Decorator that creates a test that makes a jump
        from one place to another in the following asynchronous code.
        cs"t��������fdd��}|S)Nc	s|j������dd�dS)NT)r�rQr�)r�)r)r�rQr�rmr�r�rr	r��sz=JumpTestCase.async_jump_test.<locals>.decorator.<locals>.test)r)rmr�)r�rQr�r�r�)rmr	r��sz/JumpTestCase.async_jump_test.<locals>.decoratorr)r�r�r�r�rQr�r)r�rQr�r�r�r	�async_jump_test�szJumpTestCase.async_jump_testrr(cCs"|jd�|jd�|jd�dS)Nrr%r()r)rrrr	�test_jump_simple_forwards�s

z&JumpTestCase.test_jump_simple_forwardsr%cCs|jd�|jd�dS)Nrr%)r)rrrr	�test_jump_simple_backwards�s
z'JumpTestCase.test_jump_simple_backwardsr&cCs>x.dD]&}|jd�xdD]}|jd�qWqW|jd�dS)Nrr%r(r-r&)rr%)r()r)rrE�jrrr	�test_jump_out_of_block_forwards�s



z,JumpTestCase.test_jump_out_of_block_forwardsr,rGcCsR|jd�x8dD]0}|jd�xdD]}|jd�q$W|jd�qW|jd�dS)	Nrr(r%r&r,rG)r)r%)r)rrEr�rrr	� test_jump_out_of_block_backwards�s



z-JumpTestCase.test_jump_out_of_block_backwardsr-c
�shxbdD]Z}xJtddg�2dHy3dH}Wn
tk
sJX|jd�|jd�qYW|jd�qWdS)Nrr%r(r-r&)r)r�StopAsyncIterationr)rrErrr	�)test_jump_out_of_async_for_block_forwards�s

*
z6JumpTestCase.test_jump_out_of_async_for_block_forwardsc
�spxjdD]b}|jd�xHtdg�2dHy3dH}Wn
tk
sRX|jd�|jd�q$YW|jd�qWdS)Nrr%r-r&r,)r)rrr�)rrErrr	�*test_jump_out_of_async_for_block_backwards�s

(
z7JumpTestCase.test_jump_out_of_async_for_block_backwardscCs|jd�|jd�dS)Nrr()r)rrrr	�test_jump_to_codeless_line�s
z'JumpTestCase.test_jump_to_codeless_linecCs"|jd�|jd�|jd�dS)Nrr%r()r)rrrr	�test_jump_to_same_line�s

z#JumpTestCase.test_jump_to_same_line�	cCsFz|jd�Wd|jd�z|jd�Wd|jd�X|jd�XdS)Nr%r-r,�r�)r)rrrr	�test_jump_in_nested_finally�s
z(JumpTestCase.test_jump_in_nested_finally�cCs<z|jd�dddS|jd�|jd�X|jd�dS)Nr%rrr,rGr�)r)rrrr	�test_jump_in_nested_finally_2�s

z*JumpTestCase.test_jump_in_nested_finally_2�cCsXz|jd�dddS|jd�z|jd�Wd|jd�X|jd�X|jd�dS)	Nr%rrr,r�rJr��)r)rrrr	�test_jump_in_nested_finally_3�s

z*JumpTestCase.test_jump_in_nested_finally_3cCs(|jd�x|jd�qW|jd�dS)Nrr(r-)r)rrrr	�test_jump_infinite_while_loop�s
z*JumpTestCase.test_jump_infinite_while_loopc	Cs.t|d��|jd�WdQRX|jd�dS)Nrr%r()rr)rrrr	�$test_jump_forwards_out_of_with_blocksz1JumpTestCase.test_jump_forwards_out_of_with_blockc
�s<t|d�4IdH�|jd�WdQIdHRX|jd�dS)Nrr%r()rr)rrrr	�*test_jump_forwards_out_of_async_with_blocksz7JumpTestCase.test_jump_forwards_out_of_async_with_blockc	Cs.|jd�t|d��|jd�WdQRXdS)Nrr%r()rr)rrrr	�%test_jump_backwards_out_of_with_blocks
z2JumpTestCase.test_jump_backwards_out_of_with_blockc
�s<|jd�t|d�4IdH�|jd�WdQIdHRXdS)Nrr%r()rr)rrrr	�+test_jump_backwards_out_of_async_with_blocks
z8JumpTestCase.test_jump_backwards_out_of_async_with_blockcCs*z|jd�Wd|jd�X|jd�dS)Nr%r-r&)r)rrrr	�+test_jump_forwards_out_of_try_finally_blocksz8JumpTestCase.test_jump_forwards_out_of_try_finally_blockcCs*|jd�z|jd�Wd|jd�XdS)Nrr(r&)r)rrrr	�,test_jump_backwards_out_of_try_finally_block%s
z9JumpTestCase.test_jump_backwards_out_of_try_finally_blockc	Cs6y|jd�Wn|jd��YnX|jd�dS)Nr%r-r,)r)rrrr	�*test_jump_forwards_out_of_try_except_block-s
z7JumpTestCase.test_jump_forwards_out_of_try_except_blockc	Cs6|jd�y|jd�Wn|jd��YnXdS)Nrr(r&)r)rrrr	�+test_jump_backwards_out_of_try_except_block6s

z8JumpTestCase.test_jump_backwards_out_of_try_except_blockr�cCs`yddWnDtk
r4|jd�|jd�Yntk
rP|jd�YnX|jd�dS)Nrrr-r&rGr�)�ZeroDivisionErrorr�FloatingPointError)rrrr	�test_jump_between_except_blocks?s
z,JumpTestCase.test_jump_between_except_blocksc	CsFyddWn*|jd�|jd�|jd�YnX|jd�dS)Nrrr-r&r,rG)r)rrrr	�test_jump_within_except_blockJs

z*JumpTestCase.test_jump_within_except_blockcCsN|jd�t|d��|jd�WdQRXt|d��|jd�WdQRXdS)Nrr%r(r-r&)rr)rrrr	�test_jump_across_withTs

z"JumpTestCase.test_jump_across_withc�sj|jd�t|d�4IdH�|jd�WdQIdHRXt|d�4IdH�|jd�WdQIdHRXdS)Nrr%r(r-r&)rr)rrrr	�test_jump_across_async_with\s

z(JumpTestCase.test_jump_across_async_withc
CsP|jd�x6dD].}t|d��|jd�WdQRX|jd�qW|jd�dS)Nrr(r-r&r,)r)rr)rrErrr	�,test_jump_out_of_with_block_within_for_blockds

z9JumpTestCase.test_jump_out_of_with_block_within_for_blockc�s^|jd�xDdD]<}t|d�4IdH�|jd�WdQIdHRX|jd�qW|jd�dS)Nrr(r-r&r,)r)rr)rrErrr	�2test_jump_out_of_async_with_block_within_for_blockms

z?JumpTestCase.test_jump_out_of_async_with_block_within_for_blockcCsX|jd�t|d��0t|d��|jd�WdQRX|jd�WdQRX|jd�dS)Nrr%r(r-r&r,)rr)rrrr	�-test_jump_out_of_with_block_within_with_blockvs
z:JumpTestCase.test_jump_out_of_with_block_within_with_blockc�sf|jd�t|d��>t|d�4IdH�|jd�WdQIdHRX|jd�WdQRX|jd�dS)Nrr%r(r-r&r,)rrr)rrrr	�3test_jump_out_of_async_with_block_within_with_blocks
z@JumpTestCase.test_jump_out_of_async_with_block_within_with_blockcCsJz|jd�Wdt|d��|jd�WdQRX|jd�X|jd�dS)Nr%r-r&r,rG)rr)rrrr	�0test_jump_out_of_with_block_within_finally_block�sz=JumpTestCase.test_jump_out_of_with_block_within_finally_blockc�sXz|jd�Wdt|d�4IdH�|jd�WdQIdHRX|jd�X|jd�dS)Nr%r-r&r,rG)rr)rrrr	�6test_jump_out_of_async_with_block_within_finally_block�szCJumpTestCase.test_jump_out_of_async_with_block_within_finally_blockr�c
Cs||jd�xbd	D]Z}|jd�x@d
D]8}|jd�zxdD]}|jd�q:WWd|jd�Xq$W|jd�qW|jd�dS)Nrr(r%r&r�rJr�r�)r)rr%)rr%)r)rrEr��krrr	�&test_jump_out_of_complex_nested_blocks�s





z3JumpTestCase.test_jump_out_of_complex_nested_blocksc	Cs8|jd�t|d��}|jd�WdQRX|jd�dS)Nrr%r-r&)rr)rrrrr	� test_jump_out_of_with_assignment�s


z-JumpTestCase.test_jump_out_of_with_assignmentc
�sF|jd�t|d�4IdH�}|jd�WdQIdHRX|jd�dS)Nrr%r-r&)rr)rrrrr	�&test_jump_out_of_async_with_assignment�s

z3JumpTestCase.test_jump_out_of_async_with_assignmentcCsF|jd�z |jd�|sdS|jd�Wd|jd�X|jd�dS)Nrr(r,r�r�)r)rrrr	�*test_jump_over_return_in_try_finally_block�s

z7JumpTestCase.test_jump_over_return_in_try_finally_blockrJ�
cCs`|jd�xF|jd�z|jd�|s(P|jd�Wd|jd�X|jd�PqW|jd�dS)Nrr(r&r�rJr�r�)r)rrrr	�)test_jump_over_break_in_try_finally_block�s



z6JumpTestCase.test_jump_over_break_in_try_finally_blockcCsJ|jd�|s(x,dD]}|jd�qWn|jd�|jd�|jd�dS)Nrr(r-r,rGr�)r()r)rrErrr	�$test_jump_over_for_block_before_else�s



z1JumpTestCase.test_jump_over_for_block_before_elsec�sr|jd�|sPxTtdg�2dHy3dH}Wn
tk
sBX|jd�qYWn|jd�|jd�|jd�dS)Nrr(r-r,rGr�)rrr�)rrErrr	�*test_jump_over_async_for_block_before_else�s
(

z7JumpTestCase.test_jump_over_async_for_block_before_else�aftercCs|jd�|jd�dS)Nrr%)r)rrrr	�test_no_jump_too_far_forwards�s
z*JumpTestCase.test_no_jump_too_far_forwardsZbeforecCs|jd�|jd�dS)Nrr%)r)rrrr	�test_no_jump_too_far_backwards�s
z+JumpTestCase.test_no_jump_too_far_backwards�exceptc	Cs,y|jd�Wn|jd��YnXdS)Nr%r-)r)rrrr	�test_no_jump_to_except_1�s

z%JumpTestCase.test_no_jump_to_except_1cCs4y|jd�Wn tk
r.|jd��YnXdS)Nr%r-)rr�)rrrr	�test_no_jump_to_except_2s

z%JumpTestCase.test_no_jump_to_except_2cCsDy|jd�Wn0tk
r>}z|jd�|�WYdd}~XnXdS)Nr%r-)rr�)rrbrrr	�test_no_jump_to_except_3
s

z%JumpTestCase.test_no_jump_to_except_3cCsHy|jd�Wn4ttfk
rB}z|jd�|�WYdd}~XnXdS)Nr%r-)rr�r>)rrbrrr	�test_no_jump_to_except_4s

z%JumpTestCase.test_no_jump_to_except_4ZintocCs&|jd�xdD]}|jd�qWdS)Nrr%r()rr%)r)rrErrr	�$test_no_jump_forwards_into_for_blocks

z1JumpTestCase.test_no_jump_forwards_into_for_blockc�sP|jd�x@tddg�2dHy3dH}Wn
tk
s@X|jd�qYWdS)Nrr%r()rrr�)rrErrr	�*test_no_jump_forwards_into_async_for_block s
*z7JumpTestCase.test_no_jump_forwards_into_async_for_blockcCs&xdD]}|jd�qW|jd�dS)Nrr%r()rr%)r)rrErrr	�%test_no_jump_backwards_into_for_block&s
z2JumpTestCase.test_no_jump_backwards_into_for_blockc�sPx@tddg�2dHy3dH}Wn
tk
s6X|jd�qYW|jd�dS)Nrr%r()rr�r)rrErrr	�+test_no_jump_backwards_into_async_for_block,s*z8JumpTestCase.test_no_jump_backwards_into_async_for_blockcCs2d}|jd�x|dkr,|jd�|d7}qWdS)Nrr%r-)r)rrErrr	�&test_no_jump_forwards_into_while_block2s



z3JumpTestCase.test_no_jump_forwards_into_while_blockcCs2d}x|dkr"|jd�|d7}qW|jd�dS)Nrr%r(r&)r)rrErrr	�'test_no_jump_backwards_into_while_block:s


z4JumpTestCase.test_no_jump_backwards_into_while_blockc	Cs.|jd�t|d��|jd�WdQRXdS)Nrr%r()rr)rrrr	�%test_no_jump_forwards_into_with_blockBs
z2JumpTestCase.test_no_jump_forwards_into_with_blockc
�s<|jd�t|d�4IdH�|jd�WdQIdHRXdS)Nrr%r()rr)rrrr	�+test_no_jump_forwards_into_async_with_blockHs
z8JumpTestCase.test_no_jump_forwards_into_async_with_blockc	Cs.t|d��|jd�WdQRX|jd�dS)Nrr%r()rr)rrrr	�&test_no_jump_backwards_into_with_blockNsz3JumpTestCase.test_no_jump_backwards_into_with_blockc
�s<t|d�4IdH�|jd�WdQIdHRX|jd�dS)Nrr%r()rr)rrrr	�,test_no_jump_backwards_into_async_with_blockTsz9JumpTestCase.test_no_jump_backwards_into_async_with_blockcCs*|jd�z|jd�Wd|jd�XdS)Nrr(r&)r)rrrr	�,test_no_jump_forwards_into_try_finally_blockZs
z9JumpTestCase.test_no_jump_forwards_into_try_finally_blockcCs*z|jd�Wd|jd�X|jd�dS)Nr%r-r&)r)rrrr	�-test_no_jump_backwards_into_try_finally_blockbsz:JumpTestCase.test_no_jump_backwards_into_try_finally_blockc	Cs6|jd�y|jd�Wn|jd��YnXdS)Nrr(r&)r)rrrr	�+test_no_jump_forwards_into_try_except_blockjs

z8JumpTestCase.test_no_jump_forwards_into_try_except_blockc	Cs6y|jd�Wn|jd��YnX|jd�dS)Nr%r-r,)r)rrrr	�,test_no_jump_backwards_into_try_except_blockss
z9JumpTestCase.test_no_jump_backwards_into_try_except_blockcCsnyddWnRtk
r4|jd�|jd�Yn,tk
r^}z|jd�WYdd}~XnX|jd�dS)Nrrr-r&rGr�)r�rr�)rrbrrr	�$test_no_jump_between_except_blocks_2}s
z1JumpTestCase.test_no_jump_between_except_blocks_2�finallycCs>z|jd�|jd�Wd|jd�|jd�X|jd�dS)Nr%r(r&r,rG)r)rrrr	�test_no_jump_into_finally_block�s

z,JumpTestCase.test_no_jump_into_finally_blockcCs*|jd�z|jd�Wd|jd�XdS)Nrr(r&)r)rrrr	�!test_no_jump_into_finally_block_2�s
z.JumpTestCase.test_no_jump_into_finally_block_2cCs*|jd�z|jd�Wd|jd�XdS)Nrr(r&)r)rrrr	�!test_no_jump_out_of_finally_block�s
z.JumpTestCase.test_no_jump_out_of_finally_blockcCsN|jd�t|d��|jd�WdQRXt|d��|jd�WdQRXdS)Nrr%r(r-r&)rr)rrrr	� test_no_jump_between_with_blocks�s

z-JumpTestCase.test_no_jump_between_with_blocksc�sj|jd�t|d�4IdH�|jd�WdQIdHRXt|d�4IdH�|jd�WdQIdHRXdS)Nrr%r(r-r&)rr)rrrr	�&test_no_jump_between_async_with_blocks�s

z3JumpTestCase.test_no_jump_between_async_with_blockscCsJ|jd�|s(x,dD]}|jd�qWn|jd�|jd�|jd�dS)Nrr(r-r,rGr�)r()r)rrErrr	�'test_no_jump_into_for_block_before_else�s



z4JumpTestCase.test_no_jump_into_for_block_before_elsec�sr|jd�|sPxTtdg�2dHy3dH}Wn
tk
sBX|jd�qYWn|jd�|jd�|jd�dS)Nrr(r-r,rGr�)rrr�)rrErrr	�-test_no_jump_into_async_for_block_before_else�s
(

z:JumpTestCase.test_no_jump_into_async_for_block_before_elsecCs|jtdddg�dS)Nr%ZSpamT)rpr�)rrrr	�test_no_jump_to_non_integers�sz)JumpTestCase.test_no_jump_to_non_integerscCs
t�dS)N)r�)rrrr	�#test_no_jump_without_trace_function�sz0JumpTestCase.test_no_jump_without_trace_functioncCs6i}tdddf|�|d}|j|dddg�dS)Na�def f(output):        # line 0
            x = 0                     # line 1
            y = 1                     # line 2
            '''                       # line 3
            %s                        # lines 4-1004
            '''                       # line 1005
            x += 1                    # line 1006
            output.append(x)          # line 1007
            returnrei�r�r%i�r)r�rp)r�dr�rrr	�test_large_function�s
z JumpTestCase.test_large_functioncsptddd��G�fdd�d�}t|dd�}tj|j�dgi}t�|�tjd�|jdd	dd	d
g|d�dS)Nzd
# Comments don't count.
output.append(2)  # firstlineno is here.
output.append(3)
output.append(4)
z
<fake module>r�cseZdZ�ZdS)z<JumpTestCase.test_jump_to_firstlineno.<locals>.fake_functionN)rrrrkr)r�rr	�
fake_function�srr%rrr(r-)�compiler�r6r7rOr�r�)rrrnr�r)r�r	�test_jump_to_firstlineno�s


z%JumpTestCase.test_jump_to_firstlinenor!z5can't jump from the 'call' trace event of a new frame)rQr�cs*�jd��fdd�}|��jd�dS)Nrcs�jd�dS)Nr()rr)rrr	�nested�sz3JumpTestCase.test_no_jump_from_call.<locals>.nestedr&)r)rrr)rr	�test_no_jump_from_call�s
z#JumpTestCase.test_no_jump_from_callr#z'can only jump from a 'line' trace eventcCs|jd�dS)Nr)r)rrrr	�test_no_jump_from_return_event�s
z+JumpTestCase.test_no_jump_from_return_eventr5cCs|jd�dddS)Nrr)r)rrrr	�!test_no_jump_from_exception_events
z.JumpTestCase.test_no_jump_from_exception_eventz!can't jump from a yield statementcs$�fdd�}t|���jd�dS)Nc3s�jd�dVdS)Nr%r()rr)rrr	�gen	s
z1JumpTestCase.test_no_jump_from_yield.<locals>.genr&)�nextr)rrr)rr	�test_no_jump_from_yields
z$JumpTestCase.test_no_jump_from_yield)Nr"F)Nr"F)Nr")Nr"���r���rrrr���rrr)Trrrr^r�rpr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrr
rr
rrrrrr	r�^s�



$
 	  		
		 	 	

 
  	
 
   	r��__main__)rr!)rr")rr#)rr!)rr")r%r")r&r")r&r#)rr!)rr")r%r")r(r")r(r#)rr!)rr")r%r")r(r")r,r")r%r")r(r")r-r")r%r")r%r#)rr!)rr")r%r")r-r")r-r#)rr!)rr"���)rr!r)rr"r)rr#)rr#)rr!)rr")r%r"r)rr!r)rr"r)rr5r)rr#)r%r5)r(r")r-r")r-r#)rr#)r%r5)r(r")r-r")r-r#)rr!)rr")r%r")r(r")r-r")r,r")r,r#)rr!)rr")r%r")r(r")r-r")r&r")r&r")r&r")r&r")r&r5)r,r")rGr")rGr#)rr!)rr")r%r")r(r")r-r")r-r")r-r")r-r")r-r5)r&r")r,r")r,r#)rr!)r%r"���)rr!���)rr"r)rr"r)rr#r)rr!r)rr5r)rr"r)rr#)r&r")r,r")r&r")r&r#))r�rZunittestr6rirX�	functoolsrrrrrr rr$r'r+r/r0r!r2r4r<r=r?r@rBrFrHrIrLrMZTestCaserWr�r�r�r�r�rrrrrr	�<module>s�
	"`&7


Youez - 2016 - github.com/yon3zu
LinuXploit