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.7/test/__pycache__/test_decorators.cpython-37.pyc
B

��g�%�@s�ddlZdd�ZGdd�de�ZGdd�de�Zddd	�Zd
d�Zdd
�ZGdd�dej	�Z
Gdd�dej	�Zedkr~e�
�dS)�Ncs�fdd�}|S)Ncs|j���|S)N)�__dict__�update)�func)�kwds��0/usr/local/lib/python3.7/test/test_decorators.py�decorateszfuncattrs.<locals>.decorater)rrr)rr�	funcattrssr	c@seZdZedd��ZdS)�MiscDecoratorscs�fdd�}|S)Ncs�|jd<|S)N�author)r)r)�namerrrs
z'MiscDecorators.author.<locals>.decorater)rrr)rrr
szMiscDecorators.authorN)�__name__�
__module__�__qualname__�staticmethodrrrrrr
	sr
c@seZdZdd�ZdS)�DbcheckErrorcCst�|d||||f�dS)Nz+dbcheck %r failed (func=%s args=%s kwds=%s))�	Exception�__init__)�self�exprstrr�argsrrrrrszDbcheckError.__init__N)r
rrrrrrrrsrcs���fdd�}|S)z+Decorator to implement debugging assertionscs*t�d�jd�������fdd�}|S)Nz
dbcheck-%s�evalcs$t����st��||���||�S)N)rr)rr)�exprrr�globals�localsrr�checksz(dbcheck.<locals>.decorate.<locals>.check)�compiler
)rr)rrr)rrrrszdbcheck.<locals>.decorater)rrrrr)rrrr�dbchecksrcs�fdd�}|S)z&Decorator to count calls to a functioncs(�j�d��<���fdd�}�|_|S)Nrcs��d7<�||�S)N�r)rr)�countsr�	func_namerr�call,sz*countcalls.<locals>.decorate.<locals>.call)r
)rr!)r)rr rr)s
zcountcalls.<locals>.decorater)rrr)rr�
countcalls'sr"csi���fdd�}�j|_|S)NcsHy�|Stk
r,�|�}|�|<|Stk
rB�|�SXdS)N)�KeyError�	TypeError)r�res)r�savedrrr!7szmemoize.<locals>.call)r
)rr!r)rr&r�memoize5s
r'c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�TestDecoratorscCs6Gdd�dt�}|�|��d�|�|���d�dS)Nc@seZdZedd��ZdS)z%TestDecorators.test_single.<locals>.CcSsdS)N�*rrrrr�fooJsz)TestDecorators.test_single.<locals>.C.fooN)r
rrrr*rrrr�CIsr+r))�object�assertEqualr*)rr+rrr�test_singleHszTestDecorators.test_singlecCstdd��}|�t|d�dS)NcSs|S)Nr)�xrrr�
notamethodPsz=TestDecorators.test_staticmethod_function.<locals>.notamethodr)r�assertRaisesr$)rr0rrr�test_staticmethod_functionOsz)TestDecorators.test_staticmethod_functioncCs8t�}|�d�dd��}|�|�d�|�|jd�dS)NZCleesecSsdS)Nr)rrrrrr*Wsz'TestDecorators.test_dotted.<locals>.foor))r
rr-)rZ
decoratorsr*rrr�test_dottedUszTestDecorators.test_dottedcCs�dd�}d}tddd�}|||�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)�setattr)r)rrrrrasz@TestDecorators.test_argforms.<locals>.noteargs.<locals>.decorater)rrrr)rrr�noteargs`sz.TestDecorators.test_argforms.<locals>.noteargs)ZNow�isZtheZtimer�)ZoneZtwocSsdS)Nr)rrrrr�f1hsz(TestDecorators.test_argforms.<locals>.f1r)�terry�gilliamZidleZcleese)ZericZjohncSsdS)N�Trrrrr�f2msz(TestDecorators.test_argforms.<locals>.f2r<)r:r;cSsdS)Nrrrrr�f3ssz(TestDecorators.test_argforms.<locals>.f3)rr8)�dictr-r4)rr6rrr9r=r>rrr�
test_argforms\s
zTestDecorators.test_argformscCs6td�dd��}|�|dd�d�|�t|dd�dS)Nzargs[1] is not NonecSs||S)Nr)�a�brrr�fxsz&TestDecorators.test_dbcheck.<locals>.frr8�)rr-r1r)rrCrrr�test_dbcheckwszTestDecorators.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)Nr8r)r/rrr�double�sz+TestDecorators.test_memoize.<locals>.doublerFr)rFr8�rrD��
)r'r"r-r
r?)rrrFrrr�test_memoize~szTestDecorators.test_memoizecCs�x2dD]*}t|dd�d|}|�tt|dd�qW|�ttddd�dd�}td|d	�}xLd
tfdtfdtfd
tfgD],\}}d|}t|dd�}|�|t||�qxWdS)N)z1+2zx[3]z(1, 2)Ztestexpr�execz@%s
def f(): passZtestz@f1 @f2
def f(): passcSst�dS)N)�NotImplementedError)rrrr�unimp�sz)TestDecorators.test_errors.<locals>.unimp)�nullvalrMZundefrNznullval.attrrMz$@%s
def f(): pass
assert f() is None)	rr1�SyntaxErrorr?�	NameErrorr$�AttributeErrorrLr)rrZcodestrrM�context�exc�coderrr�test_errors�s

zTestDecorators.test_errorscCsVGdd�dt�}|�|���d�|�|jjd�|�|jjd�|�|jjd�dS)Nc@s*eZdZeddd�edd�dd���ZdS)	z%TestDecorators.test_double.<locals>.Cr�haha)�abc�xyzr))�boohcSsdS)Nr)r)rrrrr*�sz)TestDecorators.test_double.<locals>.C.fooN)r
rrr	r*rrrrr+�s
r+r)rrV)r,r-r*rWrXrY)rr+rrr�test_double�s
zTestDecorators.test_doublecCs4dd�}|d�|d�dd���}|�|�dd�dS)Ncs�fdd�}|S)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�S)Nrr)�numrr�<lambda>��zJTestDecorators.test_order.<locals>.callnum.<locals>.deco.<locals>.<lambda>r)r)r[rr�deco�sz8TestDecorators.test_order.<locals>.callnum.<locals>.decor)r[r^r)r[r�callnum�sz*TestDecorators.test_order.<locals>.callnumr8rcSsdS)Nr)rrrrrr*�sz&TestDecorators.test_order.<locals>.fooz,Application order of decorators is incorrect)r-)rr_r*rrr�
test_order�s

zTestDecorators.test_ordercs�g��fdd��G��fdd�dt�}t|dddg�\}}}dd	d
ddd
ddddddg}g�|�|j�|�|j�|�|j�dd����}|�|�d�|��|�g�dd�}|�|j�|�|j�|�|j�|���}|�|�d�|��|�dS)Ncs ��d����fdd�}|S)NZmakedeccs��d��|S)NZcalldec)�append)r)�actions�tagrrr�szHTestDecorators.test_eval_order.<locals>.make_decorator.<locals>.decorate)ra)rcr)rb)rcr�make_decorator�sz6TestDecorators.test_eval_order.<locals>.make_decoratorcs"eZdZdd�Z��fdd�ZdS)z8TestDecorators.test_eval_order.<locals>.NameLookupTracercSs
||_dS)N)�index)rrerrrr�szATestDecorators.test_eval_order.<locals>.NameLookupTracer.__init__csV|dkrd�}}n*|dkr.dt|j�}}nds>td|����d||jf�|S)NrdZevalname�argZevalargsFzUnknown attrname %sz%s%d)�strre�AssertionErrorra)rZfname�opnamer%)rbrdrr�__getattr__�szDTestDecorators.test_eval_order.<locals>.NameLookupTracer.__getattr__N)r
rrrrjr)rbrdrr�NameLookupTracer�srkrr8rDZ	evalname1Z	evalargs1Zmakedec1Z	evalname2Z	evalargs2Zmakedec2Z	evalname3Z	evalargs3Zmakedec3Zcalldec3Zcalldec2Zcalldec1cSsdS)Nr)rrrrrr*�sz+TestDecorators.test_eval_order.<locals>.foor)cSsdS)Nr)rrrrr�barr]z+TestDecorators.test_eval_order.<locals>.bar)r,�maprdrfr-)rrkZc1Zc2Zc3Zexpected_actionsr*rlr)rbrdr�test_eval_order�s&


(zTestDecorators.test_eval_orderN)
r
rrr.r2r3r@rErJrUrZr`rnrrrrr(Fs
r(c@s$eZdZdd�Zdd�Zdd�ZdS)�TestClassDecoratorscCs.dd�}|Gdd�dt��}|�|jd�dS)NcSs
d|_|S)N�Hello)�extra)r/rrr�plainsz.TestClassDecorators.test_simple.<locals>.plainc@seZdZdS)z*TestClassDecorators.test_simple.<locals>.CN)r
rrrrrrr+sr+rp)r,r-rq)rrrr+rrr�test_simpleszTestClassDecorators.test_simplecCs:dd�}dd�}||Gdd�dt���}|�|jd�dS)NcSs
d|_|S)NrI)rq)r/rrr�tensz,TestClassDecorators.test_double.<locals>.tencSs|jd7_|S)N�)rq)r/rrr�add_fivesz1TestClassDecorators.test_double.<locals>.add_fivec@seZdZdS)z*TestClassDecorators.test_double.<locals>.CN)r
rrrrrrr+sr+�)r,r-rq)rrtrvr+rrrrZs
zTestClassDecorators.test_doublecCs:dd�}dd�}||Gdd�dt���}|�|jd�dS)NcSs
d|_|S)N�first)rq)r/rrr�
applied_first$sz5TestClassDecorators.test_order.<locals>.applied_firstcSs
d|_|S)N�second)rq)r/rrr�applied_second'sz6TestClassDecorators.test_order.<locals>.applied_secondc@seZdZdS)z)TestClassDecorators.test_order.<locals>.CN)r
rrrrrrr+*sr+rz)r,r-rq)rryr{r+rrrr`#s
zTestClassDecorators.test_orderN)r
rrrsrZr`rrrrros
ro�__main__)NN)Zunittestr	r,r
rrrr"r'ZTestCaser(ror
�mainrrrr�<module>s


G#