Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/unittest/test/testmock/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/unittest/test/testmock/__pycache__/testpatch.cpython-39.opt-1.pyc

a

��g��@sddlZddlZddlmZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
mZmZmZmZmZmZmZmZmZmZdZejeZdeZdd
d�Zejaej Z!Gdd
�d
e"�Z#deZ$e#fdd�Z%Gdd�de"�Z&Gdd�dej'�Z(edk�re�)�dS)�N)�OrderedDict)�support)�	SomeClass�is_instance)�uncache)�NonCallableMock�
CallableMixin�sentinel�	MagicMock�Mock�NonCallableMagicMock�patch�_patch�DEFAULT�call�_get_target�builtinsz%s.PTModuleTcsBG�fdd�dt�}|s<�fdd�}�fdd�}||_||_|�S)NcseZdZ�fdd�ZdS)z_get_proxy.<locals>.Proxycs
t�|�S�N)�getattr��self�name��obj��</usr/local/lib/python3.9/unittest/test/testmock/testpatch.py�__getattr__sz%_get_proxy.<locals>.Proxy.__getattr__N)�__name__�
__module__�__qualname__rrrrr�Proxysr cst�||�dSr)�setattr�rr�valuerrr�__setattr__ sz_get_proxy.<locals>.__setattr__cst�|�dSr)�delattrrrrr�__delattr__"sz_get_proxy.<locals>.__delattr__)�objectr$r&)r�get_onlyr r$r&rrr�
_get_proxysr)c@sPeZdZdd�Zdd�Zdd�ZdZedd	��Ze	d
d��Z
Gdd
�d
e�ZdS)�FoocCsdSrr�r�arrr�__init__/�zFoo.__init__cCsdSrrr+rrr�f0r.zFoo.fcCsdSrr�rrrr�g1r.zFoo.g�barcCsdSrrrrrr�
static_method4szFoo.static_methodcCsdSrr)�clsrrr�class_method7szFoo.class_methodc@seZdZdd�ZdS)zFoo.BarcCsdSrrr0rrrr,;r.z	Foo.Bar.aN�rrrr,rrrr�Bar:sr7N)
rrrr-r/r1�foo�staticmethodr3�classmethodr5r'r7rrrrr*.s

r*z%s.FoocCsdSrr�r,�brrr�function@r.r=c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�	ContainercCs
i|_dSr��valuesr0rrrr-DszContainer.__init__cCs
|j|Srr?rrrr�__getitem__GszContainer.__getitem__cCs||j|<dSrr?r"rrr�__setitem__JszContainer.__setitem__cCs|j|=dSrr?rrrr�__delitem__MszContainer.__delitem__cCs
t|j�Sr)�iterr@r0rrr�__iter__PszContainer.__iter__N)rrrr-rArBrCrErrrrr>Cs
r>c@s�eZdZd�dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dHdI�Z&dJdK�Z'dLdM�Z(dNdO�Z)dPdQ�Z*dRdS�Z+dTdU�Z,dVdW�Z-dXdY�Z.dZd[�Z/d\d]�Z0d^d_�Z1d`da�Z2dbdc�Z3ddde�Z4dfdg�Z5dhdi�Z6djdk�Z7dldm�Z8dndo�Z9dpdq�Z:drds�Z;dtdu�Z<dvdw�Z=dxdy�Z>dzd{�Z?d|d}�Z@d~d�ZAd�d��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXeYd�d��d�d���ZZeYd�d��d�d���Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d„Zbd�dĄZcd�dƄZdd�dȄZed�dʄZfd�d̄Zgd�d΄Zhd�dЄZid�d҄Zjd�dԄZkd�dքZld�d؄Zmd�dڄZnd�d܄Zod�dބZpd�S)��	PatchTestTcCs<t}|st}|�t|�|�t||��|�t|t��dSr)rr�assertRaises�	TypeError�
assertTruer�assertFalser)rr�magic�	MockClassrrr�assertNotCallableWszPatchTest.assertNotCallablecsJGdd�dt��t��dtj���fdd��}|����jtjd�dS)Nc@seZdZejZdS)z4PatchTest.test_single_patchobject.<locals>.SomethingN�rrrr	�Original�	attributerrrr�	SomethingbsrQrPcs���jtjd�dS�NZ	unpatched��assertEqualrPr	�Patchedr�rQrrr�testesz/PatchTest.test_single_patchobject.<locals>.test�patch not restored�r'r
r	rUrTrPrO�rrWrrVr�test_single_patchobjectas�z!PatchTest.test_single_patchobjectcCs@d}|�t|��t�dd�Wd�n1s20YdS)Nz>'Something' must be the actual object to be patched, not a strrQZdo_something)ZassertRaisesRegexrHr
r')r�msgrrr�&test_patchobject_with_string_as_targetmsz0PatchTest.test_patchobject_with_string_as_targetcsHGdd�dt��t��dd���fdd��}|����jtjd�dS)Nc@seZdZejZdS)z7PatchTest.test_patchobject_with_none.<locals>.SomethingNrNrrrrrQssrQrPcs���jd�dSrR)�assertIsNonerPrrVrrrWvsz2PatchTest.test_patchobject_with_none.<locals>.testrX)r'r
rTrPr	rOrZrrVr�test_patchobject_with_noners�z$PatchTest.test_patchobject_with_nonecslGdd�dt��t��dtj�t��dtj���fdd���}|����jtjd����jtj	d�dS)Nc@seZdZejZejZdS)z6PatchTest.test_multiple_patchobject.<locals>.SomethingN�rrrr	rOrP�	Original2�next_attributerrrrrQ�srQrPrbcs(���jtjd����jtjd�dSrR)rTrPr	rUrb�Patched2rrVrrrW�s��z1PatchTest.test_multiple_patchobject.<locals>.testrX)
r'r
r	rUrcrTrPrOrbrarZrrVr�test_multiple_patchobjects��z#PatchTest.test_multiple_patchobjectcCsJt}tdttj�dd��}z"tja|�|�ttj�W|an|a0dS)N�%s.somethingcSsdSrrrrrrrW�sz8PatchTest.test_object_lookup_is_quite_lazy.<locals>.test)�	somethingr
rr	�
Something2Zreplacement_valuerT�r�originalrWrrr� test_object_lookup_is_quite_lazy�s
z*PatchTest.test_object_lookup_is_quite_lazycs�tdttj��fdd��}|���tjtjd�tdttj�tdttj��fdd���}��tjtjd���tj	tjd�|���tjtjd���tj	tjd�t
�}tj|_tdt
|��fdd��}|�|���t|d�dS)	Nrecs��tjtjd�dSrR)rT�PTModulerfr	rgrr0rrrW�s�z"PatchTest.test_patch.<locals>.testrXz%s.something_elsecs(��tjtjd���tjtjd�dSrR)rTrkrfr	rg�something_else�
SomethingElserr0rrrW�s���%s.opencs��tdd�tjd�dS)N�filename�rzopen not patched)rT�openr	�Handlerr0rrrW�s�)r
rr	rgrTrkrfrQrmrlrrr�return_value�builtin_string�assertNotEqualrq)rrW�mockrr0r�
test_patch�s:�����zPatchTest.test_patchcs6tdttj��fdd��}|���tjjd�dS)Nz%s.SomeClass.class_attributecs��tjjtjd�dSrR)rTrkr�class_attributer	�ClassAttributerr0rrrW�s
�z2PatchTest.test_patch_class_attribute.<locals>.testrX)r
rr	ryr^rkrrxrZrr0r�test_patch_class_attribute�s�
�z$PatchTest.test_patch_class_attributecs�Gdd�dt��t��d���fdd��}|�t��d�t��d�����fdd���}d��|tjtj�\��|tjtj�dS)Nc@seZdZejZejZdS)z:PatchTest.test_patchobject_with_default_mock.<locals>.TestN)rrrr	rOrfra�
something2rrrr�Test�sr|rfcs"��|�jd���|td�dS)N�"Mock not passed into test function�.patch with two arguments did not create a mock)rTrf�assertIsInstancer
�rv)r|rrrrW�s
��z:PatchTest.test_patchobject_with_default_mock.<locals>.testr{cs���|tjd���|tjd���|�jd���|�jd���|td���|td����|d����|d�||fS)Nz0Patched function didn't receive initial argumentz/Patched function didn't receive second argumentr}z)Second Mock not passed into test functionr~zunexpected value for mock1)	rTr	�this1�this2r{rfrr
ru)r�r�Zmock1Zmock2�r|Z
outerMock1Z
outerMock2rrrrW�s*
�
�
�
���)r'r
r	r�r�rZrr�r�"test_patchobject_with_default_mock�s


z,PatchTest.test_patchobject_with_default_mockcs&tdttd��fdd��}|�dS)N�%s.SomeClass��speccs2��t|���ttjt����tdd��dS)NcSstjSr�r�
not_wibblerrrr�<lambda>r.z>PatchTest.test_patch_with_spec.<locals>.test.<locals>.<lambda>�rTrrIr�wibbler
rG�AttributeError��
MockSomeClassr0rrrWsz,PatchTest.test_patch_with_spec.<locals>.test)r
rrrZrr0r�test_patch_with_specszPatchTest.test_patch_with_speccs&tjtdtd��fdd��}|�dS)Nrxr�cs6��tj|���ttjjt����tdd��dS)NcSstjjSr�rrxr�rrrrr�r.zDPatchTest.test_patchobject_with_spec.<locals>.test.<locals>.<lambda>�	rTrrxrIrr�r
rGr��Z
MockAttributer0rrrWs��z2PatchTest.test_patchobject_with_spec.<locals>.test�r
r'rrZrr0r�test_patchobject_with_spec
sz$PatchTest.test_patchobject_with_speccs(tdtdgd��fdd��}|�dS)Nr�r�r�cs2��t|���ttjt����tdd��dS)NcSstjSrr�rrrrr�r.zFPatchTest.test_patch_with_spec_as_list.<locals>.test.<locals>.<lambda>r�r�r0rrrWsz4PatchTest.test_patch_with_spec_as_list.<locals>.test�r
rrZrr0r�test_patch_with_spec_as_listsz&PatchTest.test_patch_with_spec_as_listcs(tjtddgd��fdd��}|�dS)Nrxr�r�cs6��tj|���ttjjt����tdd��dS)NcSstjjSrr�rrrrr�*r.zLPatchTest.test_patchobject_with_spec_as_list.<locals>.test.<locals>.<lambda>r�r�r0rrrW$s��z:PatchTest.test_patchobject_with_spec_as_list.<locals>.testr�rZrr0r�"test_patchobject_with_spec_as_list#sz,PatchTest.test_patchobject_with_spec_as_listcs4tdt�tdtdgd��fdd���}|�dS)Nrnr�r�r�cs2��t|���ttjt����tdd��dS)NcSstjSrr�rrrrr�6r.zMPatchTest.test_nested_patch_with_spec_as_list.<locals>.test.<locals>.<lambda>r�)r�ZMockOpenr0rrrW1sz;PatchTest.test_nested_patch_with_spec_as_list.<locals>.test)r
rtrrZrr0r�#test_nested_patch_with_spec_as_list/s
z-PatchTest.test_nested_patch_with_spec_as_listcs&tdtdd��fdd��}|�dS)Nr�Tr�cs*��t���j��t�fdd��dS)Ncs�jSr�r�rr�rrr�Ar.zIPatchTest.test_patch_with_spec_as_boolean.<locals>.test.<locals>.<lambda>�rTrr�rGr�r�r0r�rrW;sz7PatchTest.test_patch_with_spec_as_boolean.<locals>.testr�rZrr0r�test_patch_with_spec_as_boolean:sz)PatchTest.test_patch_with_spec_as_booleancs&tjtddd��fdd��}|�dS)NrTr�cs*��t���j��t�fdd��dS)Ncs�jSrr�rr�rrr�Mr.zPPatchTest.test_patch_object_with_spec_as_boolean.<locals>.test.<locals>.<lambda>r�r�r0r�rrWGsz>PatchTest.test_patch_object_with_spec_as_boolean.<locals>.test)r
r'rkrZrr0r�&test_patch_object_with_spec_as_booleanFsz0PatchTest.test_patch_object_with_spec_as_booleancs&tdtdd��fdd��}|�dS)Nr�Tr�cs>��t|t��|�������j��t�fdd��dS)Ncs�jSrr�r��instancerrr�[r.zVPatchTest.test_patch_class_acts_with_spec_is_inherited.<locals>.test.<locals>.<lambda>)rIrr
rMr�rGr�r�r0r�rrWSs

zDPatchTest.test_patch_class_acts_with_spec_is_inherited.<locals>.testr�rZrr0r�,test_patch_class_acts_with_spec_is_inheritedRs	z6PatchTest.test_patch_class_acts_with_spec_is_inheritedcs:tdttjdd��fdd��}|���tdd��dS)N�
%s.froobleT��createcs��ttj�dSr)rT�froobler	�Frooblerr0rrrWaszLPatchTest.test_patch_with_create_mocks_non_existent_attributes.<locals>.testcSstSr�r�rrrrr�fr.zPPatchTest.test_patch_with_create_mocks_non_existent_attributes.<locals>.<lambda>)r
rtr	r�rG�	NameErrorrZrr0r�4test_patch_with_create_mocks_non_existent_attributes`sz>PatchTest.test_patch_with_create_mocks_non_existent_attributescs:tjtdtjdd��fdd��}|���ttd��dS)Nr�Tr�cs��tjtj�dSr)rTrr�r	r�rr0rrrWjszRPatchTest.test_patchobject_with_create_mocks_non_existent_attributes.<locals>.test)r
r'rr	r�rJ�hasattrrZrr0r�:test_patchobject_with_create_mocks_non_existent_attributesiszDPatchTest.test_patchobject_with_create_mocks_non_existent_attributescCs\|�t��.tdttj�dd��}|�Wd�n1s>0Y|�tdd��dS)Nr�cSsdSrrrrrrrWtsz9PatchTest.test_patch_wont_create_by_default.<locals>.testcSstSrr�rrrrr�xr.z=PatchTest.test_patch_wont_create_by_default.<locals>.<lambda>)rGr�r
rtr	r�r�rZrrr�!test_patch_wont_create_by_defaultrs

$z+PatchTest.test_patch_wont_create_by_defaultcCs\|�t��.t�tdtj�dd��}|�Wd�n1s>0Y|�ttd��dS)N�ordcSsdSrrrrrrrW}sz?PatchTest.test_patchobject_wont_create_by_default.<locals>.test)	rGr�r
r'rr	r�rJr�rZrrr�'test_patchobject_wont_create_by_default{s

$z1PatchTest.test_patchobject_wont_create_by_defaultcCsHttd�dd��}ttd�dd��}|�|�d�|�|�d�dS)	Nz.ordcSsd|_td�S)N�e�c)rsr�)Zmock_ordrrr�test_ord�sz>PatchTest.test_patch_builtins_without_create.<locals>.test_ordz.opencSs*|j}d|j_td�}|��}|��|S)N�abcdzdoesnotexists.txt)rs�readrq�close)Z	mock_open�mZfobj�datarrr�	test_open�sz?PatchTest.test_patch_builtins_without_create.<locals>.test_openr�r��r
rrT)rr�r�rrr�"test_patch_builtins_without_create�s



	z,PatchTest.test_patch_builtins_without_createcsPGdd�dt��t��dtdd�����fdd��}|������tj�dS)Nc@seZdZedd��ZdS)z5PatchTest.test_patch_with_static_methods.<locals>.FoocSstjSr)r	�Staticrrrr�woot�sz:PatchTest.test_patch_with_static_methods.<locals>.Foo.wootN)rrrr9r�rrrrr*�sr*r�cSstjSr)r	rUrrrrr��r.z:PatchTest.test_patch_with_static_methods.<locals>.<lambda>cs�����tj�dSr)rTr�r	rUr�r*rrr�	anonymous�sz;PatchTest.test_patch_with_static_methods.<locals>.anonymous)r'r
r9rTr�r	r�)rr�rr�r�test_patch_with_static_methods�s
z(PatchTest.test_patch_with_static_methodscs8tj}t�tdd��fdd��}|���tj|�dS)Nr*cs��tjd�dS�Nr*)rTr	r*rr0rrr��sz-PatchTest.test_patch_local.<locals>.anonymous)r	r*r
r'rT)rr8r�rr0r�test_patch_local�s
zPatchTest.test_patch_localcsTGdd�dt�}|��tj�_t��dd���fdd��}|����jtj�dS)Nc@seZdZdZdS)z'PatchTest.test_patch_slots.<locals>.Foo)r*N)rrr�	__slots__rrrrr*�sr*cs���jd�dSr�)rTr*r�r8rrrr��sz-PatchTest.test_patch_slots.<locals>.anonymous)r'r	r*r
rT)rr*r�rr�r�test_patch_slots�szPatchTest.test_patch_slotscsfGdd�dt��G��fdd�dt�}t��dtj�|�}|�}|��|�����jtjd�dS)Nc@seZdZejZdS)z=PatchTest.test_patchobject_class_decorator.<locals>.SomethingNrNrrrrrQ�srQcs(eZdZ��fdd�Z��fdd�ZdS)z7PatchTest.test_patchobject_class_decorator.<locals>.Foocs���jtjd�dSrRrS��
other_selfrVrr�test_method�s�zCPatchTest.test_patchobject_class_decorator.<locals>.Foo.test_methodcs���jtjd�dS�Nznon-test method patched)rTrPr	rOr�rVrr�not_test_method�s�zGPatchTest.test_patchobject_class_decorator.<locals>.Foo.not_test_methodN)rrrr�r�rrVrrr*�sr*rPrX)	r'r
r	rUr�r�rTrPrO)rr*r/rrVr� test_patchobject_class_decorator�s�z*PatchTest.test_patchobject_class_decoratorcsrGdd�dt�}G�fdd�dt�}tdt�|�}|�}|��|����|jtjd���t	j
tjd�dS)Nc@seZdZejZdS)z7PatchTest.test_patch_class_decorator.<locals>.SomethingNrNrrrrrQ�srQcs(eZdZdZ�fdd�Z�fdd�ZdS)z1PatchTest.test_patch_class_decorator.<locals>.FooZwhatevercs��tj|d�dSrR)rTrkrf)r�Zmock_somethingr0rrr��s
�z=PatchTest.test_patch_class_decorator.<locals>.Foo.test_methodcs��tjtjd�dSr�)rTrkrfr	rQr�r0rrr��s�zAPatchTest.test_patch_class_decorator.<locals>.Foo.not_test_methodN)rrrZtest_class_attrr�r�rr0rrr*�sr*rerX)r'r
rr�r�rTrPr	rOrkrfrQ)rrQr*r/rr0r�test_patch_class_decorator�s
��z$PatchTest.test_patch_class_decoratorcsZGdd�dt��t��dtj�t��dtj���fdd���}|����jtjd�dS)Nc@seZdZejZejZdS)z3PatchTest.test_patchobject_twice.<locals>.SomethingNr`rrrrrQ�srQrPcs���jtjd�dSrRrSrrVrrrW�sz.PatchTest.test_patchobject_twice.<locals>.testrXrYrZrrVr�test_patchobject_twice�s�z PatchTest.test_patchobject_twicecs�t�dd�����}t����fdd��}|����|�t��ddi���fdd��}|����|�t��dg���fd	d��}|����|�dS)
Nrf��initial�othercsd�d<�d=d�d<dS�N�r,r��something elser�rr�r8rrrWsz'PatchTest.test_patch_dict.<locals>.testr,r<cs$��t��d����dd�dS�Nr�r,r<�rT�lenrr�rrrWsr;cs$��t��d����dd�dSr�r�rr�rrrWs�r'�copyr
�dictrTrhrr�r�test_patch_dict�szPatchTest.test_patch_dictcs�t��t��d<d�d<�j��}t����fdd��}|����j|�t��ddi���fdd��}|����j|�dS)	Nr�rfr�csd�d<�d=d�d<dSr�rrr�rrrW&sz=PatchTest.test_patch_dict_with_container_object.<locals>.testr,r<cs&��t�j�d����dd�dSr�)rTr�r@rr�rrrW0s�r>r'r@r�r
r�rTrhrr�r�%test_patch_dict_with_container_objects

z/PatchTest.test_patch_dict_with_container_objectcs�t�dd�����}tj�dd���fdd��}|����|�tj�ddidd���fd	d��}|����|�tj�d
gdd���fdd��}|����|�dS)Nrfr�T��clearcs ���i�d�d<d�d<dS�Nr�r,r�r��rTrr�rrrW>sz2PatchTest.test_patch_dict_with_clear.<locals>.testr,r<cs���ddi�dS�Nr,r<r�rr�rrrWHsr;cs���ddi�dSr�r�rr�rrrWPsr�rhrr�r�test_patch_dict_with_clear:sz$PatchTest.test_patch_dict_with_clearcs�t��t��d<d�d<�j��}tj�dd���fdd��}|����j|�tj�dd	idd���fd
d��}|����j|�dS)Nr�rfr�Tr�cs"���ji�d�d<d�d<dSr��rTr@rr�rrrW`szGPatchTest.test_patch_dict_with_container_object_and_clear.<locals>.testr,r<cs���jddi�dSr�r�rr�rrrWjsr�rhrr�r�/test_patch_dict_with_container_object_and_clearYs

z9PatchTest.test_patch_dict_with_container_object_and_clearcCsZddi}tj|dd�� }|�|ddi�Wd�n1s<0Y|�|ddi�dS)Nr,r<r�)r,)r
r�rT)rr8�patchedrrr�"test_patch_dict_as_context_managerss.z,PatchTest.test_patch_dict_as_context_managercCsZi}tdtt��tdtt�dd�t�tt��t�|�dd�����}|�|jd�dS)Nr�T��autospeccSsdSrrrrrr�	some_name}sz0PatchTest.test_name_preserved.<locals>.some_namer�)r
rr'rr�rT)rr8r�rrr�test_name_preservedzszPatchTest.test_name_preservedcCs\i}t�|ddi�dd��}|�t��|�Wd�n1sB0Y|�|i�dS)Nr,r<cSstd��dS)NZKonrad�r�rrrrrW�sz1PatchTest.test_patch_with_exception.<locals>.test)r
r�rGr�rT)rr8rWrrr�test_patch_with_exception�s
$z#PatchTest.test_patch_with_exceptioncs&t�dddi��fdd��}|�dS)Nz
os.environ�
konrad_delongz
some valuecs��dtj�dS)Nr�)�assertIn�os�environrr0rrrW�sz3PatchTest.test_patch_dict_with_string.<locals>.test)r
r�rZrr0r�test_patch_dict_with_string�sz%PatchTest.test_patch_dict_with_stringcs`tj��}t�dddi��fdd��}z,ddit_|���tjddi�W|t_n|t_0dS)Nz%unittest.test.testmock.support.targetr2�BARcs��tjddd��dS)N�BAZr��r8r2)rTr�targetrr0rrrW�sz<PatchTest.test_patch_dict_decorator_resolution.<locals>.testr8r�)rr�r�r
r�rTrhrr0r�$test_patch_dict_decorator_resolution�s

z.PatchTest.test_patch_dict_decorator_resolutioncCs�tdttdd�dd��}|�t|�tjtdtdd�dd��}|�t|�tdtdd�d	d��}|�t|�tjtddd�d
d��}|�t|�dS)Nr�T�r��spec_setcSs
d|_dS�Nr8��z�rLrrrrW�sz+PatchTest.test_patch_spec_set.<locals>.testrcSs
d|_dSr�r�r�rrrrW�s�r�cSs
d|_dSr�r�r�rrrrW�scSs
d|_dSr�r�r�rrrrW�s)r
rrrGr�r'rrZrrr�test_patch_spec_set�s



zPatchTest.test_patch_spec_setcCs(tdtdd�dd��}|�t|�dS)Nr�Tr�cSs|�}d|_dSr�r�)rLr�rrrrW�sz-PatchTest.test_spec_set_inherit.<locals>.test)r
rrGr�rZrrr�test_spec_set_inherit�s
zPatchTest.test_spec_set_inheritcCsdt}tdt�}|�t|�|��}z$|�||�|�t|�W|��n
|��0|�t|�dS)Nre)rfr
r�assertIs�start�assertIsNot�stop)rri�patcherrvrrr�test_patch_start_stop�szPatchTest.test_patch_start_stopcCsttdd�}|�|���dS�Nr2r�)r
�foo_namer^r�rrrrr�test_stop_without_start�sz!PatchTest.test_stop_without_startcCs.ttdd�}|��|��|�|���dSr)r
rr�rr^rrrr�test_stop_idempotent�szPatchTest.test_stop_idempotentcCsft}t�tdd�}|�t|�|��}z$|�|d�|�t|�W|��n
|��0|�t|�dS)Nrfr8)rfr
r'rkr�r�rTr)rrirZreplacedrrr�test_patchobject_start_stop�sz%PatchTest.test_patchobject_start_stopcCsnddi}|��}tj|dgdd�}|�||�|��z|�|ddi�W|��n
|��0|�||�dS)Nr8r2��spam�eggsTr�rr)r�r
r�rTr�r�r�drirrrr�test_patch_dict_start_stop�sz$PatchTest.test_patch_dict_start_stopcCs@ddi}|��}tj|dgdd�}|�|���|�||�dS)Nr8r2r
Tr�)r�r
r�rJrrTr
rrr�"test_patch_dict_stop_without_starts
z,PatchTest.test_patch_dict_stop_without_startcs�|�ddi����}G��fdd�dt�}tj�ddidd�|�}|��|�|�}|��|��|�|��|��|�|�}|��|��|�|��|��|�dS)	Nrrcs(eZdZ��fdd�Z��fdd�ZdS)z7PatchTest.test_patch_dict_class_decorator.<locals>.Testcs���ddi�dS�Nr8r2r�r0�r�thisrr�
test_firstszBPatchTest.test_patch_dict_class_decorator.<locals>.Test.test_firstcs���ddi�dSrr�r0rrr�test_secondszCPatchTest.test_patch_dict_class_decorator.<locals>.Test.test_secondN)rrrrrrrrrr|sr|r8r2Tr�)r�r'r
r�rTrr)rrir|rWrrr�test_patch_dict_class_decorator
s z)PatchTest.test_patch_dict_class_decoratorcs�Gdd�dt�}Gdd�d�}|||�|fD]X}t|��t��dd���fdd��}|����jd���|jd���d�j�q,dS)	Nc@seZdZdZdS)z0PatchTest.test_get_only_proxy.<locals>.Somethingr8N�rrrr8rrrrrQ-srQc@seZdZdZdS)z4PatchTest.test_get_only_proxy.<locals>.SomethingElser8Nrrrrrrm/srmr8r2cs���jd�dS�Nr2�rTr8r��proxyrrrrW5sz+PatchTest.test_get_only_proxy.<locals>.test�r'r)r
rTr8ZassertNotIn�__dict__�rrQrm�thingrWrrr�test_get_only_proxy,szPatchTest.test_get_only_proxycs�Gdd�dt�}Gdd�d�}|||�|fD]\}t|dd��t��dd���fd	d
��}|����jd���|jd���d�j�q,dS)Nc@seZdZdZdS)z6PatchTest.test_get_set_delete_proxy.<locals>.Somethingr8NrrrrrrQ?srQc@seZdZdZdS)z:PatchTest.test_get_set_delete_proxy.<locals>.SomethingElser8NrrrrrrmAsrmF)r(r8r2cs���jd�dSrrrrrrrWGsz1PatchTest.test_get_set_delete_proxy.<locals>.testrrrrr�test_get_set_delete_proxy>sz#PatchTest.test_get_set_delete_proxycCs^tdt�d�}ttfi|��}|��}|��|�t|�|�|j�	�d�|�
|jt�dS)N�!�Zside_effectzfoo.bar.return_valuer8)�KeyErrorr
r
rr�rrGrTr8r2r�r�kwargsrrvrrr�test_patch_keyword_argsPs�z!PatchTest.test_patch_keyword_argscCsbtdt�d�}tjtdfi|��}|��}|��|�t|�|�|j	�
�d�|�|j	t�dS)Nr"r#r/)r$r
r
r'r*r�rrGrTr8r2rr%rrr�test_patch_object_keyword_args]s�z(PatchTest.test_patch_object_keyword_argscCshddi}|��}tj|dddd�}|��z"|�|tdddd��W|��n
|��0|�||�dS)Nr8r2r���)r8r2Zbaz)r�r
r�r�rTr)rrir�rrrr�test_patch_dict_keyword_argsjsz&PatchTest.test_patch_dict_keyword_argscs�Gdd�dt�}�fdd���fdd�����fdd�}ttd	d
�|�}|�}��t|�|�tjt}tj|dd	d
�|�}|�}��t|�|�dS)Nc@s8eZdZdd�Zdd�Zdd�ZdZGdd	�d	e�Zd
S)z$PatchTest.test_autospec.<locals>.BoocSsdSrrr+rrrr-{r.z-PatchTest.test_autospec.<locals>.Boo.__init__cSsdSrrr+rrrr/|r.z&PatchTest.test_autospec.<locals>.Boo.fcSsdSrrr0rrrr1}r.z&PatchTest.test_autospec.<locals>.Boo.gr2c@seZdZdd�ZdS)z(PatchTest.test_autospec.<locals>.Boo.BarcSsdSrrr0rrrr,�r.z*PatchTest.test_autospec.<locals>.Boo.Bar.aNr6rrrrr7�sr7N)	rrrr-r/r1r8r'r7rrrr�Boozs
r,cs"|d�|�d���t|�dS�N�)�assert_called_withrGrHr�r0rr�_test�s
z&PatchTest.test_autospec.<locals>._testcs|�d�|j�d���t|j�|��|j����t|jd���tt|d�|j��|jj����tt|jd�|�	�|j	��|j	�
�|j	j
����t|j	j
d�|�	��
�|�	�j
����t|�	�j
d���tt|j	d���tt|�	�d�dS)Nr.�hr2r<)r/r/rGrHr1r�rr8�lowerr7r,r�r0rr�_test2�s(




z'PatchTest.test_autospec.<locals>._test2cs,�|��|��|d����|t�|Sr-)r�r*r��r0r3rrrr=�s
z)PatchTest.test_autospec.<locals>.functionTr�r*)r'r
rrr*�sys�modulesr)rr,r=rWrv�modulerr4r�
test_autospecys	
zPatchTest.test_autospeccs&tdtdd��fdd��}|�dS)N�%s.functionTr�cs�t����ttj���ttj�td���ttj�t�d�t��t��tdd�t�dd���tt���tt	td�dS)Nr.�r�r8)
r=Zassert_not_calledrG�AssertionErrorZ
assert_calledZassert_called_oncer/rHr�rr�r0rrrW�s

z.PatchTest.test_autospec_function.<locals>.testr�rZrr0r�test_autospec_function�sz PatchTest.test_autospec_functioncCs0tdtddd�dd��}|�}|�|d�dS)Nr9Tr�)r�rscSs
tdd�S)Nr.r:)r=)Z
mock_functionrrrrW�sz.PatchTest.test_autospec_keywords.<locals>.testr�)rrW�resultrrr�test_autospec_keywords�s
�
z PatchTest.test_autospec_keywordscCsDtdtdd�� }t��|��Wd�n1s60YdS)Nz%s.Foo.static_methodTr�)r
rr*r3�assert_called_once_with�r�methodrrr�test_autospec_staticmethod�sz$PatchTest.test_autospec_staticmethodcCsDtdtdd�� }t��|��Wd�n1s60YdS)Nz%s.Foo.class_methodTr�)r
rr*r5r?r@rrr�test_autospec_classmethod�sz#PatchTest.test_autospec_classmethodcCsNtdtddd�}|�t|j�tjt}tj|dddd�}|�t|j�dS)Nr9r�T)�newr�r=)r
rrGrHr�r5r6r')rrr7rrr�test_autospec_with_new�s

z PatchTest.test_autospec_with_newcCsZGdd�dt�}tt|d�}|��}z&|�||�|�|jt�W|��n
|��0dS)Nc@seZdZgZdS)z0PatchTest.test_autospec_with_object.<locals>.BarN)rrr�extrarrrrr7�sr7r�)r*r
rr�rrF�listr)rr7rrvrrr�test_autospec_with_object�sz#PatchTest.test_autospec_with_objectcCsPt}ttdd�}|��}z(|�||�|�|d�|�W|��n
|��0dS)NTr�r�)r*r
rr�rr)rZFooClassrrvrrr�test_autospec_inherits�sz PatchTest.test_autospec_inheritscCs|ttdd�}|��}zX|�dt|��|�dt|j��|�dt|d���|�dt|d�j��W|��n
|��0dS)NTr�z name='Foo'z
 name='Foo.f'z
 name='Foo()'z name='Foo().f')r
rr�r��reprr/r)rrrvrrr�test_autospec_nameszPatchTest.test_autospec_namecCsbt�tdt��dd��}z
|�Wnt��}Yn0t�ddd�}|�||�}|�d|�dS)Nr/cSst�dSr)r;rrrrrWsz'PatchTest.test_tracebacks.<locals>.testrzraise AssertionError)	r
r'r*r5�exc_info�unittestZTextTestResultZ_exc_info_to_stringr�)rrW�errr=�	tracebackrrr�test_tracebackss

zPatchTest.test_tracebackscCsTtttd�}|��}|��|��}|��|�||�||fD]}|�|�q@dS)N��new_callable)r
rrr�rrrM�rrZm1Zm2rvrrr�test_new_callable_patch#sz!PatchTest.test_new_callable_patchcCsXtjtdtd�}|��}|��|��}|��|�||�||fD]}|�|�qDdS)Nr/rQ)r
r'r*rr�rrrMrSrrr�test_new_callable_patch_object0sz(PatchTest.test_new_callable_patch_objectcsnG�fdd�dt��tt�ddd�}|��}z2|�t|���|��jtddd��W|�	�n
|�	�0dS)NcseZdZdZ�fdd�ZdS)z:PatchTest.test_new_callable_keyword_arguments.<locals>.BarNcs
|�_dSr�r&�rr&�r7rrr-@szCPatchTest.test_new_callable_keyword_arguments.<locals>.Bar.__init__�rrrr&r-rrXrrr7>sr7r.r:)rR�arg1�arg2)rZr[)
r'r
rr�r��typerTr&r�r)rrr�rrXr�#test_new_callable_keyword_arguments=sz-PatchTest.test_new_callable_keyword_argumentscs�G�fdd�dt��tt��d�}|��z |��jt�d��W|��n
|��0tt��d�}|��z |��jt�d��W|��n
|��0dS)NcseZdZdZ�fdd�ZdS)z-PatchTest.test_new_callable_spec.<locals>.BarNcs
|�_dSrrVrWrXrrr-Osz6PatchTest.test_new_callable_spec.<locals>.Bar.__init__rYrrXrrr7Msr7�rRr�r�)rRr�r�)r'r
rr�rTr&r�rrrrXr�test_new_callable_specLsz PatchTest.test_new_callable_speccCsbdt}t|td�}|�t|j�t|tdd�}|��}z|j|dd�W|��n
|��0dS)Nz	%s.weeeeerQT)rRr�F)rK)rr
rrGr�r�rMr)rZnon_existent_attr�pr�rrr�test_new_callable_createas�z"PatchTest.test_new_callable_createcCs4|jtttt�td�|jttjtdt�td�dS)N)rDrRr/)rG�
ValueErrorr
rr'r
r*r0rrr�'test_new_callable_incompatible_with_newos��z1PatchTest.test_new_callable_incompatible_with_newcCs0|jttttdd�|jttjtdtdd�dS)NT)rRr�r/)rGrbr
rr
r'r*r0rrr�,test_new_callable_incompatible_with_autospecys��z6PatchTest.test_new_callable_incompatible_with_autospecc	
Cs�Gdd�dt�}tttt|f}|D]`}dD]V}|di}ttfd|i|��}|��}z"|j}|�t	t
|d�W|��q*|��0q*q"dS)Nc@seZdZdS)z>PatchTest.test_new_callable_inherit_for_mocks.<locals>.MockSubN�rrrrrrr�MockSub�srfr�TrR�x)rrrr
r
rr�rsrGr�rr)	rrfZMockClassesZKlass�argr&r`r�r�rrr�#test_new_callable_inherit_for_mocks�s
�z-PatchTest.test_new_callable_inherit_for_mockscCspGdd�dt�}tt|dd�}|��}z,|�t||��|�tt|d�W|�	�n
|�	�0|�
|jt�dS)Nc@seZdZdd�ZdS)z>PatchTest.test_new_callable_inherit_non_mock.<locals>.NotAMockcSs
||_dSrr�)rr�rrrr-�szGPatchTest.test_new_callable_inherit_non_mock.<locals>.NotAMock.__init__N)rrrr-rrrr�NotAMock�srjTr^rs)
r'r
rr�rIrrGr�rrrTr�r*)rrjr`r�rrr�"test_new_callable_inherit_non_mock�sz,PatchTest.test_new_callable_inherit_non_mockcsR|�t�G��fdd�dt�}tttd�|�}|���|���|�t��dS)Ncs*eZdZ��fdd�Zdd�Zdd�ZdS)z>PatchTest.test_new_callable_class_decorating.<locals>.SomeTestcs(��t����t|���tt�dSr)rr*r�rr�rZmock_foo�rirWrrr0�szDPatchTest.test_new_callable_class_decorating.<locals>.SomeTest._testcSs|�|�dSr�r0rlrrr�test_two�szGPatchTest.test_new_callable_class_decorating.<locals>.SomeTest.test_twocSs|�|�dSrrnrlrrr�test_one�szGPatchTest.test_new_callable_class_decorating.<locals>.SomeTest.test_oneN�rrrr0rorprrmrr�SomeTest�srrrQ)r*r'r
rrrpror�)rrrrrmr�"test_new_callable_class_decorating�s

z,PatchTest.test_new_callable_class_decoratingc	s�t�tj}tj}tjtddd�}tjtddd�}||fD]t}|��z4��t����tjd���tjd�W|�	�n
|�	�0��t����tj|���tj|�q8tjtddd���fdd��}|�dS)Nr.r:)r/r1r�r)cs,��t����tjd���tjd�dS)Nr�r))r�r*rTr/r1r��original_foorrrrW�sz+PatchTest.test_patch_multiple.<locals>.test)
r*r/r1r
�multiplerr�r�rTr)r�
original_f�
original_gZpatcher1Zpatcher2rrWrrtr�test_patch_multiple�s$zPatchTest.test_patch_multiplecCs$|�ttjt�|�ttjt�dSr)rGrbr
rvrr*r0rrr�test_patch_multiple_no_kwargs�sz'PatchTest.test_patch_multiple_no_kwargscsVt�tj}tj}tjttdtd���fdd��}|���tj|���tj|�dS)Nr��r/r1r8csZ��t����tj|���tjd���tj|���t|t����t|t��dS�Nr��	r�r*r/rTr1r8rIrr
)r/r8rtrrrW�sz8PatchTest.test_patch_multiple_create_mocks.<locals>.test�r*r/r1r
rvrrrT)rrwrxrWrrtr� test_patch_multiple_create_mocks�sz*PatchTest.test_patch_multiple_create_mockscsrtj}tj}t�tdd�}d|_t�tdt�}d|_|g|_|�fdd��}|���tj|���tj|�dS)Nr/r�r1cs ��tj|���tjd�dSr|)r�r*r1rTr/)r1r0rrrW�szHPatchTest.test_patch_multiple_create_mocks_different_order.<locals>.test)	r*r/r1r
r'�attribute_namer�additional_patchersrT)rrwrxrr�rWrr0r�0test_patch_multiple_create_mocks_different_order�sz:PatchTest.test_patch_multiple_create_mocks_different_ordercs�t�tj}tj}tjttd�tjttd�ttd��fdd����}tjttd�ttd�tjttd��fdd����}ttd�tjttd�tjttd��fdd	����}��fd
d��|�|�|���tj|���tj|�dS)N)r/r�z.gcs�|fi|��dSrr�r1r&rnrr�test1
sz?PatchTest.test_patch_multiple_stacked_decorators.<locals>.test1cs�|fi|��dSrrr�rnrr�test2sz?PatchTest.test_patch_multiple_stacked_decorators.<locals>.test2cs�|fi|��dSrrr�rnrr�test3sz?PatchTest.test_patch_multiple_stacked_decorators.<locals>.test3cs�|�d�}|�d�}��|���t����tj|���tj|���tj|���t|t	����t|t	����t|t	��dS)Nr/r8)
�poprJr�r*r/r1r8rIrr
)r1r&r/r8rtrrr0s


z?PatchTest.test_patch_multiple_stacked_decorators.<locals>._testr~)rrwrxr�r�r�r)r0rurr�&test_patch_multiple_stacked_decoratorss*



z0PatchTest.test_patch_multiple_stacked_decoratorscCs�t}tj}tj}tjttdtd�}|��}z||d}|d}|�t	|�t	ddg��|�
t|�|�
tj|�|�
tj|�|�t
|t��|�t
|t��W|��n
|��0|�tj|�|�tj|�dS)Nr�r{r/r8)r*r/r1r
rvrrr�rT�setr�r8rIrr
r)rrurwrxrr=r/r8rrr�(test_patch_multiple_create_mocks_patcher3s"z2PatchTest.test_patch_multiple_create_mocks_patchercsv|�t�tj}tj}G��fdd�dt�}tjttdtd�|�}|�}|��|�	�|�
tj|�|�
tj|�dS)Ncs*eZdZ��fdd�Zdd�Zdd�ZdS)z@PatchTest.test_patch_multiple_decorating_class.<locals>.SomeTestcsZ��t����tj|���tjd���tj|���t|t����t|t��dSr|r}�rr/r8�rurWrrr0TszFPatchTest.test_patch_multiple_decorating_class.<locals>.SomeTest._testcSs|�||�dSrrnr�rrrro\szIPatchTest.test_patch_multiple_decorating_class.<locals>.SomeTest.test_twocSs|�||�dSrrnr�rrrrp^szIPatchTest.test_patch_multiple_decorating_class.<locals>.SomeTest.test_oneNrqrr�rrrrRsrrr�r{)r*r/r1r'r
rvrrrprorT)rrwrxrrrrr�r�$test_patch_multiple_decorating_classLs��z.PatchTest.test_patch_multiple_decorating_classcCsntjtdd�}|�t|j�tjtddd�}|��z|�tjd�W|��n
|��0|�	t
td��dS)N�blam)r�T)r�r�)r
rvr*rGr�r�rTr�rrJr�rrrr�test_patch_multiple_createmsz$PatchTest.test_patch_multiple_createcCs�tjttddgd�}|��}zf|�tj|d�tj�d�tj�d�tjj�	d�tjj�	d�|�
tttjdd�W|�
�n
|�
�0dS)Nr,r<)r8r�r8r.r:r�)r
rvr*rr�rTr8r,r<r/rGr�r!r)rrr=rrr�test_patch_multiple_spec_set{sz&PatchTest.test_patch_multiple_spec_setcCs�Gdd�dt�}tjttt|d�}|��}z\|�tj|d�|�tj|d�|�	tj|�|�	tj|�|�
tjtj�W|��n
|��0dS)Nc@seZdZdS)z9PatchTest.test_patch_multiple_new_callable.<locals>.ThingNrerrrr�Thing�sr�)r/r1rRr/r1)r'r
rvr*rr�r�r/r1rrr)rr�rr=rrr� test_patch_multiple_new_callable�s�z*PatchTest.test_patch_multiple_new_callablecCs�tj}tj}t�tdd�t�tdd�t�tdd�dd����}t�tdd�t�tdd�t�tdd�dd����}t�tdd�t�tdd�t�tdd�d	d
����}|||fD],}|�t|�|�tj|�|�tj|�q�dS)Nr1r.�missingr/cSsdSrrrrrr�thing1�sz3PatchTest.test_nested_patch_failure.<locals>.thing1cSsdSrrrrrr�thing2�sz3PatchTest.test_nested_patch_failure.<locals>.thing2cSsdSrrrrrr�thing3�sz3PatchTest.test_nested_patch_failure.<locals>.thing3)r*r/r1r
r'rGr�rT)rrwrxr�r�r��funcrrr�test_nested_patch_failure�s$z#PatchTest.test_nested_patch_failurec	Cstj}tj}tj}dd�}t�tdd�tjtd|d�t�tdd�dd	����}tjtd|d�t�tdd�t�tdd�d
d����}t�tdd�t�tdd�tjtd|d�dd
����}|||fD]:}|�t|�|�tj|�|�tj|�|�tj|�q�dS)NcSstd��dS�N�crasherr�rrrrr��sz4PatchTest.test_new_callable_failure.<locals>.crasherr1r.r8rQr/cSsdSrrrrrrr��sz3PatchTest.test_new_callable_failure.<locals>.thing1cSsdSrrrrrrr��sz3PatchTest.test_new_callable_failure.<locals>.thing2cSsdSrrrrrrr��sz3PatchTest.test_new_callable_failure.<locals>.thing3)	r*r/r1r8r
r'rGr�rT)	rrwrxrur�r�r�r�r�rrr�test_new_callable_failure�s*z#PatchTest.test_new_callable_failurecCs�tj}tj}t�tdd�}d|_t�tdd�}d|_t�tdd�}d|_||g||gfD]>}||_|dd��}|�t|�|�	tj|�|�	tj|�qXdS)Nr/r.r1r�cSsdSrrrrrrr��sz3PatchTest.test_patch_multiple_failure.<locals>.func)
r*r/r1r
r'r�r�rGr�rT)rrwrxr�good�bad�additionalsr�rrr�test_patch_multiple_failure�s
z%PatchTest.test_patch_multiple_failurec
Cs�tj}tj}tj}dd�}t�tdd�}d|_t�tdd�}d|_tjtd|d�}d|_||g||gfD]L}||_|dd	��}	|�t	|	�|�
tj|�|�
tj|�|�
tj|�qhdS)
NcSstd��dSr�r�rrrrr��szCPatchTest.test_patch_multiple_new_callable_failure.<locals>.crasherr/r.r1r8rQcSsdSrrrrrrr�sz@PatchTest.test_patch_multiple_new_callable_failure.<locals>.func)r*r/r1r8r
r'r�r�rGr�rT)
rrwrxrur�rr�r�r�r�rrr�(test_patch_multiple_new_callable_failure�s$
z2PatchTest.test_patch_multiple_new_callable_failurecsLtdtfddi�}|��tj�dd���fdd��}|����jd�dS)Nr*�fishZtasty�nearly gone)r�cs���jd�dS)Nr�)rTr�rr�rrrWsz=PatchTest.test_patch_multiple_string_subclasses.<locals>.test)r\�strr
rvrTr�)rr*rWrr�r�%test_patch_multiple_string_subclasses	sz/PatchTest.test_patch_multiple_string_subclasseszunittest.mock.patch.TEST_PREFIXr8cCslGdd�dt�}t�|dd�|�}|�}|�|��d�|�|��d�|�|��d�|�|��d�dS)Nc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)z-PatchTest.test_patch_test_prefix.<locals>.FooricSs|jSr�rr0rrr�foo_onesz5PatchTest.test_patch_test_prefix.<locals>.Foo.foo_onecSs|jSrr�r0rrr�foo_twosz5PatchTest.test_patch_test_prefix.<locals>.Foo.foo_twocSs|jSrr�r0rrrrpsz6PatchTest.test_patch_test_prefix.<locals>.Foo.test_onecSs|jSrr�r0rrrrosz6PatchTest.test_patch_test_prefix.<locals>.Foo.test_twoN)rrrrr�r�rprorrrrr*s
r*r�changedri)r'r
rTr�r�rpro�rr*r8rrr�test_patch_test_prefixsz PatchTest.test_patch_test_prefixr2cs�G�fdd�dt�}ddi�tj�dd�|�}|�}|�|��ddi�|�|��ddi�|�|��ddi�|�|��ddi�dS)Ncs<eZdZ�fdd�Z�fdd�Z�fdd�Z�fdd�Zd	S)
z2PatchTest.test_patch_dict_test_prefix.<locals>.Foocst��Sr�r�r0�Zthe_dictrr�bar_one.sz:PatchTest.test_patch_dict_test_prefix.<locals>.Foo.bar_onecst��Srr�r0r�rr�bar_two0sz:PatchTest.test_patch_dict_test_prefix.<locals>.Foo.bar_twocst��Srr�r0r�rrrp2sz;PatchTest.test_patch_dict_test_prefix.<locals>.Foo.test_onecst��Srr�r0r�rrro4sz;PatchTest.test_patch_dict_test_prefix.<locals>.Foo.test_twoN)rrrr�r�rprorr�rrr*-sr*�keyrir�)r�)r'r
r�rTr�r�rpror�rr�r�test_patch_dict_test_prefix+s
z%PatchTest.test_patch_dict_test_prefixc	Cs�dD]�}tdtfi|di��}|��}zT|�dt|��|�dt|j��|�dt|���|�dt|�j��W|��q|��0qdS)N�r�r�r�r�Tz name='SomeClass'z! name='SomeClass.class_attribute'z name='SomeClass()'z# name='SomeClass().class_attribute')r
rr�r�rJrxr)rrhr`r�rrr�test_patch_with_spec_mock_reprAs�
�z(PatchTest.test_patch_with_spec_mock_reprcCs^tddd��>}|�dt|j����|�dt|������Wd�n1sP0YdS)N�unittest.test.testmock.supportTr�z" name='support.SomeClass.wibble()'z$ name='support.SomeClass().wibble()')r
r�rJrr�)rr�rrr�test_patch_nested_autospec_reprPs��z)PatchTest.test_patch_nested_autospec_reprc	CsdD�]}tdtfi|di��}|��}z�|��t��g}|�|j|�|�|j|�|�|jjt�g�|�}|�t��|�|j|�|��|�t����|�|j|�|�|jt��g�|�|jjt�g�|�|jt��g�W|�	�q|�	�0qdS)Nr�r�T)
r
rr�r�rrTZ
mock_callsZmethod_calls�appendr)rrhr`r�Zkallsr=rrr�test_mock_calls_with_patchYs&

z$PatchTest.test_mock_calls_with_patchcCs�td�}|�t|j�td��Dt�}|tjd<d|_td�}d|_|��|�	�Wd�n1sh0Y|�
|jd�dS)N�
squizz.squozz�squizz�r�)r
rG�ImportErrorr�rrr5r6ZsquozzrrT)rZp1r�rrr�test_patch_imports_lazilyts

&z#PatchTest.test_patch_imports_lazilycs�Gdd�d��G�fdd�dt���fdd�}|d�dd	��}td
��,t�}|tjd
<|�t|�Wd�n1sx0Y|��jdt�|�	�jdd
�|�	�jdd�dS)Nc@seZdZdZdS)z;PatchTest.test_patch_propagates_exc_on_exit.<locals>.holder)NNNN)rrrrLrrrr�holder�sr�cseZdZd�fdd�	ZeZdS)zAPatchTest.test_patch_propagates_exc_on_exit.<locals>.custom_patchNcs t�||||�|||f�_dSr)r�__exit__rL)r�etype�val�tb�r�rrr��szJPatchTest.test_patch_propagates_exc_on_exit.<locals>.custom_patch.__exit__)NNN)rrrr�rrr�rr�custom_patch�sr�c
s$t|�\}}�||tdddddi�	S)NF)rr)r��getterrP)r�rr�with_custom_patch�s
�zFPatchTest.test_patch_propagates_exc_on_exit.<locals>.with_custom_patchr�cSst�dSr)�RuntimeErrorr�rrrrW�sz9PatchTest.test_patch_propagates_exc_on_exit.<locals>.testr�rr.zexception value not propagatedr:z"exception traceback not propagated)
rrrr5r6rGr�r�rLZassertIsNotNone)rr�rWr�r)r�r�r�!test_patch_propagates_exc_on_exit�s 


*��z+PatchTest.test_patch_propagates_exc_on_exitcCspdD]f}tdtfddi|di��}|�t|j�|�tdd��ttfddi|di��}|��|��qdS)N�r�r�r�z%s.doesnotexistr�TcSstSr)�doesnotexistrrrrr��r.z1PatchTest.test_create_and_specs.<locals>.<lambda>)r
rrGrHr�r��MODNAMEr)r�kwargr`rrr�test_create_and_specs�s�zPatchTest.test_create_and_specscCs�t}dD]6}ttfddi|di��}|�t|j�|�t|�qdD]6}ttfddi|di��}|�t|j�|�t|�qDdD]6}ttfddi|di��}|�t|j�|�t|�q�dS)Nr�r�r�r�r�r�)r�r�r�)rkr
r�rGrHr�r�)rrir�r`rrr�test_multiple_specs�szPatchTest.test_multiple_specscCs@ttdddd�}|��}z|jd|_W|��n
|��0dS)NFr�r�)r
r�r�Zdoes_not_existr)rr`rvrrr� test_specs_false_instead_of_none�sz*PatchTest.test_specs_false_instead_of_nonec	CsRdD]H}ttfi|di��}|��}z|�tt|d�W|��q|��0qdS)Nr�rZdoesnotexit)r
r�r�rGr�rr�rr�r`r�rrr�test_falsey_spec�szPatchTest.test_falsey_specc	CshdD]^}ttfddi|di��}|��}z.|�tt|dd�|�tt|d�W|��q|��0qdS)Nr�r�Tr�rf)r
r�r�rGr�r!rrr�rrr�test_spec_set_true�s
�zPatchTest.test_spec_set_truecCsBd}tt|d�}|��}z|�t|��W|��n
|��0dS)N)�__call__r�)r
r�r�rI�callabler�rr�r`r�rrr�test_callable_spec_as_list�sz$PatchTest.test_callable_spec_as_listcCsBd}tt|d�}|��}z|�t|��W|��n
|��0dS)Nr�r�)r
r�r�rJr�rr�rrr�test_not_callable_spec_as_list�sz(PatchTest.test_not_callable_spec_as_listcs^tj�tj�tj}tdt���tdt���td����fdd��}|���tj|�dS)N�	os.unlink�os.chdirzos.pathcs6t����tj|���tj����tj��dSr)r
�stopallr�r��path�unlink�chdir)Z	mock_path�r�rr�rrr�sz-PatchTest.test_patch_stopall.<locals>.patched)	r�r�r�r�r
rfr�rlr�)rr�r�rr�r�test_patch_stopall�szPatchTest.test_patch_stopallcsPg�Gdd�dt����fdd���fdd�dD�t��|��gd��dS)	Nc@seZdZdZZZdS)z*PatchTest.test_stopall_lifo.<locals>.thingN)rrr�one�two�threerrrrrsrc
s8G���fdd�dt����fdd��ddddddi�	S)Ncs"eZdZ����fdd�Z�ZS)z?PatchTest.test_stopall_lifo.<locals>.get_patch.<locals>.mypatchcs����t�|���Sr)r��superrr0)�	__class__rP�mypatch�stoppedrrrs
zDPatchTest.test_stopall_lifo.<locals>.get_patch.<locals>.mypatch.stop)rrrr�
__classcell__r)rPr�r�)r�rr�sr�cs�Srrrr�rrr�r.z@PatchTest.test_stopall_lifo.<locals>.get_patch.<locals>.<lambda>F)r)rP)r�r)rPr�r�	get_patchs
�z.PatchTest.test_stopall_lifo.<locals>.get_patchcsg|]}�|����qSr)r�)�.0r�)r�rr�
<listcomp>r.z/PatchTest.test_stopall_lifo.<locals>.<listcomp>)r�r�r�)r�r�r�)r'r
r�rTr0r)r�r�rr�test_stopall_lifo
szPatchTest.test_stopall_lifocs�i}ddi}ddd��|��}|��}���}t�|ddd����t�|dd	i���t����fd
d��}|�|�||�|�||�|��|�t��|�||�|�||�|��|�dS)Nr.r,�A�B�r.r:�I�IIr:r<cs
�d=dSr-rr�Zdic3rrr�%sz2PatchTest.test_patch_dict_stopall.<locals>.patched)r�r
r�r�rurTr�)r�dic1�dic2�origdic1�origdic2Zorigdic3r�rr�r�test_patch_dict_stopalls$
z!PatchTest.test_patch_dict_stopallcCs�tj}tj}i}ddd�}|��}|��}tdt���tdt���t�|ddd����t�|���|d=|�	tj|�|�	tj|�|�
||�|�
||�t��|�tj|�|�tj|�|�
||�|�
||�dS)	Nr�r�r�r�r�r�r�r.)r�r�r�r�r
rfr�rlr�rrur�r�rT)rZoriginal_unlinkZoriginal_chdirr�r�r�r�rrr�!test_patch_and_patch_dict_stopall5s(
z+PatchTest.test_patch_and_patch_dict_stopallcCs�ddd�}t�|dd��|�|�d�Wd�n1s<0Y|�|�d�|j}t�|dd��|�|jd�Wd�n1s�0Y|�|j|�t�|d	d
��|�|jd
�Wd�n1s�0Y|�|jd�t�|dtd
g���$|�|jtd
g��Wd�n1�s.0Y|�|jt��dd�dd�}t�|dtdg���|�|�d�Wd�n1�s�0Y|�|�d�dS)NrcSs|S)ZTESTr�rgrrrr8Osz)PatchTest.test_special_attrs.<locals>.foo�__defaults__)r.r.�__doc__ZFUNrZ
testpatch2z unittest.test.testmock.testpatch�__annotations__)�sr.r�cWs|Srr)rgr,rrrr8cs�__kwdefaults__)rgr.)r)r
r'rTr�rr�r�)rr8Zorig_docrrr�test_special_attrsNs$
,,,4.zPatchTest.test_special_attrscCs�t�}t�|d<d|d<|��}ttdtd���}t|���|}t�|t|���$|�	t|���|�Wd�n1s|0Y|�	||�t�||��$|�	t|���|�Wd�n1s�0Y|�	||�dS)Nr,Zpythonr<Zcdefghijklmnopqrstuvwxyz�)
rr'r�rG�zip�range�itemsr
r�rT)rr8riZ
update_valuesZpatched_valuesrrr�test_patch_orderdictis
22zPatchTest.test_patch_orderdictcCslddl}t�d��Ftjd=tjd=tjd=tjd=td�dd	��}|�Wd�n1s^0YdS)
Nrzsys.modulesr�zunittest.test.testmockz
unittest.testrM� unittest.test.testmock.support.XcSsdSrrr�rrrrW�sz9PatchTest.test_dotted_but_module_not_loaded.<locals>.test)�unittest.test.testmock.supportr
r�r5r6)rrMrWrrr�!test_dotted_but_module_not_loaded|s
z+PatchTest.test_dotted_but_module_not_loadedc
Cs�Gdd�d�}dd|�fD]b}|j|d��B|�t��t|�Wd�n1sT0YWd�q1sr0YqdS)Nc@seZdZdS)z*PatchTest.test_invalid_target.<locals>.FooNrerrrrr*�sr*��)r�)ZsubTestrGrHr
)rr*r�rrr�test_invalid_target�s
zPatchTest.test_invalid_targetcCsLtdt�dd�dd��}|�t��|�Wd�n1s>0YdS)Nrr.)rDrgcSsdSrrrrrrrW�sz@PatchTest.test_cant_set_kwargs_when_passing_a_mock.<locals>.test)r
r'rGrHrZrrr�(test_cant_set_kwargs_when_passing_a_mock�s
z2PatchTest.test_cant_set_kwargs_when_passing_a_mockN)T)qrrrrMr[r]r_rdrjrwrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	rrrr r!r'r(r+r8r<r>rBrCrErHrIrKrPrTrUr]r_rarcrdrirkrsryrzrr�r�r�r�r�r�r�r�r�r�r�r�r
r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	rrrrrFUs�


+*

			
!
	
	


C	




+!

	"




rF�__main__)T)*r�r5�collectionsrrMZunittest.test.testmockrrrrZtest.test_importlib.utilrZ
unittest.mockrrr	r
rrr
rrrrrtr6rrkr�r)rQrfrmrlr'r*rr=r>ZTestCaserF�mainrrrr�<module>sD4

Y


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists