HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_decorators.cpython-310.opt-1.pyc
o

�i�9�@s�ddlmZddlZddlmZdd�ZGdd�de�ZGdd	�d	e�Z	dd
d�Z
dd
�Zdd�ZGdd�dej
�ZGdd�dej
�ZedkrMe��dSdS)�)�supportN)�
MethodTypec��fdd�}|S)Ncs|j���|S�N)�__dict__�update��func��kwds��1/usr/local/lib/python3.10/test/test_decorators.py�decorateszfuncattrs.<locals>.decorater)rrrr
r
�	funcattrssrc@�eZdZedd��ZdS)�MiscDecoratorscr)Ncs�|jd<|S)N�author)rr��namerr
rs
z'MiscDecorators.author.<locals>.decorater)rrrrr
rszMiscDecorators.authorN)�__name__�
__module__�__qualname__�staticmethodrrrrr
r�rc@seZdZdd�ZdS)�DbcheckErrorcCst�|d||||f�dS)Nz+dbcheck %r failed (func=%s args=%s kwds=%s))�	Exception�__init__)�self�exprstrr	�argsrrrr
rs

�zDbcheckError.__init__N)rrrrrrrr
rsrcs���fdd�}|S)z+Decorator to implement debugging assertionscs*t�d�jd�������fdd�}|S)Nz
dbcheck-%s�evalcs(t����s
t��||���|i|��Sr)r r�rr)�exprrr	�globals�localsrr
�check sz(dbcheck.<locals>.decorate.<locals>.check)�compiler)r	r%�rr#r$)r"r	r
rszdbcheck.<locals>.decorater)rr#r$rrr'r
�dbchecksr(cr)z&Decorator to count calls to a functioncs(�j�d��<���fdd�}�|_|S)Nrcs��d7<�|i|��S)N�rr!)�countsr	�	func_namerr
�call.sz*countcalls.<locals>.decorate.<locals>.call�r�r	r,�r*)r	r+r
r+s
zcountcalls.<locals>.decorater)r*rrr/r
�
countcalls)sr0csi���fdd�}�j|_|S)NcsJz�|WSty�|�}|�|<|YSty$�|�YSwr)�KeyError�	TypeError)r�res�r	Zsavedrr
r,9s
�zmemoize.<locals>.callr-r.rr4r
�memoize7s
r5c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �TestDecoratorscCs6Gdd�dt�}|�|��d�|�|���d�dS)Nc@r)z%TestDecorators.test_single.<locals>.CcS�dS�N�*rrrrr
�fooL�z)TestDecorators.test_single.<locals>.C.fooN)rrrrr:rrrr
�CKrr<r9)�object�assertEqualr:�rr<rrr
�test_singleJszTestDecorators.test_singlecCshdd�}||�}|�|j|�|�|j|�dD]}|�t||�t||��q|�t|�|�|��|S)NcS�|Srr��xrrr
r	Rr;z0TestDecorators.check_wrapper_attrs.<locals>.func)rrr�__doc__�__annotations__)�assertIs�__func__�__wrapped__�getattrr>�repr�format)rZmethod_wrapperZ
format_strr	�wrapper�attrrrr
�check_wrapper_attrsQs�z"TestDecorators.check_wrapper_attrscCs |�td�}|�|d�d�dS)Nz<staticmethod({!r})>r))rNrr>�rrLrrr
�test_staticmethodasz TestDecorators.test_staticmethodcCs|�td�}|�t|d�dS)Nz<classmethod({!r})>r))rN�classmethod�assertRaisesr2rOrrr
�test_classmethodgszTestDecorators.test_classmethodcCs8t�}|�d�dd��}|�|�d�|�|jd�dS)NZCleesecSr7r8rrrrr
r:nr;z'TestDecorators.test_dotted.<locals>.foor9)rrr>)rZ
decoratorsr:rrr
�test_dottedls

zTestDecorators.test_dottedcCs�dd�}d}tddd�}||i|��dd��}|�|�d	�|�|j||f�|d
ddd
d�dd��}|�|�d�|�|jdtdd
d�f�|dd�dd��}|�|jdif�dS)Ncs��fdd�}|S)Ncst|d��f�|S)N�dbval)�setattrrr!rr
rxsz@TestDecorators.test_argforms.<locals>.noteargs.<locals>.decorater)rrrrr!r
�noteargswsz.TestDecorators.test_argforms.<locals>.noteargs)ZNow�isZthe�timer)�)ZoneZtwocSr7r8rrrrr
�f1r;z(TestDecorators.test_argforms.<locals>.f1r9�terry�gilliamZidleZcleese)ZericZjohncSr7)N�Trrrrr
�f2�r;z(TestDecorators.test_argforms.<locals>.f2r^)r\r]cSsdSrrrrrr
�f3�r;z(TestDecorators.test_argforms.<locals>.f3)r)rZ)�dictr>rU)rrWrrr[r_r`rrr
�
test_argformsss 



�
zTestDecorators.test_argformscCs6td�dd��}|�|dd�d�|�t|dd�dS)Nzargs[1] is not NonecSs||Srr)�a�brrr
�f�sz&TestDecorators.test_dbcheck.<locals>.fr)rZ�)r(r>rRr)rrerrr
�test_dbcheck�s
zTestDecorators.test_dbcheckcCs�i}tt|�dd���}|�|jd�|�|tdd��|�|d�d�|�|dd�|�|d�d�|�|dd�|�|d	�d
�|�|dd�|�|dg�ddg�|�|dd	�|�|dg�ddg�|�|dd�dS)NcSs|dS)NrZrrBrrr
�double�sz+TestDecorators.test_memoize.<locals>.doublerhr)rhrZ�r)rf��
)r5r0r>rra)rr*rhrrr
�test_memoize�s zTestDecorators.test_memoizec	CsdD]'}t|dd�|�t��td|�d�dd�Wd�n1s$wYqdD]%}t|dd�|�t��td|�d��Wd�n1sLwYq,dd	�}td|d
�}dtfdtfd
tfdtffD]\}}d|}t|dd�}|�|t	||�qjdS)N)zx,zx, yzx = y�passz
import sys�test�exec�@�
def f(): pass)z1.+2jz
[1, 2][-1]z(1, 2)�Truez...�Noner cSst�r)�NotImplementedErrorrrrr
�unimp�r;z)TestDecorators.test_errors.<locals>.unimp)�nullvalruZundefrvznullval.attrruz$@%s
def f(): pass
assert f() is None)
r&rR�SyntaxErrorr2rora�	NameError�AttributeErrorrtr )rZstmtr"ru�context�excZcodestr�coderrr
�test_errors�s.������zTestDecorators.test_errorscCs"dD]}td|�d�dd�qdS)N)z(x,)z(x, y)zx := yz(x := y)zx @yz(x @ y)zx[0]zw[x].y.zzw + x - (y + z)z	x(y)()(z)z[w, x, y][z]zx.yrprqrnro)r&)rr"rrr
�test_expressions�s�zTestDecorators.test_expressionscCsVGdd�dt�}|�|���d�|�|jjd�|�|jjd�|�|jjd�dS)Nc@s*eZdZeddd�edd�dd���ZdS)	z%TestDecorators.test_double.<locals>.Cr)�haha)�abc�xyzr9)�boohcSr7r8r)rrrr
r:��z)TestDecorators.test_double.<locals>.C.fooN)rrrrr:rrrr
r<�s
r<r9r)r)r=r>r:r�r�r�r?rrr
�test_double�s
zTestDecorators.test_doublecCs4dd�}|d�|d�dd���}|�|�dd�dS)Ncr)z�Decorator factory that returns a decorator that replaces the
            passed-in function with one that returns the value of 'num'cs�fdd�S)Ncs�Srrr��numrr
�<lambda>��zJTestDecorators.test_order.<locals>.callnum.<locals>.deco.<locals>.<lambda>rrr�rr
�deco�sz8TestDecorators.test_order.<locals>.callnum.<locals>.decor)r�r�rr�r
�callnum�sz*TestDecorators.test_order.<locals>.callnumrZr)cSr7r8rrrrr
r:�r�z&TestDecorators.test_order.<locals>.fooz,Application order of decorators is incorrect)r>)rr�r:rrr
�
test_order�s
�zTestDecorators.test_ordercs�g��fdd��G��fdd�dt�}t|gd��\}}}gd�}g�|�|j�|�|j�|�|j�dd����}|�|�d	�|��|�g�d
d�}|�|j�|�|j�|�|j�|���}|�|�d	�|��|�dS)Ncs ��d����fdd�}|S)NZmakedeccs��d��|S)NZcalldec��appendr)�actions�tagrr
r��zHTestDecorators.test_eval_order.<locals>.make_decorator.<locals>.decorater�)r�r)r�)r�r
�make_decorator�sz6TestDecorators.test_eval_order.<locals>.make_decoratorcs"eZdZdd�Z��fdd�ZdS)z8TestDecorators.test_eval_order.<locals>.NameLookupTracercS�
||_dSr)�index)rr�rrr
r�
zATestDecorators.test_eval_order.<locals>.NameLookupTracer.__init__csD|dkr
d�}}n|dkrdt|j�}}��d||jf�|S)Nr�Zevalname�argZevalargsz%s%d)�strr�r�)rZfname�opnamer3�r�r�rr
�__getattr__szDTestDecorators.test_eval_order.<locals>.NameLookupTracer.__getattr__N)rrrrr�rr�rr
�NameLookupTracersr�)r)rZrf)Z	evalname1Z	evalargs1Zmakedec1Z	evalname2Z	evalargs2Zmakedec2Z	evalname3Z	evalargs3Zmakedec3Zcalldec3Zcalldec2Zcalldec1cSr7r8rrrrr
r:�z+TestDecorators.test_eval_order.<locals>.foor9cSr7r8rrrrr
�bar"r�z+TestDecorators.test_eval_order.<locals>.bar)r=�mapr�r�r>)rr��c1�c2Zc3Zexpected_actionsr:r�rr�r
�test_eval_order�s"


(zTestDecorators.test_eval_ordercs�Gdd�d��G�fdd�d���fdd��G�fdd�d�}|�|��d	�|�|��d
�|�|���d	�|�|���d
�dS)Nc@seZdZdd�Zdd�ZdS)zOTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.BoundWrappercSr�r�rH�r�wrappedrrr
r)r�zXTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.BoundWrapper.__init__c_s|j|i|��Srr�)rr�kwargsrrr
�__call__,szXTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.BoundWrapper.__call__N)rrrrr�rrrr
�BoundWrapper(sr�cs eZdZdd�Z�fdd�ZdS)zJTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.WrappercSr�rr�r�rrr
r0r�zSTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.Wrapper.__init__cs|j�||�}�|�Sr)rH�__get__)r�instance�ownerZbound_function�r�rr
r�3szRTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.Wrapper.__get__N)rrrrr�rr�rr
�Wrapper/sr�cs�|�Srr)r�)r�rr
�	decorator7szLTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.decoratorcs,eZdZ�edd���Ze�dd���ZdS)zHTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.ClasscSr7)N�spamr��clsrrr
�inner;szNTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.Class.innercSr7)N�eggsrr�rrr
�outerAszNTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.Class.outerN)rrrrQr�r�r)r�rr
�Class:sr�r�r�)r>r�r�)rr�r)r�r�r�r
�*test_wrapped_descriptor_inside_classmethod'sz9TestDecorators.test_wrapped_descriptor_inside_classmethodcs�Gdd�d��Gdd�d����fD]܉G���fdd�d�}|�|��|�|�|��|�|�|��|�|�|��|�|�|��|�|�|��|�|�}|�|��|�|�|��|�|�|��|�|�|��|�|�|��|�|�|��|�dd�}|��|��|��|�|��|��||��|�|��|��||��|�|��|��|��t|��|�t	|��|��|�|�t	|��||��|�|�t	|��||��|�|�t	|��|��t|��qdS)	Nc@�&eZdZdd�Zdd�Zddd�ZdS)	zRTestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.MyClassMethod1cSr�rr�rr	rrr
rOr�z[TestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.MyClassMethod1.__init__cSs&t|jd�r|j�||��S|�|�S)Nr�)�hasattrr	r��rr�rrr
r�Rs
z[TestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.MyClassMethod1.__call__NcS�|durt|�}t||�Sr��typer�rr�r�rrr
r�W�
zZTestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.MyClassMethod1.__get__r�rrrrr�r�rrrr
�MyClassMethod1Nsr�c@r�)	zRTestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.MyClassMethod2cSst|t�r|j}||_dSr)�
isinstancerQrGr	r�rrr
r]s

z[TestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.MyClassMethod2.__init__cSs
|�|�Srrr�rrr
r�br�z[TestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.MyClassMethod2.__call__NcSr�rr�r�rrr
r�er�zZTestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.MyClassMethod2.__get__rr�rrrr
�MyClassMethod2\sr�csheZdZ�dd��Ze�dd���Z�edd���Zeedd���Z��d	d
���Z��dd���Z	d
S)zETestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.AcSrArrr�rrr
r[lr�zHTestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.A.f1cSrArrr�rrr
r_pr�zHTestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.A.f2cSrArrr�rrr
r`ur�zHTestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.A.f3cSrArrr�rrr
�f4zr�zHTestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.A.f4cSrArrr�rrr
�f5r�zHTestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.A.f5cSrArrr�rrr
�f6�r�zHTestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.A.f6N)
rrrr[rQr_r`r�r�r�r�r�r�Z
myclassmethodrr
�Aks$
r�cSrArrr�rrr
re�r;zETestDecorators.test_wrapped_classmethod_inside_classmethod.<locals>.f)
rFr[r_r`r�r�r�r�r�rQ)rr�rcrerr�r
�+test_wrapped_classmethod_inside_classmethodMs6�z:TestDecorators.test_wrapped_classmethod_inside_classmethodN)rrrr@rNrPrSrTrbrgrlr}r~r�r�r�r�r�rrrr
r6Hs 
=&r6c@s$eZdZdd�Zdd�Zdd�ZdS)�TestClassDecoratorscCs.dd�}|Gdd�dt��}|�|jd�dS)NcS�
d|_|S)N�Hello��extrarBrrr
�plain��z.TestClassDecorators.test_simple.<locals>.plainc@�eZdZdS)z*TestClassDecorators.test_simple.<locals>.CN�rrrrrrr
r<�sr<r��r=r>r�)rr�r<rrr
�test_simple�szTestClassDecorators.test_simplecC�:dd�}dd�}||Gdd�dt���}|�|jd�dS)NcSr�)Nrkr�rBrrr
�ten�r�z,TestClassDecorators.test_double.<locals>.tencSs|jd7_|S)N�r�rBrrr
�add_five�r�z1TestClassDecorators.test_double.<locals>.add_fivec@r�)z*TestClassDecorators.test_double.<locals>.CNr�rrrr
r<��r<�r�)rr�r�r<rrr
r��szTestClassDecorators.test_doublecCr�)NcSr�)N�firstr�rBrrr
�
applied_first�r�z5TestClassDecorators.test_order.<locals>.applied_firstcSr�)N�secondr�rBrrr
�applied_second�r�z6TestClassDecorators.test_order.<locals>.applied_secondc@r�)z)TestClassDecorators.test_order.<locals>.CNr�rrrr
r<�r�r<r�r�)rr�r�r<rrr
r��szTestClassDecorators.test_orderN)rrrr�r�r�rrrr
r��s
r��__main__)NN)rnrZunittest�typesrrr=rrrr(r0r5ZTestCaser6r�r�mainrrrr
�<module>s 


]#�