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__/testmock.cpython-39.opt-1.pyc

a

��g��@s�ddlZddlZddlZddlZddlmZddlZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZmZmZmZmZGdd�de�ZGdd	�d	e�Zd
d�ZGdd
�d
ej�Zedkr�e��dS)�N)�	ALWAYS_EQ)�is_instance��mock)�call�DEFAULT�patch�sentinel�	MagicMock�Mock�NonCallableMock�NonCallableMagicMock�	AsyncMock�_Call�	_CallList�create_autospecc@s(eZdZdd�Zdd�Zdd�ZeZdS)�ItercCstgd��|_dS)N��this�isZan�iter)r�thing��self�r�;/usr/local/lib/python3.9/unittest/test/testmock/testmock.py�__init__sz
Iter.__init__cCs|S�Nrrrrr�__iter__sz
Iter.__iter__cCs
t|j�Sr)�nextrrrrrrsz	Iter.nextN)�__name__�
__module__�__qualname__rrr�__next__rrrrrsrc@s2eZdZddd�Zed	dd��Zed
dd��ZdS)�	SomethingNcCsdSrr�r�a�b�c�drrr�meth �zSomething.methcCsdSrr)�clsr&r'r(r)rrr�cmeth"szSomething.cmethcCsdSrr�r&r'r(r)rrr�smeth%szSomething.smeth)N)N)N)r r!r"r*�classmethodr-�staticmethodr/rrrrr$s

r$cCsdSrr�r&rrr�	something)r+r3c@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dadb�Z3dcdd�Z4dedf�Z5dgdh�Z6didj�Z7dkdl�Z8dmdn�Z9dodp�Z:dqdr�Z;dsdt�Z<dudv�Z=dwdx�Z>dydz�Z?d{d|�Z@d}d~�ZAdd��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��ZXd�d��ZYd�d��ZZd�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�dބZqd�d�Zrd�d�Zsd�d�Ztd�d�Zud�d�Zvd�d�Zwd�d�Zxd�d�Zyd�d�Zzd�d�Z{d�d�Z|d�d��Z}d�d��Z~d�d��Zd�d��Z�d�d��Z�d��d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d	�d
�Z��d�d�Z��d
S(�MockTestcCstd�dS)Nzfrom unittest.mock import *)�execrrrr�test_all.szMockTest.test_allcCs�t�}|�|jd�|�|jdd�|�t|jt�d�|�|jdd�|�|j	gd�|�|j
gd�|�d|jd	�|�
|jd
�|�
|jd�|�|jid�dS)
Nz called not initialised correctlyrz$call_count not initialised correctlyz&return_value not initialised correctlyz#call_args not initialised correctly�(call_args_list not initialised correctlyz&method_calls not initialised correctlyZ_itemsz/default mock should not have '_items' attributez parent not initialised correctlyz!methods not initialised correctlyz$children not initialised incorrectly)r�assertFalse�called�assertEqual�
call_count�
assertTruer�return_value�	call_args�call_args_list�method_calls�assertNotIn�__dict__�assertIsNone�_mock_parent�
_mock_methods�_mock_children�rrrrr�test_constructor5s:
��
�
�
�
���
�zMockTest.test_constructorcCstdd�}|�|jd�dS)N�r=z(return value in constructor not honoured)rrCr=rGrrr� test_return_value_in_constructorQs
�z)MockTest.test_return_value_in_constructorcCs*dd�}t|�}d|j_|�|�d�dS)NcSsdSrrrrrr�fXr+z9MockTest.test_change_return_value_via_delegate.<locals>.f�)rrr=r:�rrKrrrr�%test_change_return_value_via_delegateWsz.MockTest.test_change_return_value_via_delegatecCsNdd�}t|�}t�|j_|�t��|�Wd�n1s@0YdS)NcSsdSrrrrrrrK_r+z8MockTest.test_change_side_effect_via_delegate.<locals>.f)r�	TypeErrorr�side_effect�assertRaisesrMrrr�$test_change_side_effect_via_delegate^s

z-MockTest.test_change_side_effect_via_delegatecCs�tdd�}|�dt|��|�dt|�t|��t�dftdd�dfg}|D]�\}}|�d|t|j��|�d|t|����|�d|t|��j��|�d	|t|���|�d
|t|����|�d|t|��jj��j��qNdS)N�foo��namez'%s'r�barz%s.barz%s.foo()z
%s.foo().bingz%s()z%s()()z%s()().foo.bar.baz().bing)r�assertIn�repr�idrVrSZbing�baz)rr�mocksrUrrr�	test_reprfs

�zMockTest.test_reprcCs�Gdd�dt�}t|d�}|�dt|��t|�d�}|�dt|��t|d�}|�dt|��t|�d�}|�dt|��t|dd�}|�dt|��|�d	t|��tdd
�}|�dt|��t�}|�dt|��tdgd�}|�dt|��dS)Nc@seZdZdS)z'MockTest.test_repr_with_spec.<locals>.XN�r r!r"rrrr�Xwsr^��specz
 spec='X' ��spec_setz spec_set='X' rS)r`rUz name='foo' rTr`)�objectrrWrXrA�rr^rrrr�test_repr_with_specvs$


zMockTest.test_repr_with_speccs�t�}dd�}||_|jt|dddd�|jdddd�gd���fdd�}||_|�|�|�|�ggd	�d
�ttjd�}|�|jtjd�d
d�}t|tjd�}|�|�tj�dS)Nc_std��dS)NZkablooie)�SystemError)�args�kwargsrrr�effect�sz)MockTest.test_side_effect.<locals>.effectrL����fish�rLrjrkcs���Sr��popr��resultsrrri�s�rkrjrLzside effect not used correctly�rPz#side effect in constructor not usedcSstSr�rrrrrrP�sz.MockTest.test_side_effect.<locals>.side_effect)rPr=)	rrPrQrf�assert_called_withr:r	�
SideEffect�RETURN)rrrirPrrqr�test_side_effect�s$��zMockTest.test_side_effectcs�gd���fdd�}dd�}t|�}gd�|_|�|�|�|�ggd�d�gd��t|�}||_|�|�|�|�ggd�d�dS)	Nrncs���Srrorrqrrri�sz2MockTest.test_autospec_side_effect.<locals>.effectcSsdSrrrrrrrK�r+z-MockTest.test_autospec_side_effect.<locals>.fz1side effect not used correctly in create_autospecrsz'callable side effect not used correctly)rrPr:)rrirKrrrqr�test_autospec_side_effect�s
��z"MockTest.test_autospec_side_effectcCs,dd�}t|�}td�|_|�td|�dS)NcSsdSrrrrrrrK�r+z7MockTest.test_autospec_side_effect_exception.<locals>.fzBazinga!)r�
ValueErrorrP�assertRaisesRegexrMrrr�#test_autospec_side_effect_exception�s
z,MockTest.test_autospec_side_effect_exceptioncCsRt�}dg}td||d�}|tjtjd�|j}|��tj|_|j}|�|��|�	|j
dd�|�	|j|d�|�	|j|d�|�
|jd�|�	|jd	d
�|�	|jdd�|�	|jgd�|�	|jgd
|jgf�|�	|jg�|�	|jtjd�|�	|j|d�|�
|jd�|�	|jd|id�|�	|j|d�|�
|jjd�dS)Nr3�child)rU�parentr`�r3zname incorrectly resetzparent incorrectly resetzmethods incorrectly resetzcalled not resetrzcall_count not resetzcall_args not resetzcall_args_list not resetz0method_calls not initialised correctly: %r != %rzside_effect incorrectly resetzreturn_value incorrectly resetzreturn value mock not resetzchildren reset incorrectlyzchildren incorrectly clearedzchild not reset)rr	r$Z
SomethingElser3rwrPr=�
reset_mockr:�
_mock_namerDrEr8r9r;r>r?r@�
mock_callsrF)rrr`rr3r=rrr�test_reset_mock�sV
�
�
�
���
��
�zMockTest.test_reset_mockcCst�}||_|��dSr)rr=r�rGrrr�test_reset_mock_recursion�sz"MockTest.test_reset_mock_recursioncCst��}|��dSr)r�	mock_openr��rr&rrr�(test_reset_mock_on_mock_open_issue_18622�sz1MockTest.test_reset_mock_on_mock_open_issue_18622cCs>t�}|�t|jt�d�|�}|�|�|d�|��|tj�}|�|jd�|�|j	dd�|�|j
tjfifd�|�|j
jtjfd�|�|j
jid�|�|j
tjfifgd�tj|_|tjtjd�}|�|tjd	�|�|j	d
d�|�|j
tjfdtjifd�|�|j
tjfiftjfdtjifgd�dS)
Nz%Default return_value should be a Mockz'different result from consecutive callszcalled not setrLzcall_count incorrectzcall_args not setr7)�keyzincorrect return valuerjr�zcall_args_list not set)rr<rr=r:r�r	�Argr9r;r>rgrhr?ZReturnValueZKeyArg)rr�resultZret_valrrr�	test_call�sP�
�
����
��
��zMockTest.test_callc	Cs�t�}|�|tj�|tjd�|tjtjd�|�|jdtjffdtjiftjfdtjifg�|�|jtjfdtjif�|�|jjtjf�|�|jjdtji�|�	|jdk�dS)N)�kwrr�za long sequence)
rr	r�ZKwargr:r?r>rgrhr8rGrrr�test_call_args_comparison$s"

��z"MockTest.test_call_args_comparisoncCs2t��}|�||k�|�||k�|�|t��k�|�|t��k�|�|tjk�|�|tjk�|�tj|k�|�tj|k�|�|tk�|�|tk�t�t���}t�tj�}|�||k�|�||k�|�||k�|�||k�|�|tk�|�|tk�|�|dk�|�|dk�dS)NrL)rr
r<r8�ANYrr)rZmmZcall1Zcall2rrr�test_calls_equal_with_any:s*z"MockTest.test_calls_equal_with_anycCsdt�}|�|��|�t|jd�|��|�t|j�|dddddd�|jdddddd�dS)NrLrjrkrmZnothing�r&r')rrvrQ�AssertionErrorr�rGrrr�test_assert_called_withVsz MockTest.test_assert_called_withcCs t�}|t��|�tj�dSr)r
rvrr��r�mrrr�test_assert_called_with_anyes
z$MockTest.test_assert_called_with_anycCs�ddd�}t|d�}|dddd�|�ddd�|jdddd�|jt|jdddd�|�t��}|jd	d
�Wd�n1s�0Y|�|jjt�dS)NcSsdSrrr.rrrrKlr+z9MockTest.test_assert_called_with_function_spec.<locals>.fr_rLrjrk�r'r(�r&r'r(���e)N)rrvrQr��assertIsInstance�	exception�	__cause__rO�rrKr�cmrrr�%test_assert_called_with_function_specks


�*z.MockTest.test_assert_called_with_function_speccsz�fdd�}tt�jd�}||�ttjd�}||�tt�jd�}||�ttjd�}||�tt�jd�}||�dS)NcsF|dddd�|�ddd�|jdddd��jt|jdddd�dS)NrLrjrkr�r�)rvrQr�rrrr�_check|s
�z<MockTest.test_assert_called_with_method_spec.<locals>._checkr_)rr$r*r-r/)rr�rrrr�#test_assert_called_with_method_spec{sz,MockTest.test_assert_called_with_method_speccCs�d}|�t|�d���t���Wd�n1s60Y|�t|�d���tdd���Wd�n1sv0YdS)Nz"Expected '{0}' to have been calledrZ	test_namerT)r|r��formatr�
assert_called)r�msgrrr�$test_assert_called_exception_message�s
(z-MockTest.test_assert_called_exception_messagecs�t���������|�t�j����|�t�j��dddd��jdddd�����dddd�|�t�fdd��dS)NrSrVrj�rZcs�jdddd�S)N�bobrVrjr���assert_called_once_withrrrr�<lambda>�r+z7MockTest.test_assert_called_once_with.<locals>.<lambda>)rr�rQr�r�rrrr�test_assert_called_once_with�s
�z%MockTest.test_assert_called_once_withcs6t���d��d�|�tt�d��fdd��dS)NrLrjzCalls: [call(1), call(2)]cs
��d�S)Nrjr�r�r�rrr��r+zAMockTest.test_assert_called_once_with_call_list.<locals>.<lambda>)rr|r��re�escaperrr�r�&test_assert_called_once_with_call_list�s
�z/MockTest.test_assert_called_once_with_call_listcCs�ddd�}t|d�}|dddd�|�ddd�|jdddd�|jt|jdddd�|�t��}|jd	d
�Wd�n1s�0Y|�|jjt�|ddd
�|�t|jddd�|�t|jddd
�dS)NcSsdSrrr.rrrrK�r+z>MockTest.test_assert_called_once_with_function_spec.<locals>.fr_rLrjrkr�r�r�r����)N)rr�rQr�r�r�r�rOr�rrr�*test_assert_called_once_with_function_spec�s$


�*
�
�z3MockTest.test_assert_called_once_with_function_speccCsbt�}|j}|�t|t�d�|�|j|d�t�}d|j_|�|��dd�|�|jjd�dS)Nzattribute isn't a mockz+different attributes returned for same namerkzmethod returned wrong valuez!method didn't record being called)rr3r<rr:r=r9�rrr3rrr�#test_attribute_access_returns_mocks�s
�
�z,MockTest.test_attribute_access_returns_mockscCs0t�}|j}|�|jdd�|�|j|d�dS)Nr3z attribute name not set correctlyz"attribute parent not set correctly)rr3r:r�rDr�rrr�(test_attributes_have_name_and_parent_set�s
�
�z1MockTest.test_attributes_have_name_and_parent_setcCstt�}|jddd�|jjdtjd�|�|jjdddtjifgd�|�|jdd	d
difdddtjifgd�dS)Nrkrlr�)�caker3)r�r�z#method calls not recorded correctly)rkrmzsomething_else.something)rr3�something_elser	ZCaker:r@rGrrr�test_method_calls_recorded�s
���z#MockTest.test_method_calls_recordedcCs�t�}|��|�|jdg�|�|jddifg�t�}|�d�|�|jdg�|�|jddifg�t�}|jdd�|�|jdd	difg�|�|jddd	difg�t�}|jdd
d�|�|jdddd
ifg�dS)
Nr�r3r�	different)r3�r�r�rL��xr�Zmore)�somer�)rr3r:r@rGrrr� test_method_calls_compare_easily�s&

��z)MockTest.test_method_calls_compare_easilyc	CsHdgdfD]8}dD].}tfi||i��}|j|�tdt|d�qq
dS)Nr3r�)r`rbz-Mock object has no attribute 'something_else'r�)rr3r|�AttributeError�getattr)rr`�argrrrr�test_only_allowed_methods_exists�z(MockTest.test_only_allowed_methods_existcs>Gdd�dt�}�fdd�}|t|d��|t|�d��dS)Nc@seZdZdZdZdd�ZdS)z*MockTest.test_from_spec.<locals>.SomethingrkNcSsdSrrrrrr�y r+z,MockTest.test_from_spec.<locals>.Something.y)r r!r"r��
__something__r�rrrrr$sr$cs:|j|j|j��tdt|d���tdt|d�dS)Nz Mock object has no attribute 'z'�zz)Mock object has no attribute '__foobar__'Z
__foobar__)r�r�r�r|r�r�rrrr�test_attributes"s��z0MockTest.test_from_spec.<locals>.test_attributesr_)rcr)rr$r�rrr�test_from_specszMockTest.test_from_speccCsJt�}t|d�}|�|�|��|��|dddd�|jdddd�dS)N��wrapsrLrjrkrl)rr:r�rv�r�realrrrr�test_wraps_calls6s
zMockTest.test_wraps_callscs8Gdd�dt�}|�}t|d��|�t�fdd��dS)Nc@seZdZdS)zFMockTest.test_wraps_prevents_automatic_creation_of_mocks.<locals>.RealNr]rrrr�RealCsr�r�cs���Sr)Znew_attrrrrrr�Ir+zJMockTest.test_wraps_prevents_automatic_creation_of_mocks.<locals>.<lambda>)rcrrQr�)rr�r�rrr�/test_wraps_prevents_automatic_creation_of_mocksBs
z8MockTest.test_wraps_prevents_automatic_creation_of_mockscCs4t�}t|d�}d|_|�|�d�|�|j�dS)Nr�rk)rr=r:r8r9r�rrr�,test_wraps_call_with_nondefault_return_valueLs

z5MockTest.test_wraps_call_with_nondefault_return_valuecs�Gdd�dt�}|�}t|d��|����|���|�t�fdd��|��j|j��jjdddd	�}|jjjdddd	�|�||j���dS)
Nc@seZdZe�ZdS)z,MockTest.test_wraps_attributes.<locals>.RealN)r r!r"r�	attributerrrrr�Wsr�r�cs�jSrrlrrrrr�^r+z0MockTest.test_wraps_attributes.<locals>.<lambda>rLrjrkrl)	rcrr:r�rQr��assertNotEqualZfrogrv)rr�r�r�rrr�test_wraps_attributesVs
zMockTest.test_wraps_attributescCsdGdd�dt�}|�}t|d�}tjtg|j_|�|��tj�|�|��tj�|�	t
|j�dS)Nc@seZdZdd�ZdS)z[MockTest.test_customize_wrapped_object_with_side_effect_iterable_with_default.<locals>.RealcSstjSr)r	�ORIGINAL_VALUErrrr�methodhszbMockTest.test_customize_wrapped_object_with_side_effect_iterable_with_default.<locals>.Real.methodN�r r!r"r�rrrrr�gsr�r�)rcrr	�VALUE1rr�rPr:r�rQ�
StopIteration�rr�r�rrrr�Dtest_customize_wrapped_object_with_side_effect_iterable_with_defaultfs
zMMockTest.test_customize_wrapped_object_with_side_effect_iterable_with_defaultcCsfGdd�dt�}|�}t|d�}tjtjg|j_|�|��tj�|�|��tj�|�t	|j�dS)Nc@seZdZdd�ZdS)zNMockTest.test_customize_wrapped_object_with_side_effect_iterable.<locals>.RealcSsdSrrrrrrr�vr+zUMockTest.test_customize_wrapped_object_with_side_effect_iterable.<locals>.Real.methodNr�rrrrr�usr�r�)
rcrr	r��VALUE2r�rPr:rQr�r�rrr�7test_customize_wrapped_object_with_side_effect_iterablets
z@MockTest.test_customize_wrapped_object_with_side_effect_iterablecCs:Gdd�dt�}|�}t|d�}t|j_|�t|j�dS)Nc@seZdZdd�ZdS)zOMockTest.test_customize_wrapped_object_with_side_effect_exception.<locals>.RealcSsdSrrrrrrr��r+zVMockTest.test_customize_wrapped_object_with_side_effect_exception.<locals>.Real.methodNr�rrrrr��sr�r�)rcr�RuntimeErrorr�rPrQr�rrr�8test_customize_wrapped_object_with_side_effect_exception�s

zAMockTest.test_customize_wrapped_object_with_side_effect_exceptioncCsFGdd�dt�}dd�}|�}t|d�}||j_|�|��tj�dS)Nc@seZdZdd�ZdS)zNMockTest.test_customize_wrapped_object_with_side_effect_function.<locals>.RealcSsdSrrrrrrr��r+zUMockTest.test_customize_wrapped_object_with_side_effect_function.<locals>.Real.methodNr�rrrrr��sr�cSstjSr)r	�VALUErrrrrP�szUMockTest.test_customize_wrapped_object_with_side_effect_function.<locals>.side_effectr�)rcrr�rPr:r	r�)rr�rPr�rrrr�7test_customize_wrapped_object_with_side_effect_function�s
z@MockTest.test_customize_wrapped_object_with_side_effect_functioncCs@Gdd�dt�}|�}t|d�}tj|j_|�|��tj�dS)Nc@seZdZdd�ZdS)zFMockTest.test_customize_wrapped_object_with_return_value.<locals>.RealcSsdSrrrrrrr��r+zMMockTest.test_customize_wrapped_object_with_return_value.<locals>.Real.methodNr�rrrrr��sr�r�)rcrr	r�r�r=r:r�rrr�/test_customize_wrapped_object_with_return_value�s


z8MockTest.test_customize_wrapped_object_with_return_valuecCspGdd�dt�}|�}t|d�}tjtjg|j_tj|j_|�	|��tj�|�	|��tj�|�
t|j�dS)Nc@seZdZdd�ZdS)zVMockTest.test_customize_wrapped_object_with_return_value_and_side_effect.<locals>.RealcSsdSrrrrrrr��r+z]MockTest.test_customize_wrapped_object_with_return_value_and_side_effect.<locals>.Real.methodNr�rrrrr��sr�r�)rcrr	r�r�r�rPZWRONG_VALUEr=r:rQr�r�rrr�?test_customize_wrapped_object_with_return_value_and_side_effect�s

zHMockTest.test_customize_wrapped_object_with_return_value_and_side_effectcCsLGdd�dt�}|�}t|d�}dd�|j_tj|j_|�|��tj�dS)Nc@seZdZdd�ZdS)zWMockTest.test_customize_wrapped_object_with_return_value_and_side_effect2.<locals>.RealcSsdSrrrrrrr��r+z^MockTest.test_customize_wrapped_object_with_return_value_and_side_effect2.<locals>.Real.methodNr�rrrrr��sr�r�cSstSrrurrrrr��r+z[MockTest.test_customize_wrapped_object_with_return_value_and_side_effect2.<locals>.<lambda>)rcrr�rPr	r�r=r:r�rrr�@test_customize_wrapped_object_with_return_value_and_side_effect2�s

zIMockTest.test_customize_wrapped_object_with_return_value_and_side_effect2cCsnGdd�dt�}|�}t|d�}tjtg|j_tj|j_|�	|��tj�|�	|��tj�|�
t|j�dS)Nc@seZdZdd�ZdS)z^MockTest.test_customize_wrapped_object_with_return_value_and_side_effect_default.<locals>.RealcSsdSrrrrrrr��r+zeMockTest.test_customize_wrapped_object_with_return_value_and_side_effect_default.<locals>.Real.methodNr�rrrrr��sr�r�)rcrr	r�rr�rPrxr=r:rQr�r�rrr�Gtest_customize_wrapped_object_with_return_value_and_side_effect_default�s

zPMockTest.test_customize_wrapped_object_with_return_value_and_side_effect_defaultcCs�ddi}t|d�}|�|�d�d�|�|dt�|�d|v�d|j_|�|�d�d�tj|j_|�|�d�d�|�|�d�d�|�|dt�|�d|v�d|d<|�|�d�d�|�|dt�|�d|v�|d=|�|�d�d�dS)NrSrVr�r=rZ�spam)r
r:�getr�r8r=r	r)r�dataZwrapped_dictrrr�test_magic_method_wraps_dict�s$

z%MockTest.test_magic_method_wraps_dictcCsTGdd�d�}t|d�}|�}|�|�d�d�|�|dd�|�|��d�dS)Nc@seZdZdd�Zdd�ZdS)z3MockTest.test_magic_method_wraps_class.<locals>.FoocSs|Srr)r�indexrrr�__getitem__�sz?MockTest.test_magic_method_wraps_class.<locals>.Foo.__getitem__cSsdS�NrSrrrrr�__custom_method__�szEMockTest.test_magic_method_wraps_class.<locals>.Foo.__custom_method__N)r r!r"r�r�rrrr�Foo�sr�r�rjrS)r
r:r�r�)rr��klass�objrrr�test_magic_method_wraps_class�s	
z&MockTest.test_magic_method_wraps_classcCs4ttd�}|�t|�ttd�d�}|�t|�dS�NrtrS)rr�rQrGrrr�test_exceptional_side_effects
z%MockTest.test_exceptional_side_effectcCs4ttd�}|�t|�ttd�d�}|�t|�dSr�)r�KeyboardInterruptrQrGrrr� test_baseexceptional_side_effect	s
z)MockTest.test_baseexceptional_side_effectcCst�}|�td|j�dS)Nz
not called)rr|r�rvrGrrr�test_assert_called_with_messages�z(MockTest.test_assert_called_with_messagecCstdd�}|�td|j�dS)NZgeoffreyrTz'Expected 'geoffrey' to be called once\.)rr|r�r�rGrrr�$test_assert_called_once_with_messages

�z-MockTest.test_assert_called_once_with_messagecs2t��|�t�fdd��d�_|��jd�dS)Ncs�jSr)r rrrrr� r+z'MockTest.test__name__.<locals>.<lambda>rS)rrQr�r r:rrrr�test__name__szMockTest.test__name__cCsJGdd�dt�}t|dg�d�}|�d�|j�d�|�tt|d�dS)Nc@seZdZdS)z-MockTest.test_spec_list_subclass.<locals>.SubNr]rrrr�Sub'sr�rSr_rk)�listr�appendrvrQr�r�)rr�rrrr�test_spec_list_subclass&s

z MockTest.test_spec_list_subclasscCs�Gdd�dt�}t|d�}|�||�t|�d�}|�||�|�|j|�|�t�jjd�t|d�}|�||�t|�d�}|�||�dS)Nc@seZdZdS)z#MockTest.test_spec_class.<locals>.XNr]rrrrr^1sr^r_rra)rcrr��assertIs�	__class__r:r rdrrr�test_spec_class0s

zMockTest.test_spec_classcCs�Gdd�d�}t|d�}|�||�t|�d�}|�||�|�|j|�|�t�jjd�t|d�}|�||�t|�d�}|�||�dS)Nc@seZdZdS)z2MockTest.test_spec_class_no_object_base.<locals>.XNr]rrrrr^Esr^r_rra)rr�r�r�r:r rdrrr�test_spec_class_no_object_baseDs

z'MockTest.test_spec_class_no_object_basecsLGdd�dt�}t|d��d�_t|d���fdd�}d�_|�t|�dS)Nc@seZdZdZdS)z8MockTest.test_setting_attribute_with_spec_set.<locals>.XrkN)r r!r"r�rrrrr^Ysr^r_rSracs
d�_dSr�r�rrrr�set_attr`sz?MockTest.test_setting_attribute_with_spec_set.<locals>.set_attr)rcrr�r�rQr�)rr^rrrr�$test_setting_attribute_with_spec_setXs

z-MockTest.test_setting_attribute_with_spec_setcCs4t��}|�tj|�t�td��t�t��dS)Nge��A)�sys�getrecursionlimit�
addCleanup�setrecursionlimit�int�copyr)r�currentrrr�	test_copygszMockTest.test_copycs\Gdd�dt�}||d��|��jd��fdd�}|�t|��fdd�}|�t|�dS)Nc@s&eZdZdd�Zdd�Zeee�ZdS)z8MockTest.test_subclass_with_properties.<locals>.SubClasscSsdS�Nrkrrrrr�_getssz=MockTest.test_subclass_with_properties.<locals>.SubClass._getcSstd��dS)Nz
strange error)�	NameError)r�valuerrr�_setusz=MockTest.test_subclass_with_properties.<locals>.SubClass._setN)r r!r"r
r�property�some_attributerrrr�SubClassrsrrarkcs
d�_dSr)rr��srr�test|sz4MockTest.test_subclass_with_properties.<locals>.testcs
d�_dS)NrV�rSrrrrr�s)rr:rrQrr�)rrrrrr�test_subclass_with_propertiesqs
z&MockTest.test_subclass_with_propertiescCs>t�}dd�}|t|�_|d�|�d�|�t|dd�dS)NcSs|�|�|�|�Sr)Z_increment_mock_callZ
_mock_callr�rrr�__call__�s
z,MockTest.test_setting_call.<locals>.__call__�one�two)r�typerrvrQrO)rrrrrr�test_setting_call�s

zMockTest.test_setting_callcCs�t�}tt|��}tdd�tt�D��}|�t�||�|j|jf|�dt|��|�dt|��d|_|_|�dt|��|�dt|��dd�|_	|�d	t|��dS)
NcSsg|]}|�d�s|�qS)�_)�
startswith)�.0r�rrr�
<listcomp>�r+z%MockTest.test_dir.<locals>.<listcomp>r&r'r(r)cSstg�Sr)rrrrrr��r+z#MockTest.test_dir.<locals>.<lambda>r)
r�set�dirr:r&r'rWr(r)r)rr�attrs�
type_attrsrrr�test_dir�s
zMockTest.test_dircCsXttjd�}tttj��}tt|��}|�t�||�d|_|�t|��d�d�dS)Nr_rk�versionrL)r�unittest�TestCaser"r#r:r'�count)rrZtestcase_attrsr$rrr�test_dir_from_spec�szMockTest.test_dir_from_speccCs^t�tdd�}|��z8ttt���}ttt��}|�t�||�W|��n
|��0dS)NZ
FILTER_DIRF)	rrcr�startr"r#rr:�stop)rZpatcherr$r%rrr�test_filter_dir�szMockTest.test_filter_dircCs6t�}d|j_|�dt|��|`|�dt|��dS)NrLr~)rr~r=rWr#rArGrrr�,test_dir_does_not_include_deleted_attributes�s
z5MockTest.test_dir_does_not_include_deleted_attributescCs�tdd�}|�|jd�tdd�}|�|jd�tdt�d�}tfi|��}|�t|�|�|j��d�|�|jt�t�}|jfi|��|�t|�|�|j��d�|�|jt�dS)NrVr�!)rPzfoo.bar.return_valuerS)	rr:rSr
�KeyErrorrQrVr�Zconfigure_mock)rrrhrrr�test_configure_mock�s 

�zMockTest.test_configure_mockcOsR|�|��}||i|��Wd�n1s.0Yt|j�}|�||�dSr)rQ�strr�r:)rr��message�funcrgrh�contextr�rrr�assertRaisesWithMsg�s,
zMockTest.assertRaisesWithMsgc
Cst�}d}d}d}|jt|||f|jddddd�|jddddd	�|jj|jjg}|D]0}d
}d}d}|jt|||f|ddddd�qZ|D]*}d
}d}d}|jt|||f|dd�q�|D],}d
}d
}d}|�t|||f|ddd�q�|D]&}d
}d}d}|�t|||f|�q�dS)Nznot called.zmock(1, '2', 3, bar='foo')z0expected call not found.
Expected: %s
Actual: %srL�2rkrS)rVrzfoo(1, '2', 3, foo='foo')zfoo(1, '2', 3, bar='foo')zfoo(bar='foo')zfoo(1, 2, 3)rjzfoo())rr7r�rvrSr�)rr�actual�expectedr4Z	assertersr*rrr�'test_assert_called_with_failure_message�sT��
����z0MockTest.test_assert_called_with_failure_messagec	Cs�t�}|�|jgkd�t�}|�ddifg}|�|j|�|��|�t���|�|j|�|�|jjddifg�t�}|�jdddddd	�ddifd
dtddd	�fg}|�|j|�|�|jjjddtddd	�fg�|�|jjddtddd	�fg�t�}|�j�	��
�ddifd
difddifg}|�|j|�|�|�jtj�	��
����t�tdd�fD�]8}tfi|��}t|j�ddifg}|�|j|�tfi|��}|�
��ddifddifg}|�|j|�|�|�
�jt�g�tfi|��}|d�d�d�|�|jtd�d�d����|�|�jtd�d����|�|��jtd����tfi|��}|d�d�d�j
j�d�|�|jtd�d�d�j
j�d����|�|�jtd�d�j
j�d����|�|��jtd�j
j�d����tfi|��}t|�j�	��
��ddif}|�|jd|�|�|�jtj�	��
������|�|�j�	�jt�
������|�|�j�	�j
jt�������qpdS)NT�rrLrjrkr�r�r�z().foornrSz
().foo.barz().foo.bar().bazrVrTzfoo.__int__r&za()z().foo.bar().baz().__int__���)r
r�r�r:rSr�r�dictr=rVrZ�	call_listrr&r'r(�__int__)rrr:rhZ	last_callrrr�test_mock_calls!s���
��
�

�
��

���zMockTest.test_mock_callscCsFt�}|�}|��|�|jt�t���g�|�|jt��g�dSr)rZwibbler:r�r)rr�r�rrr�test_child_mock_call_equalos
z#MockTest.test_child_mock_call_equalcCsFt�}|����|�|jdt�����|�|jdt���dS�NrLr)rrSr3r�r�rr�r:r�rrr�test_mock_call_not_equal_leafysz&MockTest.test_mock_call_not_equal_leafcCsFt�}|����|�|jdt�����|�|jdt���dSrC�rrSrVr�r�rrZr�rrr�!test_mock_call_not_equal_non_leaf�sz*MockTest.test_mock_call_not_equal_non_leafcCs8t�}|jdd���|�|jdtjdd����dS)NrLr�rj)rrSrVr:r�rr�rrr�2test_mock_call_not_equal_non_leaf_params_different�sz;MockTest.test_mock_call_not_equal_non_leaf_params_differentcCs,t�}|j��|�|jdtj���dS�NrrEr�rrr�&test_mock_call_not_equal_non_leaf_attr�s
z/MockTest.test_mock_call_not_equal_non_leaf_attrcCs.t�}|j��|�|jdt�����dSrH)rrSrVr�r�rr�rrr�2test_mock_call_not_equal_non_leaf_call_versus_attr�s
z;MockTest.test_mock_call_not_equal_non_leaf_call_versus_attrcCs^t�}|����j��|�t|jd�d�|�t|jd�d�|�t|jd�d�dS)Nrz
call.foo()rLzcall.foo().bar()rjzcall.foo().bar().baz.bob())rrSrVrZr�r:rXr�r�rrr�test_mock_call_repr�s
zMockTest.test_mock_call_reprcCs0t�}||_t|���|�t|���d�dS)Nz<Mock name='mock\(\)' id='\d+'>)rrSrXZassertRegexr�rrr�test_mock_call_repr_loop�sz!MockTest.test_mock_call_repr_loopcCst�}|�t�g|jv�dSr)rr8rr�r�rrr�test_mock_calls_contains�sz!MockTest.test_mock_calls_containscCshGdd�dt�}|�}|�|j|�|�|�|�Gdd�dt�}|�}|�|j|�|�|�|�dS)Nc@seZdZdS)�+MockTest.test_subclassing.<locals>.SubclassNr]rrrr�Subclass�srOc@seZdZdd�ZdS)rNc[stfi|��Sr)r)rrhrrr�_get_child_mock�sz;MockTest.test_subclassing.<locals>.Subclass._get_child_mockN)r r!r"rPrrrrrO�s)rr�rS�assertNotIsInstance)rrOrrrr�test_subclassing�szMockTest.test_subclassingcs�t�t�t�t�g}�fdd�}|D]z}||�t|�rb|�|dd�|dd�|��||�|��|jjddd�|�d����d�|��||�q$dS)Ncs@d}|D]2}t||�}��|t���|t���|g�qdS)N)r?r@r�)r�r�rr�r:)r�namesrU�attrrrr�assert_attrs�s
z-MockTest.test_arg_lists.<locals>.assert_attrsrLrjrkr2)	rr
rr
�callabler�rSrVrZ)rr[rUrrrr�test_arg_lists�s&�

zMockTest.test_arg_listscCs�t�}|ddd�|ddd�|�t|j�d�|�|jjd�|�|jjtdd��dtdd�fdtdd�fg}t||j�D]@\}}|�t|�d�|�|d	|d	�|�|d|d�q~dS)
NrLrkr2rjr��r')rj�rLr)	rr:�lenr>rgrhr>�zipr?)rrZ
expected_listr:r>rrr�test_call_args_two_tuple�sz!MockTest.test_call_args_two_tuplecCsttgd��d�}|�|�|�|�ggd��|�t|�tgd�d�}|�|�|�|�ggd��|�t|�tdd�}|�|�|�|�ggd��|�t|�Gdd�dt�}t|d�}|�|�|�tt�d�}|�|�|�|�|�ggd��|�t|�dS)	Nrnrtr�Zghi)�g�h�ic@seZdZdS)z/MockTest.test_side_effect_iterator.<locals>.FooNr]rrrrr��sr�r)	rrr:rQr�r
rcr�r)rrr�rrr�test_side_effect_iterator�s"

�z"MockTest.test_side_effect_iteratorcCs\ttfD]N}tdtdf}||d�}|�t|�|�|�d�|�t|�|�|�d�qdS)Nrkr�rt)rr
r{r1rQr:)r�Klass�iterabler�rrr�$test_side_effect_iterator_exceptions
s
z-MockTest.test_side_effect_iterator_exceptionscCs�t�}tgd��|_|�|�|�|�ggd��|�t|�|j}|�|ttg���gd�|_|�|�|�|�ggd��|�t|�|j}|�|ttg���t�}||_|�|�|�|�|�ggd��|�t|�|�	|j|�dS)Nrnr�r)
rrrPr:rQr�r�rrr�)rrrPZ	this_iterrrr�!test_side_effect_setting_iterators$
�z*MockTest.test_side_effect_setting_iteratorcCs4tdd�}tdtg�|_|�|�|�gddg�dS)NrjrIrL)rrrrPr:rGrrr�!test_side_effect_iterator_default)s
z*MockTest.test_side_effect_iterator_defaultcCs�t�}|dd�|dd�|dd�|dd�|dd�tdd�ddifd	d
ddifddddifdd
ifdd
ddifg}|D]}|j|gdd�q|tdd�tdd�t�dddfD]}|jt|j|gdd�q�tdd�tdd�gtdd�tdd�gtdd�tdd�gg}|D]}|j|dd��q
tdd�tdd�tdd�gtdd�tdd�gtdd�tdd�tdd�gtdd�tdd�tdd�tdd�tdd�gg}|D]}|jt|j|dd��q�dS)NrLrjrkr2r�r�rXr&�)rkr�r)r<�rLrjr<rgT�Z	any_orderr8rSr��)rr�assert_has_callsrQr�)rr�kalls�kallZ
kall_listsZ	kall_listrrr�test_assert_has_calls_any_order.sD




�"��*��z(MockTest.test_assert_has_calls_any_orderc	
Cs�tdd�ddifdtdd�dd	d
difg}t��t�d�g}|�t��jdd����|�tjt�id��	dg����g}t
�t�fD]F}|dd�|dd�|dd
�|dd�|ddd�|�||f�q�t
�}|��|�d�|��jdd�|jt�id��	dg�|�||f�|D]j\}}t
t|��D]R}dD]F}||||�}|�|�t|�dk�r>|�t|jtt|����q>�q6�q"dS)NrLrjr&rkrfr�rXr<rYr'r2rr�rn)rrSrV�extendr�rZr?Zbamr"rmrr
r��rangerZrjrQr�r��reversed)	rZkalls1Zkalls2r[rrkr_�stepZtheserrr�test_assert_has_callsZs@
�"






�zMockTest.test_assert_has_callsc	CsFGdd�d�}t|�}||�fD]H}|jddddd�|�tjddddd�g�|�t�dddd�g�q |��||�fD]l}|�t|jt��g�|�d��dd�|�t�d�t�d��dd�g�|j�td�t��dd�g�q||��t�d�t�	d�t���	d�t���dddd�g}|D]}|�t|j|g��q(dS)Nc@s,eZdZdd�Zddd�ZGdd�d�ZdS)	z=MockTest.test_assert_has_calls_nested_spec.<locals>.SomethingcSsdSrrrrrrr�r+zFMockTest.test_assert_has_calls_nested_spec.<locals>.Something.__init__NcSsdSrrr%rrrr*�r+zBMockTest.test_assert_has_calls_nested_spec.<locals>.Something.methc@seZdZdd�Zdd�ZdS)zAMockTest.test_assert_has_calls_nested_spec.<locals>.Something.FoocSsdSrrr�rrrr�r+zJMockTest.test_assert_has_calls_nested_spec.<locals>.Something.Foo.__init__cSsdSrr)rr&r'rrr�meth1�r+zGMockTest.test_assert_has_calls_nested_spec.<locals>.Something.Foo.meth1N)r r!r"rrsrrrrr��sr�)N)r r!r"rr*r�rrrrr$�s
r$rLrjrk�r)r�)
rr*rjrr�rQr�r�rsZnon_existent)rr$Z
mock_classr�Z
invalid_callsrlrrr�!test_assert_has_calls_nested_spec�s.
" ��z*MockTest.test_assert_has_calls_nested_speccCsJt�}|�������|������t��������}|�	|�dSr)
r
rSrVrZrr�threerr?rj)rr��callsrrr�)test_assert_has_calls_nested_without_spec�s
z2MockTest.test_assert_has_calls_nested_without_speccCs�ddd�}t|d�}|dddd�|dd	d
dd�|d
ddd�ddifddddifdifg}|�|�|j|dd�|�|dd��|j|dd�dd�|�|dd��|j|dd�dd�tt|��}|�t��|�|�Wd�n1s�0Y|j|dd�|�t��"|�|dd��Wd�n1�sH0Y|j|dd�dd�|�t��"|�|dd��Wd�n1�s�0Y|j|dd�dd�dS)NcSsdSrrr.rrrrK�r+z<MockTest.test_assert_has_calls_with_function_spec.<locals>.fr_rLrjrkr�r�r�r�ri�r(r)�
��)r(r<rn)r�r�r�r))rzr{r|Trhr=)N)rrjr�rprQr�)rrKrrwrrr�(test_assert_has_calls_with_function_spec�s2

�
(22z1MockTest.test_assert_has_calls_with_function_speccCs�d	dd�}t|d�}|d�|�td�t�d����}|�t�g�Wd�n1sX0Y|�|j	j
�|�td�t�d����&}|�t�tdd�g�Wd�n1s�0Y|�|j	j
t�dS)
NcSsdSrrr�rrrrK�r+zAMockTest.test_assert_has_calls_not_matching_spec_error.<locals>.fr_rLz^{}$z5Calls not found.
Expected: [call()]
Actual: [call(1)]z�Error processing expected calls.
Errors: [None, TypeError('too many positional arguments')]
Expected: [call(), call(1, 2)]
Actual: [call(1)]rj)N)
rr|r�r�r�r�rjrrCr�r�r�rOr�rrr�-test_assert_has_calls_not_matching_spec_error�s.

��,���4z6MockTest.test_assert_has_calls_not_matching_spec_errorcCs�t�}|dd�|dd�|ddd�|�dd�|jdd�|jddd�|�t|j�|�t|jdd�|jt|jdd�dS)NrLrjrkr2r�rXr�)r�assert_any_callrQr�rGrrr�test_assert_any_call�s*

���zMockTest.test_assert_any_callcCs�ddd�}t|d�}|dddd�|dd	d
dd�|�ddd�|jdddd
�|�dd	d
d�|jdd	d
dd�|jt|jdddd�|�t��}|jdd�Wd�n1s�0Y|�|jjt�dS)NcSsdSrrr.rrrrKr+z;MockTest.test_assert_any_call_with_function_spec.<locals>.fr_rLrjrkr�r�r�r�riryr�r.r�r�)N)rrrQr�r�r�r�rOr�rrr�'test_assert_any_call_with_function_specs


�*z0MockTest.test_assert_any_call_with_function_speccCsfdd�}t�}||_t|�t|�jg}|D]6}|dd�|dd�|�|jtdd�tdd�g�q*dS)NcSsdSrrr�rrrrKr+z3MockTest.test_mock_calls_create_autospec.<locals>.frLrjrkr�)rrKrr:r�r)rrKr�Zfuncsr5rrr�test_mock_calls_create_autospecs�

�z(MockTest.test_mock_calls_create_autospeccCs$tjt�dd�}|�dt|��dS)NZ
sweet_funcrT)rrrcrWrXr�rrr�test_create_autospec_with_name+sz'MockTest.test_create_autospec_with_namec	CstGdd�d�}dD]\}|j|d��<t�t||��}|�|��|�t|d�Wd�q1sd0YqdS)Nc@s$eZdZedd��Zedd��ZdS)zMMockTest.test_create_autospec_classmethod_and_staticmethod.<locals>.TestClasscSsdSrr)r,rrr�class_method2szZMockTest.test_create_autospec_classmethod_and_staticmethod.<locals>.TestClass.class_methodcSsdSrrrrrr�
static_method5sz[MockTest.test_create_autospec_classmethod_and_staticmethod.<locals>.TestClass.static_methodN)r r!r"r0r�r1r�rrrr�	TestClass1s
r�)r�r�)r�Z	extra_arg)ZsubTestrrr�r�rQrO)rr�r�Zmock_methodrrr�1test_create_autospec_classmethod_and_staticmethod0sz:MockTest.test_create_autospec_classmethod_and_staticmethodcCs�t�}d}|�t|��|��Wd�n1s40Y|�t|��|��Wd�n1sh0Ytdd�}|��|��dS)Nz1Attributes cannot start with 'assert' or 'assret'T)Zunsafe)rr|r�Zassert_foo_callZassret_foo_call)rr�r�rrr�test_mock_unsafe?s&&
zMockTest.test_mock_unsafecCsPt�}|j��|��|�t��|j��Wd�n1sB0YdSr)r�hello�assert_not_calledrQr�r�rrr�test_assert_not_calledKs

zMockTest.test_assert_not_calledcCs*t�}|dd�|�tt�d�|j�dS)NrLrjzCalls: [call(1, 2)])rr|r�r�r�r�r�rrr�test_assert_not_called_messageRs
�z'MockTest.test_assert_not_called_messagecCsbt�}|�t��|j��Wd�n1s00Y|��|j��|��|j��dSr)rrQr�r�r�r�rrr�test_assert_calledYs(
zMockTest.test_assert_calledcCs�t�}|�t��|j��Wd�n1s00Y|��|j��|��|�t��|j��Wd�n1s~0YdSr)rrQr�r��assert_called_oncer�rrr�test_assert_called_oncecs(
z MockTest.test_assert_called_oncecCs2t�}|dd�|d�|�tt�d�|j�dS)NrLrjrkzCalls: [call(1, 2), call(3)])rr|r�r�r�r�r�rrr�test_assert_called_once_messagens
�z(MockTest.test_assert_called_once_messagecCsNt�}|�t��}|��Wd�n1s.0Y|�dt|j��dS)NzCalls:)rrQr�r�rAr3r�)rr�r�rrr�*test_assert_called_once_message_not_calledvs&z3MockTest.test_assert_called_once_message_not_calledcCs0t�}|jddd�d}|�t|jj�|�dS)Nr�Zhero)rUZdaddyz call(name='hello', daddy='hero'))rr�r:rXr>)rr��textrrr�test_ordered_call_signature}sz$MockTest.test_ordered_call_signaturecCsVt��}t�dd�}t�}|��|�dd�|�|jd|�|�|jd|�dS)N�r�rrL)rr*r�rr:r@)rr(r_r�rrr�test_override_tuple_methods�sz$MockTest.test_override_tuple_methodscCs>tdddgd�}|jddd�|�|jt�|�|jd�dS)Nrzrjrk�r=rPT)rr�r�r=r:rPr�rrr�test_reset_return_sideeffect�sz%MockTest.test_reset_return_sideeffectcCs<tdddgd�}|jdd�|�|jt�|�|jd�dS)Nrzrjrkr�TrI)rr�r�r=r�rPr�rrr�test_reset_return�szMockTest.test_reset_returncCs<tdddgd�}|jdd�|�|jd�|�|jd�dS)Nrzrjrkr�Trt)rr�r:r=rPr�rrr�test_reset_sideeffect�szMockTest.test_reset_sideeffectcCs@ttdd�d�}|�|��d�|jdd�|�|��d�dS)NrLrI�rKT)r
r:rKr�r�r�rrr�test_reset_return_with_children�sz(MockTest.test_reset_return_with_childrencCsDttddgd�d�}|�|jjd�|jdd�|�|jjd�dS)Nrjrkrtr�T)r
r�rKrPr�r:r�rrr�+test_reset_return_with_children_side_effect�sz4MockTest.test_reset_return_with_children_side_effectc	s�Gdd�dt�}Gdd�dt�}Gdd�dt��ttttg}t|�D]0}|�|f�fdd�	�|�|f�fd	d�	�qD|D�]
}t�td
d�fD]�}|�}|j|j	|j
f||fdgd
gffD]�\}}t�td
d�fD]�}|j|fi|��|j|�t
t|d
�|�t
t|d�d|v�r.|�t
t|dd�|j|fi|��|�t
t|d�|j	|�t
t|d�d|vr�|�t
t|dd�q�q�q�qzdS)Nc@seZdZdZdS)z)MockTest.test_mock_add_spec.<locals>._OnerLN)r r!r"rrrrr�_One�sr�c@seZdZdZdS)z)MockTest.test_mock_add_spec.<locals>._TworjN)r r!r"rrrrr�_Two�sr�c@seZdZdZZZdS)z-MockTest.test_mock_add_spec.<locals>.AnythingZfourN)r r!r"rrrvrrrr�Anything�sr�cs
|�d�S)Nr_r��K�r�rrr��r+z-MockTest.test_mock_add_spec.<locals>.<lambda>cs
|�d�S)Nrarr�r�rrr��r+Trarrrvrb)rcrr
rr
r�r�r>rrrv�
mock_add_specrQr�r��setattr)	rr�r�ZklassesrarhrZOneZTworr�r�test_mock_add_spec�sL�
��

���
�zMockTest.test_mock_add_speccs|ttfD]n}|��t����t�|�tt��|���dd�j_��t�|�	t��d�|�t�fdd��qdS)NrSr�cs�dSr�rrrrrr��r+z;MockTest.test_mock_add_spec_magic_methods.<locals>.<lambda>)
r
r
rr�rcrQrOr@r=r:)rrarrr� test_mock_add_spec_magic_methods�s

z)MockTest.test_mock_add_spec_magic_methodscCs�tttttfD]�}|�}t�|_|��|�|jt��g�|�|j	t��g�|�}tdd�|_
|�
�|�|jg�|�|j	g�|�}t��|_|��|�|jg�|�|j	g�qdS)NrUrT)rrr
r
rrSr:r@rr�rVrZ�rrarrrr�test_adding_child_mock�s$�
zMockTest.test_adding_child_mockcCs@ttfD]2}|�}t�|_|��|�|jt�t��g�qdSr)rr
r=r:r�rr�rrr�test_adding_return_value_mock
s
z&MockTest.test_adding_return_value_mockcCs�Gdd�dt�}t�}t�|d�}t�|d�}|��}|�|j�|��}|�|j�|�|d�|�|d�|��|��|�	|j
t��t��g�dS)Nc@seZdZdZdZdS)z'MockTest.test_manager_mock.<locals>.FoorrN)r r!r"rrrrrrr�sr�rr)rcrrr,rr-�attach_mockrrr:r�r)rr��managerZp1Zp2Zmock_oneZmock_tworrr�test_manager_mockszMockTest.test_manager_mockcCshttfD]Z}|�}tdd�|_tdd�|_t|�t|�|�|jt��t��g�|�|j	g�qdS)NrkrIg@)
rr
r@�	__float__r�floatr:r�rr@)rrar�rrr�test_magic_methods_mock_calls)sz&MockTest.test_magic_methods_mock_callscCs<tjdd�}|d�}|��}|d�}|��}|�||�dS)Nr��Z	read_data�a-namezanother-name)rr��readr:)r�mocked_open�f1Zf1_data�f2Zf2_datarrr� test_mock_open_reuse_issue_217504sz)MockTest.test_mock_open_reuse_issue_21750cCsVtjdd�}|d�}dd�|D�}|�|dd�|�|dd	�|�t|�g�dS)
NzRemarkable
Norwegian Bluer�r�cSsg|]}|�qSrr�r �linerrrr!Ar+z=MockTest.test_mock_open_dunder_iter_issue.<locals>.<listcomp>rzRemarkable
rLzNorwegian Blue)rr�r:r�)rr�r��linesrrr� test_mock_open_dunder_iter_issue<sz)MockTest.test_mock_open_dunder_iter_issuecCs�tjdd�}|d�}t|�}|��}dd�|D�}|�|d�|�|d�|�|dd	�|�t|�g�|�t��t|�Wd�n1s�0YdS)
Nz1st line
2nd line
3rd liner�r�cSsg|]}|�qSrrr�rrrr!Kr+z6MockTest.test_mock_open_using_next.<locals>.<listcomp>z	1st line
z	2nd line
rz3rd line)rr�rr#r:r�rQr�)rr�r�Zline1Zline2r�rrr�test_mock_open_using_nextFsz"MockTest.test_mock_open_using_nextcCs,tjdd�}d|jj_|�dt|���dS)N�foo
barnr��abc)rr�r=�readliner:r)r�mopenrrr�3test_mock_open_next_with_readline_with_return_valueSs
z<MockTest.test_mock_open_next_with_readline_with_return_valuecCslt�tjdd��}t�d|��:|j}|j}td�|_dd�}|�t|�Wd�n1s^0YdS)NZJLVrTztempfile.NamedTemporaryFilezTest 2 ErrorcSst���d�dS)NZasd)�tempfile�NamedTemporaryFile�writerrrr�attempt_sz.MockTest.test_mock_open_write.<locals>.attempt)	rr�r
rr=r��OSErrorrPrQ)rZmock_namedtempZmock_filehandleZ
mock_writer�rrr�test_mock_open_writeXs
zMockTest.test_mock_open_writecCsJtjdd�}dd�|jj_|���}|���}|�d|�|�d|�dS)Nr�r�cWsdS)Nr�r)rgrrrr�er+z8MockTest.test_mock_open_alter_readline.<locals>.<lambda>r�)rr�r=r�rPr:)rr��first�secondrrr�test_mock_open_alter_readlinecs

z&MockTest.test_mock_open_alter_readlinecCs�tjdd�}|d�}|��|�d|���|�d|���|�d|���|�d|���|�g|���|�g|���dS)NrSr�rVr<)rr�r�r:r��	readlines)r�_openr^rrr�test_mock_open_after_eofksz!MockTest.test_mock_open_after_eofcCs
ttfD]�}|�}t|�}||_|�|�|�|�t|�|�|��|�|�|�|�t|�|�|�}|j|_|�	dt|j��|�	dt|j��|��|�	dt|j��|�	dt|j��|�}t|�}|�|_||j_|�t|�|�|�t|���|�qdS)Nz
name='mock.a')
rr
rXr=r�r:r�r&r'rW)rrar�Z
original_reprrrr�test_mock_parentsws,zMockTest.test_mock_parentscCs�ttttf}|D]�}|D]z}|�}|dd�}|�|d�|�|j|�|�dt|��|j�	d�|�
|jtj�	d�g�|�
|j
tj�	d�g�qqdS)NrSrTrVzname='mock.bar'rL)rr
r
rr�r�rVrWrXrZr:r�rr@�r�classesraZKlass2r�Zm2rrr�test_attach_mock�s
zMockTest.test_attach_mockcCs�ttttf}ttfD]h}|D]^}|�}|dd�}|�|d�|�|�|�|�dt|��|��|�	|j
t������qqdS)NrSrTr=z
name='mock()')
rr
r
rr�r�rWrXrSr:r�rr?r�rrr�test_attach_mock_return_value�s
z&MockTest.test_attach_mock_return_valuecCst�}tjt�d�dd���}|�|j��d�|�|d�|�d�td�|d�t	�d�t	�d�t	�d�g}t	d�t	d�t	d�g}|�|j
|�|�|jj
|�|�tj
|�|�|j
|�|�d	t|jj��|�|j��d	�Wd�n1s�0YdS)
N�
.somethingT�Zautospecr3r~rLrjrk�
mock.child)
rrrr r:Z_extract_mock_namer�r~r3rr�rWrX)rrZ	mock_funcZparent_callsZchild_callsrrr�test_attach_mock_patch_autospec�s
z(MockTest.test_attach_mock_patch_autospecc
Cs�tjt�d�dd���}t�}|�|d�t�}|jddddd	�|�tj	tj
ddddd	�g�|j�ttj
ddddd	�g�|�ttj
ddddd	�g�Wd�n1s�0Ytjt�d
�dd��\}t�}|�|d�td�|�t�d�g�t�td�g�|�td�g�Wd�n1�s.0Ytjt�d�dd���}t�}|�|d
�t�}|jddddd	�|�t�
�t�
�jddddd	�g�|j�tddddd	�g�|�t�t�jddddd	�g�Wd�n1�s�0YdS)Nz.Something.methTr��attach_methrLrjrkr�rtr��attach_funcz
.Something�
attach_obj)rrr rr�r$r*rjrr�r�r3r�r�)rZmockedr�r�rrr�)test_attach_mock_patch_autospec_signature�s2:0
�z2MockTest.test_attach_mock_patch_autospec_signaturecCsft�t�t�t�fD]L}|�t|d��|`|�t|d��|`|�t|d��|�	t
t|d�qdS)Nr�rK)rr
r
rr<�hasattrr�r8rKrQr�r�rGrrr�test_attribute_deletion�s�z MockTest.test_attribute_deletioncCs�t�t�t�t�fD]t}d|_|�t|d��|�|jd�|`|�t|d��d|_|�t|d��|�|jd�|`|�t|d��qdS)NrkrSr�)	rr
r
rrSr<r�r:r8rGrrr�7test_mock_does_not_raise_on_repeated_attribute_deletion�s�z@MockTest.test_mock_does_not_raise_on_repeated_attribute_deletionc	CsPt�t�t�t�fD]6}|`|�t��|`Wd�q1s@0YqdSr)rr
r
rrSrQr�rGrrr�4test_mock_raises_when_deleting_nonexistent_attributes�z=MockTest.test_mock_raises_when_deleting_nonexistent_attributecCs,t�}d|_|`|��|�t|d��dS)NTr~)rr~r�r8r�rGrrr�/test_reset_mock_does_not_raise_on_attr_deletions
z8MockTest.test_reset_mock_does_not_raise_on_attr_deletioncCs:t�t�fD](}|�|t�t|_|�|t�|jqdSr)rr
rQrr�r�rSrGrrr�test_class_assignables
zMockTest.test_class_assignablecCs8|�tj�|�ttj�t�|�tt��j�t�dSr)�assertIsNotNonerrUr:rrrrrr�test_name_attribute_of_call sz$MockTest.test_name_attribute_of_callcCs8|�tj�|�ttj�t�|�tt��j�t�dSr)r�rrr:rrrrrr�test_parent_attribute_of_call'sz&MockTest.test_parent_attribute_of_callcCsddd�}t�}t|�|_|�dd�|�t|jd�|�|jt�dd�g�|�dt	|jj
��dS)NcSsdSrrr�rrrrS1r+zBMockTest.test_parent_propagation_with_create_autospec.<locals>.foorLrjr�)rrr~rQrOr:r�rrWrXr)rrSrrrr�,test_parent_propagation_with_create_autospec/s
z5MockTest.test_parent_propagation_with_create_autospeccCspdd�}t�}|�t|dd�d�|�dd�|�t|jd�|�|jjt�dd�g�|�	dt
|jj��dS)	NcSsdSrrr�rrrrS=r+zGMockTest.test_parent_propagation_with_autospec_attach_mock.<locals>.foorVrTr~rLrjr�)rr�rr~rQrOr:r�rrWrXr)rrSrrrr�1test_parent_propagation_with_autospec_attach_mock;sz:MockTest.test_parent_propagation_with_autospec_attach_mockc	s�tjj}|�dd�|�t�d���tjd=�fdd��|�tjt���t���ddl	m
}m}m}m
}||||tg}|D]}|td	�}|�|t�q~Wd�n1s�0YdS)
NcSsttjd|�S)Nr)r�r(r)rrrrr�Vr+z9MockTest.test_isinstance_under_settrace.<locals>.<lambda>zsys.modulesz
unittest.mockcs�Srr)�frame�eventr���tracerrr�]sz6MockTest.test_isinstance_under_settrace.<locals>.tracer)rr
rr
r_)r(rrrr>r�modules�settrace�gettrace�
unittest.mockrr
rr
rr$r�)	rZ	old_patchrr
rr
r[rr�rr�r�test_isinstance_under_settraceHs	
�

�
z'MockTest.test_isinstance_under_settracecCs^Gdd�d�}|�}tjjj|ddd��Wd�n1s>0Y|�|jjjd�dS)Nc@seZdZdd�ZdS)zFMockTest.test_bool_not_called_when_passing_spec_arg.<locals>.SomethingcSstj��|_dSr)r(rr
�obj_with_bool_funcrrrrrqszOMockTest.test_bool_not_called_when_passing_spec_arg.<locals>.Something.__init__N)r r!r"rrrrrr$psr$r�Tr�r)r(rrrcr:r��__bool__r;)rr$r�rrr�*test_bool_not_called_when_passing_spec_argos4z3MockTest.test_bool_not_called_when_passing_spec_argN)�r r!r"r6rHrJrNrRr\reryrzr}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�r�r�r�r�r�r�r�r�r�rrrrrrr&r+r.r/r2r7r;rArBrDrFrGrIrJrKrLrMrRrWr\r`rcrdrermrrrurxr}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�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr4,s	)&	





!




	8N
#
,((
	5	





'r4�__main__)r	r�rr�Ztest.supportrr(Zunittest.test.testmock.supportrrr�rrrr	r
rrr
rrrrrcrr$r3r)r4r �mainrrrr�<module>s<8

^

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