Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib64/python3.6/unittest/test/testmock/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/unittest/test/testmock/__pycache__/testcallable.cpython-36.pyc

3

� f��@sfddlZddlmZmZmZddlmZmZmZm	Z	m
Z
mZmZGdd�dej
�Zedkrbej�dS)�N)�is_instance�X�	SomeClass)�Mock�	MagicMock�NonCallableMagicMock�NonCallableMock�patch�create_autospec�
CallableMixinc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�TestCallablecCs$|jt|t��|jt|t��dS)N)�
assertTruerr�assertFalser)�self�mock�r�H/opt/alt/python36/lib64/python3.6/unittest/test/testmock/testcallable.py�assertNotCallableszTestCallable.assertNotCallablecCsJxDt�t�fD]4}|jt|�|jt|d��|j|jjt	|��qWdS)N�__call__)
rr�assertRaises�	TypeErrorr�hasattrZassertIn�	__class__�__name__�repr)rrrrr�test_non_callableszTestCallable.test_non_callablecCs$|jttt��|jttt��dS)N)r
�
issubclassrrrr)rrrr�test_hierarchyszTestCallable.test_hierarchycCs<t�}|jtt|j�t��t�}|jtt|j�t��dS)N)	rr
r�type�onerr�twor)rrr rrr�test_attributes#szTestCallable.test_attributescCs\Gdd�dt�}|�}|jtt|j�|��Gdd�dt�}|�}|jtt|j�|��dS)Nc@seZdZdS)z-TestCallable.test_subclasses.<locals>.MockSubN)r�
__module__�__qualname__rrrr�MockSub,sr$c@seZdZdS)z.TestCallable.test_subclasses.<locals>.MagicSubN)rr"r#rrrr�MagicSub2sr%)rr
rrrrr )rr$rr%r rrr�test_subclasses+szTestCallable.test_subclassescCsLtdtdd�}|j�}|j|j�|�}|j�|j|�|jt|�dS)Nz%s.XT)�spec)	r	r�start�
addCleanup�stop�assert_called_once_withrrr)r�patcherr�instancerrr�test_patch_spec9s
zTestCallable.test_patch_speccCsLtdtdd�}|j�}|j|j�|�}|j�|j|�|jt|�dS)Nz%s.XT)�spec_set)	r	rr(r)r*r+rrr)rr,rr-rrr�test_patch_spec_setEs
z TestCallable.test_patch_spec_setcCs@tdtt�d�}|j�}|j|j�|j|�|jt|�dS)Nz%s.X)r')	r	rrr(r)r*rrr)rr,rrrr�test_patch_spec_instanceQs

z%TestCallable.test_patch_spec_instancecCs@tdtt�d�}|j�}|j|j�|j|�|jt|�dS)Nz%s.X)r/)	r	rrr(r)r*rrr)rr,rrrr�test_patch_spec_set_instanceZs

z)TestCallable.test_patch_spec_set_instancec	Cs�Gdd�dt�}Gdd�d|�}Gdd�dt|�}x�dD]�}x�|||fD]�}td	tf||i��z}|�}|j�|jt|t��|jt	t
|d
�|�}|j�|ddd
�|jddd
�|jddd
�|jjddd
�WdQRXqHWq8WdS)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�	CallableXdsr3c@seZdZdS)z8TestCallable.test_patch_spec_callable_class.<locals>.SubN)rr"r#rrrr�Subhsr4c@seZdZdS)z:TestCallable.test_patch_spec_callable_class.<locals>.MultiN)rr"r#rrrr�Multiksr5r'r/z%s.XZ	foobarbaz���)r'r/)rrr	rr+r
rrr�AttributeError�getattrZfoo)	rr3r4r5�argZKlassrr-�resultrrr�test_patch_spec_callable_classcs"

z+TestCallable.test_patch_spec_callable_classcCs4tt�}|�}|jt|�tt��}|jt|�dS)N)r
rrr)rrr-rrr�test_create_autospec�s

z!TestCallable.test_create_autospeccCs@ttdd�}|jt|�|j�|jj�|jt|jdd�dS)NT)r-Zsome�args)r
rrrZwibbler+)rrrrr�test_create_autospec_instance�s

z*TestCallable.test_create_autospec_instanceN)rr"r#rrrr!r&r.r0r1r2r=r>r@rrrrrs		 	r�__main__)ZunittestZunittest.test.testmock.supportrrrZ
unittest.mockrrrrr	r
rZTestCaserr�mainrrrr�<module>s$