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_funcattrs.cpython-310.opt-2.pyc
o

�ip;�@s�ddlZddlZddlZdd�ZGdd�dej�ZGdd�de�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�Z	Gdd�de�Z
dd�Zddd�ZGdd�dej�Z
Gdd�dej�ZGdd�dej�Zedkroe��dSdS)�Ncsdd���fdd�S)NcSsGdd�d�}dd�a|S)Nc@seZdZdS)�;global_function.<locals>.inner_function.<locals>.LocalClassN)�__name__�
__module__�__qualname__�rr�0/usr/local/lib/python3.10/test/test_funcattrs.py�
LocalClasssrcSsdd�}|S)NcS�dS�Nrrrrr�inner_function2��.inner_global_function.<locals>.inner_function2r)rrrr�inner_global_functionsr)r)rrrr�inner_functions�'global_function.<locals>.inner_functionc��Sr
rr�rrr�<lambda>��!global_function.<locals>.<lambda>rrrrr�global_functions	rc@�eZdZdd�Zdd�ZdS)�
FuncAttrsTestcCs.Gdd�d�}dd�}|�|_||_||_dS)Nc@�eZdZdd�ZdS)zFuncAttrsTest.setUp.<locals>.FcSr	r
r��selfrrr�arz FuncAttrsTest.setUp.<locals>.F.aN)rrrrrrrr�F�rcS�dS�N�rrrrr�br�FuncAttrsTest.setUp.<locals>.b)�firr")rrr"rrr�setUps

�FuncAttrsTest.setUpcCslzt|||�Wn	|yYn
w|�d||f�zt||�Wn
|y,YdSw|�d|�dS)Nz!shouldn't be able to set %s to %rzshouldn't be able to del %s)�setattr�fail�delattr)r�obj�name�value�
exceptionsrrr�cannot_set_attrs��zFuncAttrsTest.cannot_set_attrN)rrrr%r.rrrrrs
rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �FunctionPropertiesTestcCs|�|jjt�dSr
)�assertEqualr"rrrrrr�test_module/�z"FunctionPropertiesTest.test_modulecCs@d|j_|�dt|j�d�d|jj_|�dt|jj�d�dS)N��
known_attrz+set attributes not in dir listing of methodzEset attribute on function implementations, should show up in next dir)r"r4ZassertIn�dirrrr$rrrr�test_dir_includes_correct_attrs2s�
z6FunctionPropertiesTest.test_dir_includes_correct_attrscCsdd�}|�|j|�dS)NcSs	dSr rrrrr�	duplicate=szJFunctionPropertiesTest.test_duplicate_function_equality.<locals>.duplicate)ZassertNotEqualr")rr7rrr� test_duplicate_function_equality;sz7FunctionPropertiesTest.test_duplicate_function_equalitycCs2dd�}|�|�d�|jj|_|�|�d�dS)NcSr	r
rrrrr�testCrz:FunctionPropertiesTest.test_copying___code__.<locals>.testr!)r0r"�__code__)rr9rrr�test_copying___code__Bs
z,FunctionPropertiesTest.test_copying___code__cCs,|�|jjt��|�|jddttf�dS)N�__globals__�)�assertIsr"r<�globalsr.�AttributeError�	TypeErrorrrrr�test___globals__Hs�z'FunctionPropertiesTest.test___globals__cCs�|�|jjt�|�|jddttf�dd�}i}t|�|j|�}|�|j|�|�|jt�|�	|d�d�|�	|i�t
�d�}ddi}t|d	�}t||�|�|d
j|�|�|dj|�|�|d
jd|�|�
d|dj�dS)N�__builtins__r=cSst|�Sr
)�len)�srrr�funcT�z6FunctionPropertiesTest.test___builtins__.<locals>.func�abcr!z\
            def func3(s): pass
            func4 = type(func3)(func3.__code__, {})
        �None)�typerCZfunc3Zfunc4)r>r"rCr.r@rArJr:r<r0�textwrap�dedent�execZassertNotIn)rrF�nsZfunc2�codeZ
safe_builtinsrrr�test___builtins__Ms&�


z(FunctionPropertiesTest.test___builtins__csZd��fdd�}|j}|�|t�|�t|�d�|�|djjd�|�|d|t�dS)N�c�t��dSr
��printr�rrr�fn�z2FunctionPropertiesTest.test___closure__.<locals>.f�r�cell�__closure__)	rZZassertIsInstance�tupler0rD�	__class__rr.r@�rrV�crrUr�test___closure__lsz'FunctionPropertiesTest.test___closure__cCs^t�d�}|�|jd�t��}d}|jt|d��|jWd�dS1s(wYdS)NrX�'shouldn't be able to read an empty cell)�msg)�types�CellTyper0�
cell_contents�assertRaises�
ValueError)rZcell_objrarrr�
test_cell_newvs
"�z$FunctionPropertiesTest.test_cell_newcsH�fdd�}z|jdjWntyYd�dSw|�d�d�dS)NcrRr
rSrrUrrrV�rWz1FunctionPropertiesTest.test_empty_cell.<locals>.frr`rQ)rZrdrfr()rrVrrUr�test_empty_cells�
z&FunctionPropertiesTest.test_empty_cellcs�d��fdd�}|j}d|d_|�|djd�|�|�d�|��d�|d`z|djWn	ty:Ynw|�d�|�t��|�Wd�n1sSwY|�t��
t��Wd�dS1smwYdS)NrQcrr
rrrUrrrV�rz/FunctionPropertiesTest.test_set_cell.<locals>.f�	rr`)	rZrdr0rfr(re�	NameError�UnboundLocalErrorrTr]rrUr�
test_set_cell�s(
�
�
"�z$FunctionPropertiesTest.test_set_cellcCs�|�|jjd�d|j_|�|jjd�d|j_|�|jjd�|�|jddt�d}t|dii�|�|jjjd�|�|jjddt�dS)	Nr"r^�drr3zdef f(): pass
f.__name__rCr)	r0r"rr.rArMr$rr@)rrErrr�
test___name__�sz$FunctionPropertiesTest.test___name__cCs�|�|jjd�|�tjjd�|�tjd�|�t�jd�|�t��jd�|�t���jd�|�tjd�|�t�jd�d	|j_|�|jjd	�d
|j_|�|jjd
�|�|jddt�dS)
Nr#r&rrrrrr
r^rmrr3)	r0r"rrr%rrr.rArrrr�test___qualname__�s&
���z(FunctionPropertiesTest.test___qualname__csd\��dd�}dd�}�fdd�}�fdd	�}��fd
d�}|||||fD]}|�t|j�tj�q&|�|�d�|�|�d
�|j|_|�|j|j�|�|�d�z|j|_Wn	tycYnw|�d�z|j|_Wn
tyyYdSw|�d�dS)N)r3�cSr	r
rrrrrr�rz/FunctionPropertiesTest.test___code__.<locals>.acSr)NrQrrrrrr"�rz/FunctionPropertiesTest.test___code__.<locals>.bcrr
rr)�num_onerrr^�rz/FunctionPropertiesTest.test___code__.<locals>.ccrr
rr)�num_tworrrm�rz/FunctionPropertiesTest.test___code__.<locals>.dcs��fSr
rr�rqrrrr�e�rGz/FunctionPropertiesTest.test___code__.<locals>.er3rpzC__code__ with different numbers of free vars should not be possible)r0rJr:rb�CodeTyperfr()rrr"r^rmrtrFrrsr�
test___code__�s2�
�z$FunctionPropertiesTest.test___code__cCs*|�|jjd�|j`|�|jjd�dSr
)r0r"�__defaults__rrrr�test_blank_func_defaults�sz/FunctionPropertiesTest.test_blank_func_defaultscCs�dd�}ddd�}|�|jd�|�|jd�d|_|�|jd�|�|�d�|�|d�d	�|�|dd	�d
�|`|�|jd�z|�Wn
tyQYdSw|�d�dS)NcS�||Sr
r�rr"rrr�
first_func��zAFunctionPropertiesTest.test_func_default_args.<locals>.first_funcrXr=cSryr
rrzrrr�second_func�r|zBFunctionPropertiesTest.test_func_default_args.<locals>.second_func)rXr=r!�rpzE__defaults__ does not update; deleting it does not remove requirement)r0rwrAr()rr{r}rrr�test_func_default_args�s"

�z-FunctionPropertiesTest.test_func_default_argsN)rrrr1r6r8r;rBrPr_rgrhrlrnrorvrxrrrrrr/-s 	
	
r/c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�InstancemethodAttrTestcCs0|�|jjjj|j�|�|jjd|jt�dS)Nr\)r0r$r�__self__r\rr.rArrrr�test___class__�sz%InstancemethodAttrTest.test___class__cCs2|�|jjj|jj�|�|jjd|jjt�dS)N�__func__)r0r$rr�rr.r@rrrr�
test___func__sz$InstancemethodAttrTest.test___func__cCs.|�|jjj|j�|�|jjd|jt�dS)Nr�)r0r$rr�r.r@rrrr�
test___self__sz$InstancemethodAttrTest.test___self__cCsnt�t|j�|j_|�|j��t|j��z|jjjWn	ty%Ynw|�d�|�|jjddt�dS)N�4using unknown attributes should raise AttributeError�unknown_attrr=)	rb�
MethodType�idr$r0r�r@r(r.rrrr�test___func___non_method	s�
z/InstancemethodAttrTest.test___func___non_methodN)rrrr�r�r�r�rrrrr��s
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�ArbitraryFunctionAttrTestcCsJd|j_|�|jjd�zd|jj_Wn
tyYdSw|�d�dS)Nr3z0setting attributes on methods should raise error)r"r4r0r$rr@r(rrrr�
test_set_attrs�z'ArbitraryFunctionAttrTest.test_set_attrcC�.z|j`Wn
tyYdSw|�d�dS)Nz1deleting unknown attribute should raise TypeError)r"r�r@r(rrrr�test_delete_unknown_attr$�
�z2ArbitraryFunctionAttrTest.test_delete_unknown_attrc	Cs@|j|jjfD]}z|jWn	tyYqw|�d�qdS)Nr�)r"r$rZnon_existent_attrr@r()rrFrrr�test_unset_attr,s
��z)ArbitraryFunctionAttrTest.test_unset_attrN)rrrr�r�r�rrrrr�s
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�FunctionDictsTestcCsD|�|jddt�ddlm}|ddi�}|�|jjjd|t�dS)N�__dict__r)�UserDictr4r3)r.r"rA�collectionsr�r$rr�)rr�rmrrr�test_setting_dict_to_invalid8sz.FunctionDictsTest.test_setting_dict_to_invalidcCs�ddi}||j_|�||jj�||jj_|�||jjjj�|�||jjj�|�|jjd�|�|jjdd�|�|jjjjd�|�|jjjd�dS)Nr4r3)	r"r�r>rrr$r�r0r4)rrmrrr�test_setting_dict_to_valid>s
z,FunctionDictsTest.test_setting_dict_to_validcCr�)Nz3deleting function dictionary should raise TypeError)r"r�rAr(rrrr�test_delete___dict__Nr�z&FunctionDictsTest.test_delete___dict__cCs|�|jji�dSr
)r0r"r�rrrr�test_unassigned_dictVr2z&FunctionDictsTest.test_unassigned_dictcCs(d}i}|||j<|�||j|�dS)NzSome string)r"r0)rr,rmrrr�test_func_as_dict_keyYs
z'FunctionDictsTest.test_func_as_dict_keyN)rrrr�r�r�r�r�rrrrr�7sr�c@r)�FunctionDocstringTestcCs`|�|jjd�d}||j_||jj_|�|jj|�|�|jjj|�|�|jjd|t�dS)NzA test method that does nothing�__doc__)r0r"r�rrr$r.r@)rZdocstrrrr�test_set_docstring_attras
z-FunctionDocstringTest.test_set_docstring_attrcCs"d|j_|j`|�|jjd�dS)Nz
The docstring)r"r�r0rrrr�test_delete_docstringjsz+FunctionDocstringTest.test_delete_docstringN)rrrr�r�rrrrr�`s	r�cs	�fdd�}|�|jdS)NcrRr
rSrrUrrrVr�zcell.<locals>.fr�rZ)r,rVrrUrrYps
rYTcs 	�fdd�}|sd�|jdS)NcrRr
rSrrUrrrVyr�zempty_cell.<locals>.fi�rr�)�emptyrVrrUr�
empty_cellws

r�c@r)�CellTestcCsj|�td�td�k�|�t�td�k�|�t�t�k�|�td�td�k�|�td�t�k�dS)Nr=r!Zsaturdayi���gB�T)�
assertTruerYr�rrrr�test_comparison�s
zCellTest.test_comparisonN)rrrr�rrrrr��rr�c@r)�StaticMethodAttrsTestcCs<dd�}t|�}|�|j|u�t|�}|�|j|u�dS)NcSr	r
rrrrrrV�rz4StaticMethodAttrsTest.test_func_attribute.<locals>.f)�classmethodr�r��staticmethod)rrVr^rErrr�test_func_attribute�s
z)StaticMethodAttrsTest.test_func_attributeN)rrrr�rrrrr��rr�c@r)�BuiltinFunctionPropertiesTestcCs�ddl}|�tjd�|�|jjd�|�tjjd�|�tjjd�|�tj	jd�|�t
j	jd�|�gd�jjd	�|�d
dijjd�dS)
NrrD�timez
dict.fromkeyszfloat.__getformat__z
str.maketranszbytes.maketrans)rXr=r!zlist.appendZfooZbarzdict.pop)
r�r0rDr�dict�fromkeys�float�
__getformat__�str�	maketrans�bytes�append�pop)rr�rrr�test_builtin__qualname__�s
�z6BuiltinFunctionPropertiesTest.test_builtin__qualname__N)rrrr�rrrrr��sr��__main__)T)rKrbZunittestrZTestCaserr/r�r�r�r�rYr�r�r�r�r�mainrrrr�<module>s&
O)

�