Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_decorators.cpython-39.pyc

a

XC?h�+�@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��9/opt/alt/python39/lib64/python3.9/test/test_decorators.py�decorateszfuncattrs.<locals>.decorater	)rrr	rr
�	funcattrssrc@seZdZedd��ZdS)�MiscDecoratorscs�fdd�}|S)Ncs�|jd<|S)N�author)rr��namer	r
rs
z'MiscDecorators.author.<locals>.decorater	)rrr	rr
r
szMiscDecorators.authorN)�__name__�
__module__�__qualname__�staticmethodrr	r	r	r
r
	sr
c@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
rsrcs���fdd�}|S)z+Decorator to implement debugging assertionscs*t�d�jd�������fdd�}|S)Nz
dbcheck-%s�evalcs(t����st��||���|i|��Sr)rr�rr)�exprrr�globals�localsr	r
�checksz(dbcheck.<locals>.decorate.<locals>.check)�compiler)rr �rrr)rrr
rszdbcheck.<locals>.decorater	)rrrrr	r"r
�dbchecksr#cs�fdd�}|S)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�rr'�r%)rr&r
r)s
zcountcalls.<locals>.decorater	)r%rr	r*r
�
countcalls'sr+csi���fdd�}�j|_|S)NcsNz
�|WSty0�|�}|�|<|YStyH�|�YS0dSr)�KeyError�	TypeError)r�res�rZsavedr	r
r'7s
zmemoize.<locals>.callr(r)r	r/r
�memoize5s
r0c@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�TestDecoratorscCs6Gdd�dt�}|�|��d�|�|���d�dS)Nc@seZdZedd��ZdS)z%TestDecorators.test_single.<locals>.CcSsdS�N�*r	r	r	r	r
�fooJsz)TestDecorators.test_single.<locals>.C.fooN)rrrrr4r	r	r	r
�CIsr5r3)�object�assertEqualr4�rr5r	r	r
�test_singleHszTestDecorators.test_singlecCstdd��}|�t|d�dS)NcSs|Srr	��xr	r	r
�
notamethodPsz=TestDecorators.test_staticmethod_function.<locals>.notamethodr$)r�assertRaisesr-)rr<r	r	r
�test_staticmethod_functionOs
z)TestDecorators.test_staticmethod_functioncCs8t�}|�d�dd��}|�|�d�|�|jd�dS)NZCleesecSsdSr2r	r	r	r	r
r4Wsz'TestDecorators.test_dotted.<locals>.foor3)r
rr7)rZ
decoratorsr4r	r	r
�test_dottedUs

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)�setattrrrr	r
rasz@TestDecorators.test_argforms.<locals>.noteargs.<locals>.decorater	)rrrr	rr
�noteargs`sz.TestDecorators.test_argforms.<locals>.noteargs)ZNow�isZthe�timer$�)ZoneZtwocSsdSr2r	r	r	r	r
�f1hsz(TestDecorators.test_argforms.<locals>.f1r3�terry�gilliamZidleZcleese)ZericZjohncSsdS)N�Tr	r	r	r	r
�f2msz(TestDecorators.test_argforms.<locals>.f2rI)rGrHcSsdSrr	r	r	r	r
�f3ssz(TestDecorators.test_argforms.<locals>.f3)r$rE)�dictr7r@)rrBrrrFrJrKr	r	r
�
test_argforms\s 



�
zTestDecorators.test_argformscCs6td�dd��}|�|dd�d�|�t|dd�dS)Nzargs[1] is not NonecSs||Srr	)�a�br	r	r
�fxsz&TestDecorators.test_dbcheck.<locals>.fr$rE�)r#r7r=r)rrPr	r	r
�test_dbcheckws
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)NrEr	r:r	r	r
�double�sz+TestDecorators.test_memoize.<locals>.doublerSr)rSrE�r$rQ��
)r0r+r7rrL)rr%rSr	r	r
�test_memoize~s zTestDecorators.test_memoizec	CsdD]N}t|dd�|�t��$td|�d�dd�Wd�q1sH0YqdD]J}t|dd�|�t�� td|�d��Wd�qX1s�0YqXdd	�}td|d
�}dtfdtfd
tfdtffD],\}}d|}t|dd�}|�|t	||�q�dS)N)zx,zx, yzx = y�passz
import sys�test�exec�@�
def f(): pass)z1.+2jz
[1, 2][-1]z(1, 2)�Truez...�NonercSst�dSr)�NotImplementedErrorrr	r	r
�unimp�sz)TestDecorators.test_errors.<locals>.unimp)�nullvalr`Zundefraznullval.attrr`z$@%s
def f(): pass
assert f() is None)
r!r=�SyntaxErrorr-rZrL�	NameError�AttributeErrorr_r)rZstmtrr`�context�excZcodestr�coder	r	r
�test_errors�s$40�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.yr[r\rYrZ)r!)rrr	r	r
�test_expressions�szTestDecorators.test_expressionscCsVGdd�dt�}|�|���d�|�|jjd�|�|jjd�|�|jjd�dS)Nc@s*eZdZeddd�edd�dd���ZdS)	z%TestDecorators.test_double.<locals>.Cr$�haha)�abc�xyzr3)�boohcSsdSr2r	)rr	r	r
r4�sz)TestDecorators.test_double.<locals>.C.fooN)rrrrr4r	r	r	r
r5�s
r5r3r$rj)r6r7r4rkrlrmr8r	r	r
�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�Srr	r	��numr	r
�<lambda>��zJTestDecorators.test_order.<locals>.callnum.<locals>.deco.<locals>.<lambda>r	rror	r
�deco�sz8TestDecorators.test_order.<locals>.callnum.<locals>.decor	)rprsr	ror
�callnum�sz*TestDecorators.test_order.<locals>.callnumrEr$cSsdSr2r	r	r	r	r
r4�sz&TestDecorators.test_order.<locals>.fooz,Application order of decorators is incorrect)r7)rrtr4r	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�szHTestDecorators.test_eval_order.<locals>.make_decorator.<locals>.decoraterv)ryr)rx)ryr
�make_decorator�sz6TestDecorators.test_eval_order.<locals>.make_decoratorcs"eZdZdd�Z��fdd�ZdS)z8TestDecorators.test_eval_order.<locals>.NameLookupTracercSs
||_dSr)�index)rr{r	r	r
r�szATestDecorators.test_eval_order.<locals>.NameLookupTracer.__init__csV|dkrd�}}n*|dkr.dt|j�}}nds>Jd|����d||jf�|S)NrzZevalname�argZevalargsFzUnknown attrname %sz%s%d)�strr{rw)rZfname�opnamer.�rxrzr	r
�__getattr__�szDTestDecorators.test_eval_order.<locals>.NameLookupTracer.__getattr__N)rrrrr�r	rr	r
�NameLookupTracer�sr�)r$rErQ)Z	evalname1Z	evalargs1Zmakedec1Z	evalname2Z	evalargs2Zmakedec2Z	evalname3Z	evalargs3Zmakedec3Zcalldec3Zcalldec2Zcalldec1cSsdSr2r	r	r	r	r
r4sz+TestDecorators.test_eval_order.<locals>.foor3cSsdSr2r	r	r	r	r
�barrrz+TestDecorators.test_eval_order.<locals>.bar)r6�maprzr|r7)rr�Zc1Zc2Zc3Zexpected_actionsr4r�r	rr
�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>.BoundWrappercSs
||_dSr��__wrapped__�r�wrappedr	r	r
rszXTestDecorators.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
�BoundWrappersr�cs eZdZdd�Z�fdd�ZdS)zJTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.WrappercSs
||_dSrr�r�r	r	r
rszSTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.Wrapper.__init__cs|j�||�}�|�Sr)r��__get__)r�instance�ownerZbound_function�r�r	r
r�szRTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.Wrapper.__get__N)rrrrr�r	r�r	r
�Wrappersr�cs�|�Srr	)r�)r�r	r
�	decorator szLTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.decoratorcs,eZdZ�edd���Ze�dd���ZdS)zHTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.ClasscSsdS)N�spamr	��clsr	r	r
�inner$szNTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.Class.innercSsdS)N�eggsr	r�r	r	r
�outer*szNTestDecorators.test_wrapped_descriptor_inside_classmethod.<locals>.Class.outerN)rrr�classmethodr�r�r	)r�r	r
�Class#sr�r�r�)r7r�r�)rr�r	)r�r�r�r
�*test_wrapped_descriptor_inside_classmethodsz9TestDecorators.test_wrapped_descriptor_inside_classmethodN)rrrr9r>r?rMrRrWrhrirnrur�r�r	r	r	r
r1Fs
=r1c@s$eZdZdd�Zdd�Zdd�ZdS)�TestClassDecoratorscCs.dd�}|Gdd�dt��}|�|jd�dS)NcSs
d|_|S)N�Hello��extrar:r	r	r
�plain:sz.TestClassDecorators.test_simple.<locals>.plainc@seZdZdS)z*TestClassDecorators.test_simple.<locals>.CN�rrrr	r	r	r
r5=sr5r��r6r7r�)rr�r5r	r	r
�test_simple9szTestClassDecorators.test_simplecCs:dd�}dd�}||Gdd�dt���}|�|jd�dS)NcSs
d|_|S)NrVr�r:r	r	r
�tenBsz,TestClassDecorators.test_double.<locals>.tencSs|jd7_|S)N�r�r:r	r	r
�add_fiveEsz1TestClassDecorators.test_double.<locals>.add_fivec@seZdZdS)z*TestClassDecorators.test_double.<locals>.CNr�r	r	r	r
r5Isr5�r�)rr�r�r5r	r	r
rnAszTestClassDecorators.test_doublecCs:dd�}dd�}||Gdd�dt���}|�|jd�dS)NcSs
d|_|S)N�firstr�r:r	r	r
�
applied_firstOsz5TestClassDecorators.test_order.<locals>.applied_firstcSs
d|_|S)N�secondr�r:r	r	r
�applied_secondRsz6TestClassDecorators.test_order.<locals>.applied_secondc@seZdZdS)z)TestClassDecorators.test_order.<locals>.CNr�r	r	r	r
r5Usr5r�r�)rr�r�r5r	r	r
ruNszTestClassDecorators.test_orderN)rrrr�rnrur	r	r	r
r�7s
r��__main__)NN)Zunittestrr6r
rrr#r+r0ZTestCaser1r�r�mainr	r	r	r
�<module>s


r#