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_funcattrs.cpython-37.opt-1.pyc
B

��g5�@s�ddlZddlZdd�ZGdd�dej�ZGdd�de�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�Z	dd�Z
ddd�ZGdd�dej�ZGdd�dej�Z
Gdd�dej�Zedkr�e��dS)�Ncsdd���fdd�S)NcSsGdd�d�}dd�a|S)Nc@seZdZdS)z;global_function.<locals>.inner_function.<locals>.LocalClassN)�__name__�
__module__�__qualname__�rr�//usr/local/lib/python3.7/test/test_funcattrs.py�
LocalClasssrcSsdd�}|S)NcSsdS)Nrrrrr�inner_function2sz.inner_global_function.<locals>.inner_function2r)rrrr�inner_global_function
sr	)r	)rrrr�inner_functionsz'global_function.<locals>.inner_functioncs�S)Nrr)r
rr�<lambda>�z!global_function.<locals>.<lambda>rrr)r
r�global_functions	r
c@seZdZdd�Zdd�ZdS)�
FuncAttrsTestcCs.Gdd�d�}dd�}|�|_||_||_dS)Nc@seZdZdd�ZdS)zFuncAttrsTest.setUp.<locals>.FcSsdS)Nr)�selfrrr�asz FuncAttrsTest.setUp.<locals>.F.aN)rrrrrrrr�FsrcSsdS)N�rrrrr�bszFuncAttrsTest.setUp.<locals>.b)�firr)rrrrrr�setUps
zFuncAttrsTest.setUpcCsnyt|||�Wn|k
r$YnX|�d||f�yt||�Wn|k
rZYnX|�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_attrszFuncAttrsTest.cannot_set_attrN)rrrrrrrrrrs
rc@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�FunctionPropertiesTestcCs|�|jjt�dS)N)�assertEqualrrr)rrrr�test_module.sz"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)rr"ZassertIn�dirrrr)rrrr�test_dir_includes_correct_attrs1s

z6FunctionPropertiesTest.test_dir_includes_correct_attrscCsdd�}|�|j|�dS)NcSsdS)zmy docstringrrrrrr�	duplicate<szJFunctionPropertiesTest.test_duplicate_function_equality.<locals>.duplicate)ZassertNotEqualr)rr%rrr� test_duplicate_function_equality:sz7FunctionPropertiesTest.test_duplicate_function_equalitycCs2dd�}|�|�d�|jj|_|�|�d�dS)NcSsdS)Nrrrrr�testBrz:FunctionPropertiesTest.test_copying___code__.<locals>.testr)rr�__code__)rr'rrr�test_copying___code__As
z,FunctionPropertiesTest.test_copying___code__cCs,|�|jjt��|�|jddttf�dS)N�__globals__�)�assertIsrr*�globalsr�AttributeError�	TypeError)rrrr�test___globals__Gsz'FunctionPropertiesTest.test___globals__csZd��fdd�}|j}|�|t�|�t|�d�|�|djjd�|�|d|t�dS)N�cst��dS)N)�printr)rrr�fNrz2FunctionPropertiesTest.test___closure__.<locals>.f�r�cell�__closure__)	r6ZassertIsInstance�tupler�len�	__class__rrr.)rr3�cr)rr�test___closure__Lsz'FunctionPropertiesTest.test___closure__csD�fdd�}y|jdjWntk
r0YnX|�d�d�dS)Ncst��dS)N)r2r)rrrr3Wrz1FunctionPropertiesTest.test_empty_cell.<locals>.frz'shouldn't be able to read an empty cellr1)r6�
cell_contents�
ValueErrorr)rr3r)rr�test_empty_cellVs
z&FunctionPropertiesTest.test_empty_cellc	s�d��fdd�}|j}d|d_|�|djd�|�|�d�|��d�|d`y|djWntk
rvYnX|�d�|�t��|�WdQRX|�t��t��WdQRXdS)Nr1cs�S)Nrr)rrrr3brz/FunctionPropertiesTest.test_set_cell.<locals>.f�	rz'shouldn't be able to read an empty cell)	r6r<rr=rZassertRaises�	NameError�UnboundLocalErrorr2)rr3r:r)rr�
test_set_cell`s"

z$FunctionPropertiesTest.test_set_cellcCs�|�|jjd�d|j_|�|jjd�d|j_|�|jjd�|�|jddt�d}t|dii�|�|jjjd�|�|jjddt�dS)	Nrr:�drr!zdef f(): pass
f.__name__�__builtins__r)	rrrrr/�execrrr.)r�srrr�
test___name__tsz$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)
NzFuncAttrsTest.setUp.<locals>.bzFuncAttrsTest.setUpr
z!global_function.<locals>.<lambda>z'global_function.<locals>.inner_functionz;global_function.<locals>.inner_function.<locals>.LocalClassr	z.inner_global_function.<locals>.inner_function2r:rCrr!)	rrrrrr
r	rr/)rrrr�test___qualname__�s 
z(FunctionPropertiesTest.test___qualname__csd\��dd�}dd�}�fdd�}�fdd	�}��fd
d�}x*|||||gD]}|�t|j�tj�qNW|�|�d�|�|�d
�|j|_|�|j|j�|�|�d�y|j|_Wntk
r�YnX|�d�y|j|_Wntk
r�YnX|�d�dS)N)r!�cSsdS)Nrrrrrr�rz/FunctionPropertiesTest.test___code__.<locals>.acSsdS)Nr1rrrrrr�rz/FunctionPropertiesTest.test___code__.<locals>.bcs�S)Nrr)�num_onerrr:�rz/FunctionPropertiesTest.test___code__.<locals>.ccs�S)Nrr)�num_tworrrC�rz/FunctionPropertiesTest.test___code__.<locals>.dcs��fS)Nrr)rJrKrr�e�rz/FunctionPropertiesTest.test___code__.<locals>.er!rIzC__code__ with different numbers of free vars should not be possible)r�typer(�types�CodeTyper=r)rrrr:rCrL�funcr)rJrKr�
test___code__�s.
z$FunctionPropertiesTest.test___code__cCs*|�|jjd�|j`|�|jjd�dS)N)rr�__defaults__)rrrr�test_blank_func_defaults�sz/FunctionPropertiesTest.test_blank_func_defaultscCs�dd�}ddd�}|�|jd�|�|jd�d|_|�|jd�|�|�d�|�|d�d	�|�|dd	�d
�|`|�|jd�y
|�Wntk
r�YnX|�d�dS)
NcSs||S)Nr)rrrrr�
first_func�szAFunctionPropertiesTest.test_func_default_args.<locals>.first_funcr4r+cSs||S)Nr)rrrrr�second_func�szBFunctionPropertiesTest.test_func_default_args.<locals>.second_func)r4r+r�rIzE__defaults__ does not update; deleting it does not remove requirement)r4r+)rrRr/r)rrTrUrrr�test_func_default_args�s 

z-FunctionPropertiesTest.test_func_default_argsN)rrrr r$r&r)r0r;r>rBrGrHrQrSrWrrrrr,s	

rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�InstancemethodAttrTestcCs0|�|jjjj|j�|�|jjd|jt�dS)Nr9)rrr�__self__r9rrr/)rrrr�test___class__�sz%InstancemethodAttrTest.test___class__cCs2|�|jjj|jj�|�|jjd|jjt�dS)N�__func__)rrrr[rrr.)rrrr�
test___func__�sz$InstancemethodAttrTest.test___func__cCs.|�|jjj|j�|�|jjd|jt�dS)NrY)rrrrYrr.)rrrr�
test___self__�sz$InstancemethodAttrTest.test___self__cCspt�t|j�|j_|�|j��t|j��y|jjjWntk
rLYnX|�d�|�|jjddt�dS)Nz4using unknown attributes should raise AttributeError�unknown_attrr+)	rN�
MethodType�idrrr^r.rr)rrrr�test___func___non_method�s
z/InstancemethodAttrTest.test___func___non_methodN)rrrrZr\r]rarrrrrX�srXc@s$eZdZdd�Zdd�Zdd�ZdS)�ArbitraryFunctionAttrTestcCsJd|j_|�|jjd�yd|jj_Wntk
r:YnX|�d�dS)Nr!z0setting attributes on methods should raise error)rr"rrrr.r)rrrr�
test_set_attr�sz'ArbitraryFunctionAttrTest.test_set_attrcCs.y
|j`Wntk
rYnX|�d�dS)Nz1deleting unknown attribute should raise TypeError)rr^r.r)rrrr�test_delete_unknown_attr�s

z2ArbitraryFunctionAttrTest.test_delete_unknown_attrc	CsFx@|j|jjgD].}y
|jWntk
r2YqX|�d�qWdS)Nz4using unknown attributes should raise AttributeError)rrrZnon_existent_attrr.r)rrPrrr�test_unset_attrs
z)ArbitraryFunctionAttrTest.test_unset_attrN)rrrrcrdrerrrrrb�s
rbc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�FunctionDictsTestcCsD|�|jddt�ddlm}|ddi�}|�|jjjd|t�dS)N�__dict__r)�UserDictr"r!)rrr/�collectionsrhrrr[)rrhrCrrr�test_setting_dict_to_invalidsz.FunctionDictsTest.test_setting_dict_to_invalidcCs�ddi}||j_|�||jj�||jj_|�||jjjj�|�||jjj�|�|jjd�|�|jjdd�|�|jjjjd�|�|jjjd�dS)Nr"r!)	rrgr,rrrr[rr")rrCrrr�test_setting_dict_to_valids
z,FunctionDictsTest.test_setting_dict_to_validcCs.y
|j`Wntk
rYnX|�d�dS)Nz3deleting function dictionary should raise TypeError)rrgr/r)rrrr�test_delete___dict__%s

z&FunctionDictsTest.test_delete___dict__cCs|�|jji�dS)N)rrrg)rrrr�test_unassigned_dict-sz&FunctionDictsTest.test_unassigned_dictcCs(d}i}|||j<|�||j|�dS)NzSome string)rr)rrrCrrr�test_func_as_dict_key0s
z'FunctionDictsTest.test_func_as_dict_keyN)rrrrjrkrlrmrnrrrrrfs
rfc@seZdZdd�Zdd�ZdS)�FunctionDocstringTestcCs`|�|jjd�d}||j_||jj_|�|jj|�|�|jjj|�|�|jjd|t�dS)NzA test method that does nothing�__doc__)rrrprrrrr.)rZdocstrrrr�test_set_docstring_attr8s
z-FunctionDocstringTest.test_set_docstring_attrcCs"d|j_|j`|�|jjd�dS)Nz
The docstring)rrpr)rrrr�test_delete_docstringAsz+FunctionDocstringTest.test_delete_docstringN)rrrrqrrrrrrro7s	rocs�fdd�}|�|jdS)z)Create a cell containing the given value.cst��dS)N)r2r)rrrr3Iszcell.<locals>.fr)r6)rr3r)rrr5Gsr5Tcs�fdd�}|sd�|jdS)zCreate an empty cell.cst��dS)N)r2r)rrrr3Pszempty_cell.<locals>.fi�r)r6)�emptyr3r)rr�
empty_cellNsrtc@seZdZdd�ZdS)�CellTestcCsj|�td�td�k�|�t�td�k�|�t�t�k�|�td�td�k�|�td�t�k�dS)Nr+rZsaturdayi���gB�T)�
assertTruer5rt)rrrr�test_comparison[s
zCellTest.test_comparisonN)rrrrwrrrrruZsruc@seZdZdd�ZdS)�StaticMethodAttrsTestcCs<dd�}t|�}|�|j|k�t|�}|�|j|k�dS)NcSsdS)Nrrrrrr3isz4StaticMethodAttrsTest.test_func_attribute.<locals>.f)�classmethodrvr[�staticmethod)rr3r:rFrrr�test_func_attributehs
z)StaticMethodAttrsTest.test_func_attributeN)rrrr{rrrrrxgsrxc@seZdZdd�ZdS)�BuiltinFunctionPropertiesTestcCs�ddl}|�tjd�|�|jjd�|�tjjd�|�tjjd�|�tj	jd�|�t
j	jd�|�dd	d
gjjd�|�dd
ijjd�dS)Nrr8�timez
dict.fromkeyszfloat.__getformat__z
str.maketranszbytes.maketransr4r+rzlist.appendZfooZbarzdict.pop)
r}rr8r�dict�fromkeys�float�
__getformat__�str�	maketrans�bytes�append�pop)rr}rrr�test_builtin__qualname__ws
z6BuiltinFunctionPropertiesTest.test_builtin__qualname__N)rrrr�rrrrr|ssr|�__main__)T)rNZunittestr
ZTestCaserrrXrbrfror5rtrurxr|r�mainrrrr�<module>s 
')