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-1.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!r3ZassertIn�dirrrr#rrrr�test_dir_includes_correct_attrs2s�
z6FunctionPropertiesTest.test_dir_includes_correct_attrscCsdd�}|�|j|�dS)NcSr)zmy docstringr rrrrr�	duplicate=szJFunctionPropertiesTest.test_duplicate_function_equality.<locals>.duplicate)ZassertNotEqualr!)rr6rrr� test_duplicate_function_equality;sz7FunctionPropertiesTest.test_duplicate_function_equalitycCs2dd�}|�|�d�|jj|_|�|�d�dS)NcSr	r
rrrrr�testCrz:FunctionPropertiesTest.test_copying___code__.<locals>.testr )r/r!�__code__)rr8rrr�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)�typerBZfunc3Zfunc4)r=r!rBr-r?r@rIr9r;r/�textwrap�dedent�execZassertNotIn)rrE�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__)	rYZassertIsInstance�tupler/rC�	__class__rr-r?�rrU�crrTr�test___closure__lsz'FunctionPropertiesTest.test___closure__cCs^t�d�}|�|jd�t��}d}|jt|d��|jWd�dS1s(wYdS)NrW�'shouldn't be able to read an empty cell)�msg)�types�CellTyper/�
cell_contents�assertRaises�
ValueError)rZcell_objr`rrr�
test_cell_newvs
"�z$FunctionPropertiesTest.test_cell_newcsH�fdd�}z|jdjWntyYd�dSw|�d�d�dS)NcrQr
rRrrTrrrU�rVz1FunctionPropertiesTest.test_empty_cell.<locals>.frr_rP)rYrcrer')rrUrrTr�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)NrPcrr
rrrTrrrU�rz/FunctionPropertiesTest.test_set_cell.<locals>.f�	rr_)	rYrcr/rer'rd�	NameError�UnboundLocalErrorrSr\rrTr�
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]�drr2zdef f(): pass
f.__name__rBr)	r/r!rr-r@rLr#rr?)rrDrrr�
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]rlrr2)	r/r!rrr$rrr-r@rrrr�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)r2�cSr	r
rrrrrr�rz/FunctionPropertiesTest.test___code__.<locals>.acSr)NrPrrrrrr!�rz/FunctionPropertiesTest.test___code__.<locals>.bcrr
rr)�num_onerrr]�rz/FunctionPropertiesTest.test___code__.<locals>.ccrr
rr)�num_tworrrl�rz/FunctionPropertiesTest.test___code__.<locals>.dcs��fSr
rr�rprqrr�e�rFz/FunctionPropertiesTest.test___code__.<locals>.er2rozC__code__ with different numbers of free vars should not be possible)r/rIr9ra�CodeTyperer')rrr!r]rlrsrErrrr�
test___code__�s2�
�z$FunctionPropertiesTest.test___code__cCs*|�|jjd�|j`|�|jjd�dSr
)r/r!�__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_funcrWr<cSrxr
rryrrr�second_func�r{zBFunctionPropertiesTest.test_func_default_args.<locals>.second_func)rWr<r �rozE__defaults__ does not update; deleting it does not remove requirement)r/rvr@r')rrzr|rrr�test_func_default_args�s"

�z-FunctionPropertiesTest.test_func_default_argsN)rrrr0r5r7r:rArOr^rfrgrkrmrnrurwr~rrrrr.-s 	
	
r.c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�InstancemethodAttrTestcCs0|�|jjjj|j�|�|jjd|jt�dS)Nr[)r/r#r�__self__r[rr-r@rrrr�test___class__�sz%InstancemethodAttrTest.test___class__cCs2|�|jjj|jj�|�|jjd|jjt�dS)N�__func__)r/r#rr�rr-r?rrrr�
test___func__sz$InstancemethodAttrTest.test___func__cCs.|�|jjj|j�|�|jjd|jt�dS)Nr�)r/r#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<)	ra�
MethodType�idr#r/r�r?r'r-rrrr�test___func___non_method	s�
z/InstancemethodAttrTest.test___func___non_methodN)rrrr�r�r�r�rrrrr�s
rc@s$eZdZdd�Zdd�Zdd�ZdS)�ArbitraryFunctionAttrTestcCsJd|j_|�|jjd�zd|jj_Wn
tyYdSw|�d�dS)Nr2z0setting attributes on methods should raise error)r!r3r/r#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')rrErrr�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)�UserDictr3r2)r-r!r@�collectionsr�r#rr�)rr�rlrrr�test_setting_dict_to_invalid8sz.FunctionDictsTest.test_setting_dict_to_invalidcCs�ddi}||j_|�||jj�||jj_|�||jjjj�|�||jjj�|�|jjd�|�|jjdd�|�|jjjjd�|�|jjjd�dS)Nr3r2)	r!r�r=rrr#r�r/r3)rrlrrr�test_setting_dict_to_valid>s
z,FunctionDictsTest.test_setting_dict_to_validcCr�)Nz3deleting function dictionary should raise TypeError)r!r�r@r'rrrr�test_delete___dict__Nr�z&FunctionDictsTest.test_delete___dict__cCs|�|jji�dSr
)r/r!r�rrrr�test_unassigned_dictVr1z&FunctionDictsTest.test_unassigned_dictcCs(d}i}|||j<|�||j|�dS)NzSome string)r!r/)rr+rlrrr�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__)r/r!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�r/rrrr�test_delete_docstringjsz+FunctionDocstringTest.test_delete_docstringN)rrrr�r�rrrrr�`s	r�cs�fdd�}|�|jdS)z)Create a cell containing the given value.crQr
rRrrTrrrUr�zcell.<locals>.fr�rY)r+rUrrTrrXps
rXTcs�fdd�}|s
d�|jdS)zCreate an empty cell.crQr
rRrrTrrrUyr�zempty_cell.<locals>.fi�rr�)�emptyrUrrTr�
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)�
assertTruerXr�rrrr�test_comparison�s
zCellTest.test_comparisonN)rrrr�rrrrr��rr�c@r)�StaticMethodAttrsTestcCs<dd�}t|�}|�|j|u�t|�}|�|j|u�dS)NcSr	r
rrrrrrU�rz4StaticMethodAttrsTest.test_func_attribute.<locals>.f)�classmethodr�r��staticmethod)rrUr]rDrrr�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)
NrrC�timez
dict.fromkeyszfloat.__getformat__z
str.maketranszbytes.maketrans)rWr<r zlist.appendZfooZbarzdict.pop)
r�r/rCr�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)rJraZunittestrZTestCaserr.rr�r�r�rXr�r�r�r�r�mainrrrr�<module>s&
O)

�