Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/mock/tests/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/mock/tests/__pycache__/testcallable.cpython-35.pyc



�n�UO�@s�ddlZddlmZmZmZddlmZmZm	Z	m
Z
mZmZm
Z
Gdd�dej�Zedkr�ej�dS)�N)�is_instance�X�	SomeClass)�Mock�	MagicMock�NonCallableMagicMock�NonCallableMock�patch�create_autospec�
CallableMixinc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�TestCallablecCs0|jt|t��|jt|t��dS)N)�
assertTruerr�assertFalser)�self�mock�r�H/opt/alt/python35/lib/python3.5/site-packages/mock/tests/testcallable.py�assertNotCallableszTestCallable.assertNotCallablecCscx\t�t�fD]H}|jt|�|jt|d��|j|jjt	|��qWdS)N�__call__)
rr�assertRaises�	TypeErrorr�hasattr�assertIn�	__class__�__name__�repr)rrrrr�test_non_callableszTestCallable.test_non_callablecCs0|jttt��|jttt��dS)N)r
�
issubclassrrrr)rrrr�test_heirarchyszTestCallable.test_heirarchycCsTt�}|jtt|j�t��t�}|jtt|j�t��dS)N)	rr
r�type�onerr�twor)rr r!rrr�test_attributes#s		zTestCallable.test_attributescCs�Gdd�dt�}|�}|jtt|j�|��Gdd�dt�}|�}|jtt|j�|��dS)Nc@seZdZdS)z-TestCallable.test_subclasses.<locals>.MockSubN)r�
__module__�__qualname__rrrr�MockSub,sr%c@seZdZdS)z.TestCallable.test_subclasses.<locals>.MagicSubN)rr#r$rrrr�MagicSub2sr&)rr
rrr rr!)rr%r r&r!rrr�test_subclasses+s		zTestCallable.test_subclassescCsftdtdd�}|j�}|j|j�|�}|j�|j|�|jt|�dS)Nz%s.X�specT)	r	r�start�
addCleanup�stop�assert_called_once_withrrr)r�patcherr�instancerrr�test_patch_spec9s	

zTestCallable.test_patch_speccCsftdtdd�}|j�}|j|j�|�}|j�|j|�|jt|�dS)Nz%s.X�spec_setT)	r	rr)r*r+r,rrr)rr-rr.rrr�test_patch_spec_setEs	

z TestCallable.test_patch_spec_setcCsVtdtdt��}|j�}|j|j�|j|�|jt|�dS)Nz%s.Xr()	r	rrr)r*r+rrr)rr-rrrr�test_patch_spec_instanceQs

z%TestCallable.test_patch_spec_instancecCsVtdtdt��}|j�}|j|j�|j|�|jt|�dS)Nz%s.Xr0)	r	rrr)r*r+rrr)rr-rrrr�test_patch_spec_set_instanceZs

z)TestCallable.test_patch_spec_set_instancecCsdGdd�dt�}Gdd�d|�}Gdd�dt|�}Gdd�d�}Gd	d
�d
|�}x�dD]�}x�|||||fD]�}td
t||i���}|�}	|j�|jt|	t��|jt	t
|	d�|	�}
|	j�|
ddd�|
jddd�|
jddd�|
jjddd�WdQRXq�WquWdS)Nc@seZdZdd�ZdS)z>TestCallable.test_patch_spec_callable_class.<locals>.CallableXcSsdS)Nr)rrrrreszGTestCallable.test_patch_spec_callable_class.<locals>.CallableX.__call__N)rr#r$rrrrr�	CallableXdsr4c@seZdZdS)z8TestCallable.test_patch_spec_callable_class.<locals>.SubN)rr#r$rrrr�Subhsr5c@seZdZdS)z:TestCallable.test_patch_spec_callable_class.<locals>.MultiN)rr#r$rrrr�Multiksr6c@seZdZdd�ZdS)z=TestCallable.test_patch_spec_callable_class.<locals>.OldStylecSsdS)Nr)rrrrroszFTestCallable.test_patch_spec_callable_class.<locals>.OldStyle.__call__N)rr#r$rrrrr�OldStylensr7c@seZdZdS)z@TestCallable.test_patch_spec_callable_class.<locals>.OldStyleSubN)rr#r$rrrr�OldStyleSubrsr8r(r0z%s.XZ	foobarbaz���)r(r0)rrr	rr,r
rrr�AttributeError�getattrZfoo)rr4r5r6r7r8�argZKlassrr.�resultrrr�test_patch_spec_callable_classcs&
	
	
z+TestCallable.test_patch_spec_callable_classcCsHtt�}|�}|jt|�tt��}|jt|�dS)N)r
rrr)rrr.rrr�test_create_autospec�s
	z!TestCallable.test_create_autospeccCsVttdd�}|jt|�|j�|jj�|jt|jdd�dS)Nr.TZsome�args)r
rrrZwibbler,)rrrrr�test_create_autospec_instance�s


z*TestCallable.test_create_autospec_instanceN)rr#r$rrrr"r'r/r1r2r3r@rArCrrrrrs		'	r�__main__)Z	unittest2�unittestZmock.tests.supportrrrrrrrrr	r
r�TestCaserr�mainrrrr�<module>s
4�