Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_funcattrs.cpython-34.pyc

�
g f64�@sGddlmZddlZddlZdd�ZGdd�dej�ZGdd�de�ZGd	d
�d
e�ZGdd�de�Z	Gd
d�de�Z
Gdd�de�Zdd�Zddd�Z
Gdd�dej�ZGdd�dej�ZGdd�dej�Zdd�ZedkrCe�ndS)�)�supportNcsdd���fdd�S)NcSs#Gdd�d�}dd�a|S)Nc@seZdZdS)z;global_function.<locals>.inner_function.<locals>.LocalClassN)�__name__�
__module__�__qualname__�rr�8/opt/alt/python34/lib64/python3.4/test/test_funcattrs.py�
LocalClasssrcSsdd�}|S)NcSsdS)Nrrrrr�inner_function2sz.inner_global_function.<locals>.inner_function2r)r	rrr�inner_global_functionsr
)r
)rrrr�inner_functionsz'global_function.<locals>.inner_functioncs�S)Nrr)rrr�<lambda>sz!global_function.<locals>.<lambda>rrr)rr�global_functions	r
c@s(eZdZdd�Zdd�ZdS)�
FuncAttrsTestcCsAGdd�d�}dd�}|�|_||_||_dS)Nc@seZdZdd�ZdS)zFuncAttrsTest.setUp.<locals>.FcSsdS)Nr)�selfrrr�asz FuncAttrsTest.setUp.<locals>.F.aN)rrrrrrrr�FsrcSsdS)N�rrrrr�bszFuncAttrsTest.setUp.<locals>.b)�firr)rrrrrr�setUps
	zFuncAttrsTest.setUpcCs{yt|||�Wn|k
r(YnX|jd||f�yt||�Wn|k
reYnX|jd|�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)rrrrrrrrrrs
rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�FunctionPropertiesTestcCs|j|jjt�dS)N)�assertEqualrrr)rrrr�test_module/sz"FunctionPropertiesTest.test_modulecCsZd|j_|jdt|j�d�d|jj_|jdt|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_attrs2s
z6FunctionPropertiesTest.test_dir_includes_correct_attrscCs#dd�}|j|j|�dS)NcSsdS)zmy docstringrrrrrr�	duplicate=szJFunctionPropertiesTest.test_duplicate_function_equality.<locals>.duplicate)ZassertNotEqualr)rr%rrr� test_duplicate_function_equality;sz7FunctionPropertiesTest.test_duplicate_function_equalitycCsEdd�}|j|�d�|jj|_|j|�d�dS)NcSsdS)Nrrrrr�testCsz:FunctionPropertiesTest.test_copying___code__.<locals>.testr)rr�__code__)rr'rrr�test_copying___code__Bsz,FunctionPropertiesTest.test_copying___code__cCs<|j|jjt��|j|jddttf�dS)N�__globals__�)�assertIsrr*�globalsr�AttributeError�	TypeError)rrrr�test___globals__Hsz'FunctionPropertiesTest.test___globals__cs{d��fdd�}|j}|j|t�|jt|�d�|j|djjd�|j|d|t�dS)N�cst��dS)N)�printr)rrr�fOsz2FunctionPropertiesTest.test___closure__.<locals>.f�r�cell�__closure__)	r6ZassertIsInstance�tupler�len�	__class__rrr.)rr3�cr)rr�test___closure__Ms	z'FunctionPropertiesTest.test___closure__csP�fdd�}y|jdjWntk
r8YnX|jd�d�dS)Ncst��dS)N)r2r)rrrr3Xsz1FunctionPropertiesTest.test_empty_cell.<locals>.frz'shouldn't be able to read an empty cellr1)r6�
cell_contents�
ValueErrorr)rr3r)rr�test_empty_cellWs

z&FunctionPropertiesTest.test_empty_cellcCs�|j|jjd�d|j_|j|jjd�d|j_|j|jjd�|j|jddt�d}t|iid6�|j|jjjd�|j|jjddt�dS)	Nrr:�drr!zdef f(): pass
f.__name__�__builtins__r)	rrrrr/�execrrr.)r�srrr�
test___name__asz$FunctionPropertiesTest.test___name__cCs|j|jjd�|jtjjd�|jtjd�|jt�jd�|jt��jd�|jt���jd�|jtjd�|jt�jd�d	|j_|j|jjd	�d
|j_|j|jjd
�|j|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:r?rr!)	rrrrrr
r
rr/)rrrr�test___qualname__qs z(FunctionPropertiesTest.test___qualname__cs\d\��dd�}dd�}�fdd�}�fd	d
�}��fdd�}x9|||||gD]"}|jt|j�tj�qsW|j|�d�|j|�d�|j|_|j|j|j�|j|�d�y|j|_Wntk
rYnX|jd
�y|j|_Wntk
rJYnX|jd
�dS)Nr!�cSsdS)Nrrrrrr�sz/FunctionPropertiesTest.test___code__.<locals>.acSsdS)Nr1rrrrrr�sz/FunctionPropertiesTest.test___code__.<locals>.bcs�S)Nrr)�num_onerrr:�sz/FunctionPropertiesTest.test___code__.<locals>.ccs�S)Nrr)�num_tworrr?�sz/FunctionPropertiesTest.test___code__.<locals>.dcs
��fS)Nrr)rFrGrr�e�sz/FunctionPropertiesTest.test___code__.<locals>.ezC__code__ with different numbers of free vars should not be possible)r!rE)r�typer(�types�CodeTyper=r)rrrr:r?rH�funcr)rFrGr�
test___code__�s. 


z$FunctionPropertiesTest.test___code__cCs9|j|jjd�|j`|j|jjd�dS)N)rr�__defaults__)rrrr�test_blank_func_defaults�s	z/FunctionPropertiesTest.test_blank_func_defaultscCs�dd�}dddd�}|j|jd�|j|jd�d|_|j|jd
�|j|�d�|j|d�d�|j|dd�d	�|`|j|jd�y|�Wntk
r�YnX|jd
�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_funcr�rEzE__defaults__ does not update; deleting it does not remove requirement)r4r+)r4r+)r4r+)rrNr/r)rrPrQrrr�test_func_default_args�s 	
z-FunctionPropertiesTest.test_func_default_argsN)rrrr r$r&r)r0r;r>rCrDrMrOrSrrrrr-s	

rc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�InstancemethodAttrTestcCsB|j|jjjj|j�|j|jjd|jt�dS)Nr9)rrr�__self__r9rrr/)rrrr�test___class__�sz%InstancemethodAttrTest.test___class__cCsE|j|jjj|jj�|j|jjd|jjt�dS)N�__func__)rrrrWrrr.)rrrr�
test___func__�sz$InstancemethodAttrTest.test___func__cCs?|j|jjj|j�|j|jjd|jt�dS)NrU)rrrrUrr.)rrrr�
test___self__�sz$InstancemethodAttrTest.test___self__c
Cs�tjt|j�|j_|j|jj�t|j��y|jjjWntk
rbYnX|jd�|j|jjddt�dS)Nz4using unknown attributes should raise AttributeError�unknown_attrr+)	rJ�
MethodType�idrrrZr.rr)rrrr�test___func___non_method�s"

z/InstancemethodAttrTest.test___func___non_methodN)rrrrVrXrYr]rrrrrT�srTc@s4eZdZdd�Zdd�Zdd�ZdS)�ArbitraryFunctionAttrTestcCs[d|j_|j|jjd�yd|jj_Wntk
rIYnX|jd�dS)Nr!z0setting attributes on methods should raise error)rr"rrrr.r)rrrr�
test_set_attr�s
z'ArbitraryFunctionAttrTest.test_set_attrcCs3y
|j`Wntk
r!YnX|jd�dS)Nz1deleting unknown attribute should raise TypeError)rrZr.r)rrrr�test_delete_unknown_attr�s


z2ArbitraryFunctionAttrTest.test_delete_unknown_attrcCsQxJ|j|jjgD]3}y|jWntk
r;YqX|jd�qWdS)Nz4using unknown attributes should raise AttributeError)rrrZnon_existent_attrr.r)rrLrrr�test_unset_attr�s
z)ArbitraryFunctionAttrTest.test_unset_attrN)rrrr_r`rarrrrr^�s
r^c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�FunctionDictsTestcCs_|j|jddt�ddlm}|idd6�}|j|jjjd|t�dS)N�__dict__r)�UserDictr!r")rrr/�collectionsrdrrrW)rrdr?rrr�test_setting_dict_to_invalid�sz.FunctionDictsTest.test_setting_dict_to_invalidcCs�idd6}||j_|j||jj�||jj_|j||jjjj�|j||jjj�|j|jjd�|j|jjdd�|j|jjjjd�|j|jjjd�dS)Nr!r")	rrcr,rrrrWrr")rr?rrr�test_setting_dict_to_valids
z,FunctionDictsTest.test_setting_dict_to_validcCs3y
|j`Wntk
r!YnX|jd�dS)Nz3deleting function dictionary should raise TypeError)rrcr/r)rrrr�test_delete___dict__s


z&FunctionDictsTest.test_delete___dict__cCs|j|jji�dS)N)rrrc)rrrr�test_unassigned_dictsz&FunctionDictsTest.test_unassigned_dictcCs4d}i}|||j<|j||j|�dS)NzSome string)rr)rrr?rrr�test_func_as_dict_keys
z'FunctionDictsTest.test_func_as_dict_keyN)rrrrfrgrhrirjrrrrrb�s
rbc@s(eZdZdd�Zdd�ZdS)�FunctionDocstringTestcCs�|j|jjd�d}||j_||jj_|j|jj|�|j|jjj|�|j|jjd|t�dS)NzA test method that does nothing�__doc__)rrrlrrrrr.)rZdocstrrrr�test_set_docstring_attr%sz-FunctionDocstringTest.test_set_docstring_attrcCs/d|j_|j`|j|jjd�dS)Nz
The docstring)rrlr)rrrr�test_delete_docstring.s	z+FunctionDocstringTest.test_delete_docstringN)rrrrmrnrrrrrk$s	rkcs#�fdd�}|�|jdS)z)Create a cell containing the given value.cst��dS)N)r2r)rrrr36szcell.<locals>.fr)r6)rr3r)rrr54sr5Tcs,�fdd�}|s!d�n|jdS)zCreate an empty cell.cst��dS)N)r2r)rrrr3=szempty_cell.<locals>.fi�r)r6)�emptyr3r)rr�
empty_cell;s	rpc@seZdZdd�ZdS)�CellTestcCs�|jtd�td�k�|jt�td�k�|jt�t�k�|jtd�td�k�|jtd�t�k�dS)	Nr+rZsaturday�$gB@Ti���gB�)�
assertTruer5rp)rrrr�test_comparisonHs
zCellTest.test_comparisonN)rrrrtrrrrrqGsrqc@seZdZdd�ZdS)�StaticMethodAttrsTestcCsTdd�}t|�}|j|j|k�t|�}|j|j|k�dS)NcSsdS)Nrrrrrr3Vsz4StaticMethodAttrsTest.test_func_attribute.<locals>.f)�classmethodrsrW�staticmethod)rr3r:rBrrr�test_func_attributeUs
z)StaticMethodAttrsTest.test_func_attributeN)rrrrxrrrrruTsruc@seZdZdd�ZdS)�BuiltinFunctionPropertiesTestcCs�ddl}|jtjd�|j|jjd�|jtjjd�|jtjjd�|jtj	jd�|jt
j	jd�|jdd	d
gjjd�|jidd
6jjd�dS)Nrr8�timez
dict.fromkeyszfloat.__getformat__z
str.maketranszbytes.maketransr4r+rzlist.appendZbarZfoozdict.pop)
rzrr8r�dict�fromkeys�float�
__getformat__�str�	maketrans�bytes�append�pop)rrzrrr�test_builtin__qualname__dsz6BuiltinFunctionPropertiesTest.test_builtin__qualname__N)rrrr�rrrrry`sryc	Cs&tjtttttttt	�dS)N)
rZrun_unittestrrTr^rbrkrqruryrrrr�	test_mainys
r��__main__)r'rrJZunittestr
ZTestCaserrrTr^rbrkr5rprqruryr�rrrrr�<module>s"
�)