HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/unittest/test/testmock/__pycache__/testmock.cpython-310.opt-1.pyc
o

�i�)�@s�ddlZddlZddlZddlZddlmZddlZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZGdd�de�ZGdd	�d	e�ZGd
d�d�Zdd
�ZGdd�dej�Zedkrre� �dSdS)�N)�	ALWAYS_EQ)�is_instance��mock)
�call�DEFAULT�patch�sentinel�	MagicMock�Mock�NonCallableMock�NonCallableMagicMock�	AsyncMock�_Call�	_CallList�create_autospec�InvalidSpecErrorc@s(eZdZdd�Zdd�Zdd�ZeZdS)�ItercCstgd��|_dS)N��this�isZan�iter)r�thing��self�r�</usr/local/lib/python3.10/unittest/test/testmock/testmock.py�__init__�z
Iter.__init__cCs|S�Nrrrrr�__iter__�z
Iter.__iter__cCs
t|j�Sr)�nextrrrrrr"�
z	Iter.nextN)�__name__�
__module__�__qualname__rr r"�__next__rrrrrs
rc@s2eZdZddd�Zeddd��Zeddd��ZdS)	�	SomethingNcC�dSrr�r�a�b�c�drrr�meth �zSomething.methcCr)rr)�clsr+r,r-r.rrr�cmeth"r!zSomething.cmethcCr)rr�r+r,r-r.rrr�smeth%r!zSomething.smethr)r$r%r&r/�classmethodr2�staticmethodr4rrrrr(s
r(c@seZdZdZdZdZdS)�TyposN)r$r%r&�	autospect�	auto_spec�set_specrrrrr7)sr7cCr)rr�r+rrr�	something/r0r<c@s|eZdZdd�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
�d�Z��d�d�Z��d�d�Z��dS(�MockTestcCstd�dS)Nzfrom unittest.mock import *)�execrrrr�test_all4szMockTest.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_constructor;s:
��
�
�
�
���
�zMockTest.test_constructorcCstdd�}|�|jd�dS)N�rFz(return value in constructor not honoured)rrLrFrPrrr� test_return_value_in_constructorWs
�z)MockTest.test_return_value_in_constructorcCs*dd�}t|�}d|j_|�|�d�dS)NcSr)rrrrrr�f^r0z9MockTest.test_change_return_value_via_delegate.<locals>.f�)rrrFrC�rrTrrrr�%test_change_return_value_via_delegate]sz.MockTest.test_change_return_value_via_delegatecCsPdd�}t|�}t�|j_|�t��|�Wd�dS1s!wYdS)NcSr)rrrrrrrTer0z8MockTest.test_change_side_effect_via_delegate.<locals>.f)r�	TypeErrorr�side_effect�assertRaisesrVrrr�$test_change_side_effect_via_delegateds
"�z-MockTest.test_change_side_effect_via_delegatecCs�tdd�}|�dt|��|�dt|�t|��t�dftdd�dfg}|D]P\}}|�d|t|j��|�d|t|����|�d|t|��j��|�d	|t|���|�d
|t|����|�d|t|��jj��j��q'dS)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�idr_r\Zbing�baz)rr�mocksr^rrr�	test_reprls

��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@�eZdZdS)z'MockTest.test_repr_with_spec.<locals>.XN�r$r%r&rrrr�X}�rh��specz
 spec='X' ��spec_setz spec_set='X' r\)rkr^z name='foo' r]rk)�objectrr`rarJ�rrhrrrr�test_repr_with_spec|s$


zMockTest.test_repr_with_speccs�t�}dd�}||_|jt|dddd�|jdddd�gd���fdd�}||_|�|�|�|�ggd	�d
�ttjd�}|�|jtjd�d
d�}t|tjd�}|�|�tj�dS)Nc_�td��)NZkablooie)�SystemError)�args�kwargsrrr�effect��z)MockTest.test_side_effect.<locals>.effectrU����fish�rUrwrxc����Sr��popr��resultsrrru�rv�rxrwrUzside effect not used correctly�rYz#side effect in constructor not usedcS�tSr�rrrrrrY�r!z.MockTest.test_side_effect.<locals>.side_effect)rYrF)	rrYrZrr�assert_called_withrCr	�
SideEffect�RETURN)rrrurYrrr�test_side_effect�s$��zMockTest.test_side_effectcs�gd���fdd�}dd�}t|�}gd�|_|�|�|�|�ggd�d�gd��t|�}||_|�|�|�|�ggd�d�dS)	Nr{cr|rr}rrrrru�rvz2MockTest.test_autospec_side_effect.<locals>.effectcSr)rrrrrrrT�r0z-MockTest.test_autospec_side_effect.<locals>.fz1side effect not used correctly in create_autospecr�z'callable side effect not used correctly)rrYrC)rrurTrrrr�test_autospec_side_effect�s
��z"MockTest.test_autospec_side_effectcCs,dd�}t|�}td�|_|�td|�dS)NcSr)rrrrrrrT�r0z7MockTest.test_autospec_side_effect_exception.<locals>.fzBazinga!)r�
ValueErrorrY�assertRaisesRegexrVrrr�#test_autospec_side_effect_exception�s
z,MockTest.test_autospec_side_effect_exceptionc	Cs�Gdd�dt�}tj�|d���|�td��
t|�jWd�n1s&wY|�td��tjj|ddd���Wd�n1sGwY|�td��tjj|jd	dd���Wd�n1siwY|�td
��tjj|d|jd���Wd�n1s�wY|�td��tjj|d|jd
���Wd�n1s�wYWd�dSWd�dS1s�wYdS)Nc@seZdZGdd�de�ZdS)z&MockTest.test_autospec_mock.<locals>.Ac@seZdZdZdS)z(MockTest.test_autospec_mock.<locals>.A.BN)r$r%r&�Crrrr�B��r�N)r$r%r&rnr�rrrr�A�sr�r�z8Cannot autospec attr 'B' from target <MagicMock spec='A'z(Cannot autospec attr 'B' from target 'A'T�Zautospecz-Cannot autospec attr 'C' as the patch target r�z!Cannot spec attr 'B' as the spec rjz%Cannot spec attr 'B' as the spec_set rl)rnrrr�rrr��start)rr�rrr�test_autospec_mock�s<�����������
"�zMockTest.test_autospec_mockcCsRt�}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)Nr<�child)r^�parentrk�r<zname 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
SomethingElser<r�rYrF�
reset_mockrC�
_mock_namerMrNrArBrDrGrHrI�
mock_callsrO)rr�rkrr<rFrrr�test_reset_mock�sV
�
�
�
���
��
�zMockTest.test_reset_mockcCst�}||_|��dSr)rrFr�rPrrr�test_reset_mock_recursionsz"MockTest.test_reset_mock_recursioncCst��}|��dSr)r�	mock_openr��rr+rrr�(test_reset_mock_on_mock_open_issue_18622sz1MockTest.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 setrUzcall_count incorrectzcall_args not setr@)�keyzincorrect return valuerwr�zcall_args_list not set)rrErrFrCr�r	�ArgrBrDrGrsrtrHZReturnValueZKeyArg)rr�resultZret_valrrr�	test_callsP�
�
����
��
��zMockTest.test_callc	Cs�t�}|�|tj�|tjd�|tjtjd�|�|jdtjffdtjiftjfdtjifg�|�|jtjfdtjif�|�|jjtjf�|�|jjdtji�|�	|jdk�dS)N)�kwrr�za long sequence)
rr	r�ZKwargrCrHrGrsrtrArPrrr�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)NrU)rr
rErA�ANYrr)rZmmZcall1Zcall2rrr�test_calls_equal_with_anyVs*z"MockTest.test_calls_equal_with_anycCsdt�}|�|��|�t|jd�|��|�t|j�|dddddd�|jdddddd�dS)NrUrwrxrzZnothing�r+r,)rr�rZ�AssertionErrorr�rPrrr�test_assert_called_withrsz MockTest.test_assert_called_withcCs t�}|t��|�tj�dSr)r
r�rr��r�mrrr�test_assert_called_with_any�s
z$MockTest.test_assert_called_with_anycCs�ddd�}t|d�}|dddd�|�ddd�|jdddd�|jt|jdddd�|�t��}|jd	d
�Wd�n1sAwY|�|jjt�dS)NcSr)rrr3rrrrT�r0z9MockTest.test_assert_called_with_function_spec.<locals>.frjrUrwrx�r,r-�r+r,r-���er)rr�rZr��assertIsInstance�	exception�	__cause__rX�rrTr�cmrrr�%test_assert_called_with_function_spec�s


��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)NrUrwrxr�r�)r�rZr�rrrr�_check�s

�z<MockTest.test_assert_called_with_method_spec.<locals>._checkrj)rr(r/r2r4)rr�rrrr�#test_assert_called_with_method_spec�sz,MockTest.test_assert_called_with_method_speccCs�d}|�t|�d���
t���Wd�n1swY|�t|�d���tdd���Wd�dS1s<wYdS)Nz"Expected '{0}' to have been calledrZ	test_namer])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)Nr\r_rw�rccs�jdddd�S)N�bobr_rwr���assert_called_once_withrrrr�<lambda>��z7MockTest.test_assert_called_once_with.<locals>.<lambda>)rr�rZr�r�rrrr�test_assert_called_once_with�s
�z%MockTest.test_assert_called_once_withcs6t���d��d�|�tt�d��fdd��dS)NrUrwzCalls: [call(1), call(2)]cs
��d�S)Nrwr�r�r�rrr���
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�n1sAwY|�|jjt�|ddd
�|�t|jddd�|�t|jddd
�dS)NcSr)rrr3rrrrT�r0z>MockTest.test_assert_called_once_with_function_spec.<locals>.frjrUrwrxr�r�r�r����r)rr�rZr�r�r�r�rXr�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 namerxzmethod returned wrong valuez!method didn't record being called)rr<rErrCrFrB�rrr<rrr�#test_attribute_access_returns_mocks�s
�
�z,MockTest.test_attribute_access_returns_mockscCs0t�}|j}|�|jdd�|�|j|d�dS)Nr<z attribute name not set correctlyz"attribute parent not set correctly)rr<rCr�rMr�rrr�(test_attributes_have_name_and_parent_set�s
�
�z1MockTest.test_attributes_have_name_and_parent_setcCstt�}|jddd�|jjdtjd�|�|jjdddtjifgd�|�|jdd	d
difdddtjifgd�dS)Nrxryr�)�caker<)r�r�z#method calls not recorded correctly)rxrzzsomething_else.something)rr<�something_elser	ZCakerCrIrPrrr�test_method_calls_recordeds
���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�r<r�	different)r<�r�r�rU��xr�Zmore)�somer�)rr<rCrIrPrrr� test_method_calls_compare_easilys&

�
�z)MockTest.test_method_calls_compare_easilyc	CsHdgdfD]}dD]}tdi||i��}|j|�tdt|d�q	qdS)Nr<r�)rkrmz-Mock object has no attribute 'something_else'r�r)rr<r��AttributeError�getattr)rrk�argrrrr�test_only_allowed_methods_exist*s���z(MockTest.test_only_allowed_methods_existcs>Gdd�dt�}�fdd�}|t|d��|t|�d��dS)Nc@seZdZdZdZdd�ZdS)z*MockTest.test_from_spec.<locals>.SomethingrxNcSr)rrrrrr�y<r0z,MockTest.test_from_spec.<locals>.Something.y)r$r%r&r��
__something__r�rrrrr(9sr(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_attributesrj)rnr)rr(r�rrr�test_from_spec8szMockTest.test_from_speccCsJt�}t|d�}|�|�|��|��|dddd�|jdddd�dS)N��wrapsrUrwrxry)rrCr�r��r�realrrrr�test_wraps_callsRs
zMockTest.test_wraps_callscs8Gdd�dt�}|�}t|d��|�t�fdd��dS)Nc@rf)zFMockTest.test_wraps_prevents_automatic_creation_of_mocks.<locals>.RealNrgrrrr�Real_rir�r�cr|r)Znew_attrrrrrr�e�zJMockTest.test_wraps_prevents_automatic_creation_of_mocks.<locals>.<lambda>)rnrrZr�)rr�r�rrr�/test_wraps_prevents_automatic_creation_of_mocks^s
z8MockTest.test_wraps_prevents_automatic_creation_of_mockscCs4t�}t|d�}d|_|�|�d�|�|j�dS)Nr�rx)rrFrCrArBr�rrr�,test_wraps_call_with_nondefault_return_valuehs

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�ss
r�r�c��jSrryrrrrr�z�z0MockTest.test_wraps_attributes.<locals>.<lambda>rUrwrxry)	rnrrCr�rZr��assertNotEqualZfrogr�)rr�r�r�rrr�test_wraps_attributesrs
zMockTest.test_wraps_attributescCsdGdd�dt�}|�}t|d�}tjtg|j_|�|��tj�|�|��tj�|�	t
|j�dS)Nc@�eZdZdd�ZdS)z[MockTest.test_customize_wrapped_object_with_side_effect_iterable_with_default.<locals>.RealcS�tjSr)r	�ORIGINAL_VALUErrrr�method��zbMockTest.test_customize_wrapped_object_with_side_effect_iterable_with_default.<locals>.Real.methodN�r$r%r&r�rrrrr���r�r�)rnrr	�VALUE1rr�rYrCr�rZ�
StopIteration�rr�r�rrrr�Dtest_customize_wrapped_object_with_side_effect_iterable_with_default�s
zMMockTest.test_customize_wrapped_object_with_side_effect_iterable_with_defaultcCsfGdd�dt�}|�}t|d�}tjtjg|j_|�|��tj�|�|��tj�|�t	|j�dS)Nc@r�)zNMockTest.test_customize_wrapped_object_with_side_effect_iterable.<locals>.RealcSr)rrrrrrr��r0zUMockTest.test_customize_wrapped_object_with_side_effect_iterable.<locals>.Real.methodNr�rrrrr��r�r�r�)
rnrr	r��VALUE2r�rYrCrZr�r�rrr�7test_customize_wrapped_object_with_side_effect_iterable�s
z@MockTest.test_customize_wrapped_object_with_side_effect_iterablecCs:Gdd�dt�}|�}t|d�}t|j_|�t|j�dS)Nc@r�)zOMockTest.test_customize_wrapped_object_with_side_effect_exception.<locals>.RealcSr)rrrrrrr��r0zVMockTest.test_customize_wrapped_object_with_side_effect_exception.<locals>.Real.methodNr�rrrrr��r�r�r�)rnr�RuntimeErrorr�rYrZr�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@r�)zNMockTest.test_customize_wrapped_object_with_side_effect_function.<locals>.RealcSr)rrrrrrr��r0zUMockTest.test_customize_wrapped_object_with_side_effect_function.<locals>.Real.methodNr�rrrrr��r�r�cSr�r)r	�VALUErrrrrY�r�zUMockTest.test_customize_wrapped_object_with_side_effect_function.<locals>.side_effectr�)rnrr�rYrCr	r)rr�rYr�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@r�)zFMockTest.test_customize_wrapped_object_with_return_value.<locals>.RealcSr)rrrrrrr��r0zMMockTest.test_customize_wrapped_object_with_return_value.<locals>.Real.methodNr�rrrrr��r�r�r�)rnrr	rr�rFrCr�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@r�)zVMockTest.test_customize_wrapped_object_with_return_value_and_side_effect.<locals>.RealcSr)rrrrrrr��r0z]MockTest.test_customize_wrapped_object_with_return_value_and_side_effect.<locals>.Real.methodNr�rrrrr��r�r�r�)rnrr	r�r�r�rYZWRONG_VALUErFrCrZr�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@r�)zWMockTest.test_customize_wrapped_object_with_return_value_and_side_effect2.<locals>.RealcSr)rrrrrrr��r0z^MockTest.test_customize_wrapped_object_with_return_value_and_side_effect2.<locals>.Real.methodNr�rrrrr��r�r�r�cSr�rr�rrrrr��r0z[MockTest.test_customize_wrapped_object_with_return_value_and_side_effect2.<locals>.<lambda>)rnrr�rYr	rrFrCr�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@r�)z^MockTest.test_customize_wrapped_object_with_return_value_and_side_effect_default.<locals>.RealcSr)rrrrrrr��r0zeMockTest.test_customize_wrapped_object_with_return_value_and_side_effect_default.<locals>.Real.methodNr�rrrrr��r�r�r�)rnrr	r�rr�rYr�rFrCrZr�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)Nr\r_r�rFrc�spam)r
rC�getr�rArFr	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@�eZdZdd�Zdd�ZdS)z3MockTest.test_magic_method_wraps_class.<locals>.FoocSs|Srr)r�indexrrr�__getitem__r!z?MockTest.test_magic_method_wraps_class.<locals>.Foo.__getitem__cS�dS�Nr\rrrrr�__custom_method__r!zEMockTest.test_magic_method_wraps_class.<locals>.Foo.__custom_method__N)r$r%r&rrrrrr�Foo
srr�rwr\)r
rCrr)rr�klass�objrrr�test_magic_method_wraps_classs
	z&MockTest.test_magic_method_wraps_classcC�4ttd�}|�t|�ttd�d�}|�t|�dS�Nr�r\)rr�rZrPrrr�test_exceptional_side_effect�
z%MockTest.test_exceptional_side_effectcCrr)r�KeyboardInterruptrZrPrrr� test_baseexceptional_side_effect%rz)MockTest.test_baseexceptional_side_effectcCst�}|�td|j�dS)Nz
not called)rr�r�r�rPrrr�test_assert_called_with_message-s�z(MockTest.test_assert_called_with_messagecCstdd�}|�td|j�dS)NZgeoffreyr]z'Expected 'geoffrey' to be called once\.)rr�r�r�rPrrr�$test_assert_called_once_with_message3s

�z-MockTest.test_assert_called_once_with_messagecs2t��|�t�fdd��d�_|��jd�dS)Ncr�r)r$rrrrr�<r�z'MockTest.test__name__.<locals>.<lambda>r\)rrZr�r$rCrrrr�test__name__:szMockTest.test__name__cCsJGdd�dt�}t|dg�d�}|�d�|j�d�|�tt|d�dS)Nc@rf)z-MockTest.test_spec_list_subclass.<locals>.SubNrgrrrr�SubCrirr\rjrx)�listr�appendr�rZr�r�)rrrrrr�test_spec_list_subclassBs

z MockTest.test_spec_list_subclasscCs�Gdd�dt�}t|d�}|�||�t|�d�}|�||�|�|j|�|�t�jjd�t|d�}|�||�t|�d�}|�||�dS)Nc@rf)z#MockTest.test_spec_class.<locals>.XNrgrrrrrhMrirhrjrrl)rnrr��assertIs�	__class__rCr$rorrr�test_spec_classLs

zMockTest.test_spec_classcCs�Gdd�d�}t|d�}|�||�t|�d�}|�||�|�|j|�|�t�jjd�t|d�}|�||�t|�d�}|�||�dS)Nc@rf)z2MockTest.test_spec_class_no_object_base.<locals>.XNrgrrrrrharirhrjrrl)rr�r!r"rCr$rorrr�test_spec_class_no_object_base`s

z'MockTest.test_spec_class_no_object_basecsLGdd�dt�}t|d��d�_t|d���fdd�}d�_|�t|�dS)Nc@�eZdZdZdS)z8MockTest.test_setting_attribute_with_spec_set.<locals>.XrxN)r$r%r&r�rrrrrhur�rhrjr\rlc�
d�_dSrr�rrrr�set_attr|r#z?MockTest.test_setting_attribute_with_spec_set.<locals>.set_attr)rnrr�r�rZr�)rrhr'rrr�$test_setting_attribute_with_spec_setts

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_copy�szMockTest.test_copycs\Gdd�dt�}||d��|��jd��fdd�}|�t|��fdd�}|�t|�dS)Nc@s&eZdZdd�Zdd�Zeee�ZdS)z8MockTest.test_subclass_with_properties.<locals>.SubClasscSr
�Nrxrrrrr�_get�r!z=MockTest.test_subclass_with_properties.<locals>.SubClass._getcSrq)Nz
strange error)�	NameError)r�valuerrr�_set�rvz=MockTest.test_subclass_with_properties.<locals>.SubClass._setN)r$r%r&r2r5�property�some_attributerrrr�SubClass�sr8rlrxcr&r1)r7r��srr�test�r#z4MockTest.test_subclass_with_properties.<locals>.testcr&)Nr_�r\rr9rrr;�r#)rrCr7rZr3r�)rr8r;rr9r�test_subclass_with_properties�s
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�typer>r�rZrX)rrr>rrr�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>�sz%MockTest.test_dir.<locals>.<listcomp>r+r,r-r.cSstg�Sr)rr9rrrr��r�z#MockTest.test_dir.<locals>.<lambda>r )
r�set�dirrCr+r,r`r-r.r )rr�attrs�
type_attrsrrr�test_dir�s
zMockTest.test_dircCsXttjd�}tttj��}tt|��}|�t�||�d|_|�t|��d�d�dS)Nrjrx�versionrU)r�unittest�TestCaserGrHrCrL�count)rrZtestcase_attrsrIrrr�test_dir_from_spec�szMockTest.test_dir_from_speccCs\t�tdd�}|��zttt���}ttt��}|�t�||�W|��dS|��w)NZ
FILTER_DIRF)	rrnrr�rGrHrrC�stop)rZpatcherrIrJrrr�test_filter_dir�szMockTest.test_filter_dircCs6t�}d|j_|�dt|��|`|�dt|��dS)NrUr�)rr�rFr`rHrJrPrrr�,test_dir_does_not_include_deleted_attributes�s
z5MockTest.test_dir_does_not_include_deleted_attributescCs�tdd�}|�|jd�tdd�}|�|jd�tdt�d�}tdi|��}|�t|�|�|j��d�|�|jt�t�}|jdi|��|�t|�|�|j��d�|�|jt�dS)Nr_r<�!)rYzfoo.bar.return_valuer\r)	rrCr\r
�KeyErrorrZr_r�Zconfigure_mock)rrrtrrr�test_configure_mock�s 

�zMockTest.test_configure_mockcOsR|�|��}||i|��Wd�n1swYt|j�}|�||�dSr)rZ�strr�rC)rr��message�funcrsrt�contextr�rrr�assertRaisesWithMsg�s
�
zMockTest.assertRaisesWithMsgc
Cst�}d}d}d}|jt|||f|jddddd�|jddddd	�|jj|jjg}|D]}d
}d}d}|jt|||f|ddddd�q-|D]}d
}d}d}|jt|||f|dd�qH|D]}d
}d
}d}|�t|||f|ddd�q`|D]}d
}d}d}|�t|||f|�qydS)Nznot called.zmock(1, '2', 3, bar='foo')z0expected call not found.
Expected: %s
Actual: %srU�2rxr\)r_r<zfoo(1, '2', 3, foo='foo')zfoo(1, '2', 3, bar='foo')zfoo(bar='foo')zfoo(1, 2, 3)rwzfoo())rr[r�r�r\r�)rr�actual�expectedrXZ	assertersr/rrr�'test_assert_called_with_failure_messagesV��
�����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�]}tdi|��}t|j�ddifg}|�|j|�tdi|��}|�
��ddifddifg}|�|j|�|�|�
�jt�g�tdi|��}|d�d�d�|�|jtd�d�d����|�|�jtd�d����|�|��jtd����tdi|��}|d�d�d�j
j�d�|�|jtd�d�d�j
j�d����|�|�jtd�d�j
j�d����|�|��jtd�j
j�d����tdi|��}t|�j�	��
��ddif}|�|jd|�|�|�jtj�	��
������|�|�j�	�jt�
������|�|�j�	�j
jt������q�dS)NT�rrUrwrxr�r�r�z().foor{r\z
().foo.barz().foo.bar().bazr_r]zfoo.__int__r+za()z().foo.bar().baz().__int__���)r
r!r�rCr\rr�dictrFr_rc�	call_listr-r+r,r-�__int__)rrr^rtZ	last_callrrr�test_mock_calls=s���
��
�

�
��

����zMockTest.test_mock_callscCsFt�}|�}|��|�|jt�t���g�|�|jt��g�dSr)rZwibblerCr�r)rr�r�rrr�test_child_mock_call_equal�s
z#MockTest.test_child_mock_call_equalcCsFt�}|����|�|jdt�����|�|jdt���dS�NrUr)rr\r<r�r�rr�rCr�rrr�test_mock_call_not_equal_leaf��z&MockTest.test_mock_call_not_equal_leafcCsFt�}|����|�|jdt�����|�|jdt���dSrg�rr\r_r�r�rrcr�rrr�!test_mock_call_not_equal_non_leaf�riz*MockTest.test_mock_call_not_equal_non_leafcCs8t�}|jdd���|�|jdtjdd����dS)NrUr�rw)rr\r_rCr�rr�rrr�2test_mock_call_not_equal_non_leaf_params_different�s"z;MockTest.test_mock_call_not_equal_non_leaf_params_differentcCs,t�}|j��|�|jdtj���dS�Nrrjr�rrr�&test_mock_call_not_equal_non_leaf_attr�s
z/MockTest.test_mock_call_not_equal_non_leaf_attrcCs.t�}|j��|�|jdt�����dSrm)rr\r_r�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()rUzcall.foo().bar()rwzcall.foo().bar().baz.bob())rr\r_rcr�rCrar�r�rrr�test_mock_call_repr�s
zMockTest.test_mock_call_reprcCs0t�}||_t|���|�t|���d�dS)Nz<Mock name='mock\(\)' id='\d+'>)rr\raZassertRegexr�rrr�test_mock_call_repr_loop�sz!MockTest.test_mock_call_repr_loopcCst�}|�t�g|jv�dSr)rrArr�r�rrr�test_mock_calls_contains�sz!MockTest.test_mock_calls_containscCshGdd�dt�}|�}|�|j|�|�|�|�Gdd�dt�}|�}|�|j|�|�|�|�dS)Nc@rf)�+MockTest.test_subclassing.<locals>.SubclassNrgrrrr�Subclass�rirtc@r�)rsc[stdi|��S)Nr)r)rrtrrr�_get_child_mock�sz;MockTest.test_subclassing.<locals>.Subclass._get_child_mockN)r$r%r&rurrrrrt�r�)rr�r\�assertNotIsInstance)rrtrrrr�test_subclassing�szMockTest.test_subclassingcs�t�t�t�t�g}�fdd�}|D]=}||�t|�r1|�|dd�|dd�|��||�|��|jjddd�|�d����d�|��||�qdS)Ncs@d}|D]}t||�}��|t���|t���|g�qdS)N)rHrIr�)r�r�rrrC)r�namesr^�attrrrr�assert_attrs�s
�z-MockTest.test_arg_lists.<locals>.assert_attrsrUrwrxr;)	rr
rr
�callabler�r\r_rc)rrdrzrrrr�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)
NrUrxr;rwr��r,)rw�rUr)	rrC�lenrGrsrtrb�ziprH)rrZ
expected_listr^rGrrr�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)	Nr{r�r�Zghi)�g�h�ic@rf)z/MockTest.test_side_effect_iterator.<locals>.FooNrgrrrrrrirr)	rrrCrZr�r
rnr�r)rrrrrr�test_side_effect_iterators"

�z"MockTest.test_side_effect_iteratorcCs\ttfD]'}tdtdf}||d�}|�t|�|�|�d�|�t|�|�|�d�qdS)Nrxr�r�)rr
r�rUrZrC)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)Nr{r�r)
rrrYrCrZr�r�rArr!)rrrYZ	this_iterrrr�!test_side_effect_setting_iterator0s$
�z*MockTest.test_side_effect_setting_iteratorcCs4tdd�}tdtg�|_|�|�|�gddg�dS)NrwrRrU)rrrrYrCrPrrr�!test_side_effect_iterator_defaultEs
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�qXtdd�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)NrUrwrxr;r�r�r}r+�)rxr�r)r`�rUrwr`r�T�Z	any_orderr\r\r��)rr�assert_has_callsrZr�)rr�kalls�kallZ
kall_listsZ	kall_listrrr�test_assert_has_calls_any_orderJsF




�"��*���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]#}|dd�|dd�|dd
�|dd�|ddd�|�||f�qDt
�}|��|�d�|��jdd�|jt�id��	dg�|�||f�|D]1\}}t
t|��D]&}dD]!}||||�}|�|�t|�dkr�|�t|jtt|���q�q�q�dS)NrUrwr+rxr�r�r}r`r~r,r;r<r�r{)rr\r_�extendrrcrcZbamrGrzrr
r�rangerr�rZr�r�reversed)	rZkalls1Zkalls2rdrr�r��stepZtheserrr�test_assert_has_callsvsH
�"






�����zMockTest.test_assert_has_callsc	CsDGdd�d�}t|�}||�fD]$}|jddddd�|�tjddddd�g�|�t�dddd�g�q|��||�fD]6}|�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>.SomethingcSr)rrrrrrr�r0zFMockTest.test_assert_has_calls_nested_spec.<locals>.Something.__init__NcSr)rrr*rrrr/�r0zBMockTest.test_assert_has_calls_nested_spec.<locals>.Something.methc@r
)zAMockTest.test_assert_has_calls_nested_spec.<locals>.Something.FoocSr)rrr�rrrr�r0zJMockTest.test_assert_has_calls_nested_spec.<locals>.Something.Foo.__init__cSr)rr)rr+r,rrr�meth1�r0zGMockTest.test_assert_has_calls_nested_spec.<locals>.Something.Foo.meth1N)r$r%r&rr�rrrrr�srr)r$r%r&rr/rrrrrr(�s
r(rUrwrx�r.r�)
rr/r�rr�rZr�rr�Znon_existent)rr(Z
mock_classr�Z
invalid_callsr�rrr�!test_assert_has_calls_nested_spec�s0
" ���z*MockTest.test_assert_has_calls_nested_speccCsJt�}|�������|������t��������}|�	|�dSr)
r
r\r_rcr?r@�threerrcr�)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~wY|j|dd�|�t��|�|dd��Wd�n1s�wY|j|dd�dd�|�t��|�|dd��Wd�n1s�wY|j|dd�dd�dS)NcSr)rrr3rrrrT�r0z<MockTest.test_assert_has_calls_with_function_spec.<locals>.frjrUrwrxr�r�r�r�r��r-r.�
��)r-r`r{)r�r�r�r.)r�r�r�Tr�rar)rr�rr�rZr�)rrTrr�rrr�(test_assert_has_calls_with_function_spec�s8

�
���z1MockTest.test_assert_has_calls_with_function_speccCs�d	dd�}t|d�}|d�|�td�t�d����}|�t�g�Wd�n1s,wY|�|j	j
�|�td�t�d����}|�t�tdd�g�Wd�n1sZwY|�|j	j
t�dS)
NcSr)rrr�rrrrT�r0zAMockTest.test_assert_has_calls_not_matching_spec_error.<locals>.frjrUz^{}$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)]rwr)
rr�r�r�r�r�r�rrLr�r�r�rXr�rrr�-test_assert_has_calls_not_matching_spec_error�s2

�������	z6MockTest.test_assert_has_calls_not_matching_spec_errorcCs�t�}|dd�|dd�|ddd�|�dd�|jdd�|jddd�|�t|j�|�t|jdd�|jt|jdd�dS)NrUrwrxr;r�r}r�)r�assert_any_callrZr�rPrrr�test_assert_any_calls*

��
�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�n1sZwY|�|jjt�dS)NcSr)rrr3rrrrT#r0z;MockTest.test_assert_any_call_with_function_spec.<locals>.frjrUrwrxr�r�r�r�r�r�r�r3r�r�r)rr�rZr�r�r�r�rXr�rrr�'test_assert_any_call_with_function_spec"s


��z0MockTest.test_assert_any_call_with_function_speccCsfdd�}t�}||_t|�t|�jg}|D]}|dd�|dd�|�|jtdd�tdd�g�qdS)NcSr)rrr�rrrrT6r0z3MockTest.test_mock_calls_create_autospec.<locals>.frUrwrxr�)rrTrrCr�r)rrTrZfuncsrYrrr�test_mock_calls_create_autospec5s�

��z(MockTest.test_mock_calls_create_autospeccCs$tjt�dd�}|�dt|��dS)NZ
sweet_funcr])rrrnr`rar�rrr�test_create_autospec_with_nameGsz'MockTest.test_create_autospec_with_namec	CstGdd�d�}dD].}|j|d��t�t||��}|�|��|�t|d�Wd�n1s2wYq	dS)Nc@s$eZdZedd��Zedd��ZdS)zMMockTest.test_create_autospec_classmethod_and_staticmethod.<locals>.TestClasscSr)rr)r1rrr�class_methodNr!zZMockTest.test_create_autospec_classmethod_and_staticmethod.<locals>.TestClass.class_methodcSr)rrrrrr�
static_methodQr!z[MockTest.test_create_autospec_classmethod_and_staticmethod.<locals>.TestClass.static_methodN)r$r%r&r5r�r6r�rrrr�	TestClassMs

r�)r�r�)r�Z	extra_arg)ZsubTestrrr�r�rZrX)rr�r�Zmock_methodrrr�1test_create_autospec_classmethod_and_staticmethodLs���z:MockTest.test_create_autospec_classmethod_and_staticmethodcCsDt�}d}|�t|��|��Wd�n1swY|�t|��|��Wd�n1s4wY|�t|��|��Wd�n1sNwY|�t|��|��Wd�n1shwY|�t|��|��Wd�n1s�wYtdd�}|��|��|��|��|��dS)Nz1is not a valid assertion. Use a spec for the mockT)�unsafe)rr�r�Zassert_foo_callZassret_foo_callZasert_foo_callZaseert_foo_callZassrt_foo_call)rr�r�rrr�test_mock_unsafe[s.
�
�
�
�
�
zMockTest.test_mock_unsafecCsBGdd�dt�}t|d�}|��|��|j��|j��dS)Nc@r
)z.MockTest.test_mock_safe_with_spec.<locals>.FoocSr)rrrrrr�
assert_barrr!z9MockTest.test_mock_safe_with_spec.<locals>.Foo.assert_barcSr)rrrrrr�
assertSomeur!z9MockTest.test_mock_safe_with_spec.<locals>.Foo.assertSomeN)r$r%r&r�r�rrrrrqsrrj)rnrr�r��assert_called_once�rrr�rrr�test_mock_safe_with_specps

z!MockTest.test_mock_safe_with_speccCsRt�}|j��|��|�t��|j��Wd�dS1s"wYdSr)r�hello�assert_not_calledrZr�r�rrr�test_assert_not_called�s
"�zMockTest.test_assert_not_calledcCs*t�}|dd�|�tt�d�|j�dS)NrUrwzCalls: [call(1, 2)])rr�r�r�r�r�r�rrr�test_assert_not_called_message�s
�z'MockTest.test_assert_not_called_messagecCsbt�}|�t��
|j��Wd�n1swY|��|j��|��|j��dSr)rrZr�r�r�r�rrr�test_assert_called�s�
zMockTest.test_assert_calledcCs�t�}|�t��
|j��Wd�n1swY|��|j��|��|�t��|j��Wd�dS1s@wYdSr)rrZr�r�r�r�rrr�test_assert_called_once�s�
"�z MockTest.test_assert_called_oncecCs2t�}|dd�|d�|�tt�d�|j�dS)NrUrwrxzCalls: [call(1, 2), call(3)])rr�r�r�r�r�r�rrr�test_assert_called_once_message�s
�z(MockTest.test_assert_called_once_messagecCsNt�}|�t��}|��Wd�n1swY|�dt|j��dS)NzCalls:)rrZr�r�rJrWr�)rr�r�rrr�*test_assert_called_once_message_not_called�s

�z3MockTest.test_assert_called_once_message_not_calledcCs0t�}|jddd�d}|�t|jj�|�dS)Nr�Zhero)r^Zdaddyz call(name='hello', daddy='hero'))rr�rCrarG)rr��textrrr�test_ordered_call_signature�sz$MockTest.test_ordered_call_signaturecCsVt��}t�dd�}t�}|��|�dd�|�|jd|�|�|jd|�dS)N�r�rrU)rrOrrrCrI)rr-r�r�rrr�test_override_tuple_methods�sz$MockTest.test_override_tuple_methodscCs>tdddgd�}|jddd�|�|jt�|�|jd�dS)Nr�rwrx�rFrYT)rr�r�rFrCrYr�rrr�test_reset_return_sideeffect�sz%MockTest.test_reset_return_sideeffectcCs<tdddgd�}|jdd�|�|jt�|�|jd�dS)Nr�rwrxr�TrR)rr�r�rFr�rYr�rrr�test_reset_return��zMockTest.test_reset_returncCs<tdddgd�}|jdd�|�|jd�|�|jd�dS)Nr�rwrxr�Tr�)rr�rCrFrYr�rrr�test_reset_sideeffect�r�zMockTest.test_reset_sideeffectcCs@ttdd�d�}|�|��d�|jdd�|�|��d�dS)NrUrR�rTT)r
rCrTr�r�r�rrr�test_reset_return_with_children�sz(MockTest.test_reset_return_with_childrencCsDttddgd�d�}|�|jjd�|jdd�|�|jjd�dS)Nrwrxr�r�T)r
r�rTrYr�rCr�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]}|�|f�fdd�	�|�|f�fd	d�	�q"|D]�}t�td
d�fD]y}|�}|j|j	|j
f||fdgd
gffD]a\}}t�td
d�fD]T}|j|fi|��|j|�t
t|d
�|�t
t|d�d|vr�|�t
t|dd�|j|fi|��|�t
t|d�|j	|�t
t|d�d|vr�|�t
t|dd�qjq^qGq=dS)Nc@r%)z)MockTest.test_mock_add_spec.<locals>._OnerUN�r$r%r&r?rrrr�_One�r�r�c@r%)z)MockTest.test_mock_add_spec.<locals>._TworwN)r$r%r&r@rrrr�_Two�r�r�c@seZdZdZZZdS)z-MockTest.test_mock_add_spec.<locals>.AnythingZfourN)r$r%r&r?r@r�rrrr�Anything�sr�c�
|�d�S)Nrjr��K�r�rrr��r�z-MockTest.test_mock_add_spec.<locals>.<lambda>cr�)Nrlrr�r�rrr��r�Trlr?r@r�rm)rnrr
rr
rrrbr?r@r��
mock_add_specrZr�r��setattr)	rr�r�Zklassesr�rtrZOneZTworr�r�test_mock_add_spec�sV���
���
������zMockTest.test_mock_add_speccs|ttfD]7}|��t����t�|�tt��|���dd�j_��t�|�	t��d�|�t�fdd��qdS)Nr\r�cs�dSrrrrrrr�#r�z;MockTest.test_mock_add_spec_magic_methods.<locals>.<lambda>)
r
r
r-r�rnrZrXrdrFrC)rr�rrr� test_mock_add_spec_magic_methodss

�z)MockTest.test_mock_add_spec_magic_methodscCs�tttttfD]V}|�}t�|_|��|�|jt��g�|�|j	t��g�|�}tdd�|_
|�
�|�|jg�|�|j	g�|�}t��|_|��|�|jg�|�|j	g�qdS)Nr^r])rrr
r
rr\rCrIrr�r_rc�rr�rrrr�test_adding_child_mock&s&�
�zMockTest.test_adding_child_mockcCs@ttfD]}|�}t�|_|��|�|jt�t��g�qdSr)rr
rFrCr�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>.Foor?r@N)r$r%r&r?r@rrrrrIsrr?r@)rnrrr�r+rQ�attach_mockr@r?rCr�r)rr�managerZp1Zp2Zmock_oneZmock_tworrr�test_manager_mockHszMockTest.test_manager_mockcCshttfD]-}|�}tdd�|_tdd�|_t|�t|�|�|jt��t��g�|�|j	g�qdS)NrxrRg@)
rr
rd�	__float__r-�floatrCr�rrI)rr�r�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��readrC)r�mocked_open�f1Zf1_data�f2Zf2_datarrr� test_mock_open_reuse_issue_21750isz)MockTest.test_mock_open_reuse_issue_21750cCsVtjdd�}|d�}dd�|D�}|�|dd�|�|dd	�|�t|�g�dS)
NzRemarkable
Norwegian Bluer�r�cS�g|]}|�qSrr�rE�linerrrrFvr�z=MockTest.test_mock_open_dunder_iter_issue.<locals>.<listcomp>rzRemarkable
rUzNorwegian Blue)rr�rCr)rr�r��linesrrr� test_mock_open_dunder_iter_issueqsz)MockTest.test_mock_open_dunder_iter_issuecCs�tjdd�}|d�}t|�}|��}dd�|D�}|�|d�|�|d�|�|dd	�|�t|�g�|�t��
t|�Wd�dS1sJwYdS)
Nz1st line
2nd line
3rd liner�r�cSr�rrr�rrrrF�r�z6MockTest.test_mock_open_using_next.<locals>.<listcomp>z	1st line
z	2nd line
rz3rd line)rr�r"r'rCrrZr�)rr�r�Zline1Zline2r�rrr�test_mock_open_using_next{s
"�z"MockTest.test_mock_open_using_nextcCs,tjdd�}d|jj_|�dt|���dS)N�foo
barnr��abc)rr�rF�readlinerCr")r�mopenrrr�3test_mock_open_next_with_readline_with_return_value�s
z<MockTest.test_mock_open_next_with_readline_with_return_valuecCsnt�tjdd��}t�d|��|j}|j}td�|_dd�}|�t|�Wd�dS1s0wYdS)NZJLVr]ztempfile.NamedTemporaryFilezTest 2 ErrorcSst���d�dS)NZasd)�tempfile�NamedTemporaryFile�writerrrr�attempt�rz.MockTest.test_mock_open_write.<locals>.attempt)	rr�r
rrFr��OSErrorrYrZ)rZmock_namedtempZmock_filehandleZ
mock_writer�rrr�test_mock_open_write�s
"�zMockTest.test_mock_open_writecCsJtjdd�}dd�|jj_|���}|���}|�d|�|�d|�dS)Nr�r�cWr
)Nr�r)rsrrrr��r0z8MockTest.test_mock_open_alter_readline.<locals>.<lambda>r�)rr�rFr�rYrC)rr��first�secondrrr�test_mock_open_alter_readline�s

z&MockTest.test_mock_open_alter_readlinecCs�tjdd�}|d�}|��|�d|���|�d|���|�d|���|�d|���|�g|���|�g|���dS)Nr\r�r_r`)rr�r�rCr��	readlines)r�_openr�rrr�test_mock_open_after_eof�s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
rarFr!rCr�r+r,r`)rr�r�Z
original_reprrrr�test_mock_parents�s.�zMockTest.test_mock_parentscCs�ttttf}|D]B}|D]=}|�}|dd�}|�|d�|�|j|�|�dt|��|j�	d�|�
|jtj�	d�g�|�
|j
tj�	d�g�qqdS)Nr\r]r_zname='mock.bar'rU)rr
r
rr�r!r_r`rarcrCr�rrI�rZclassesr�ZKlass2r�Zm2rrr�test_attach_mock�s
��zMockTest.test_attach_mockcCs�ttttf}ttfD]4}|D]/}|�}|dd�}|�|d�|�|�|�|�dt|��|��|�	|j
t������qq
dS)Nr\r]rFz
name='mock()')
rr
r
rr�r!r`rar\rCr�rrcr�rrr�test_attach_mock_return_value�s
��z&MockTest.test_attach_mock_return_valuecCs
t�}tjt�d�dd��n}|�|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�dS1s~wYdS)
N�
.somethingTr�r<r�rUrwrx�
mock.child)
rrrr$rCZ_extract_mock_namer�r�r<rr�r`ra)rr�Z	mock_funcZparent_callsZchild_callsrrr�test_attach_mock_patch_autospec�s 
"�z(MockTest.test_attach_mock_patch_autospecc
Cs�tjt�d�dd��I}t�}|�|d�t�}|jddddd	�|�tj	tj
ddddd	�g�|j�ttj
ddddd	�g�|�ttj
ddddd	�g�Wd�n1sVwYtjt�d
�dd��.}t�}|�|d�td�|�t�d�g�t�td�g�|�td�g�Wd�n1s�wYtjt�d�dd��M}t�}|�|d
�t�}|jddddd	�|�t�
�t�
�jddddd	�g�|j�tddddd	�g�|�t�t�jddddd	�g�Wd�dS1s�wYdS)N�.Something.methTr��attach_methrUrwrxr�r�r��attach_func�
.Something�
attach_obj)rrr$rr�r(r/r�rrr�r<rr)rZmockedr�rrrr�)test_attach_mock_patch_autospec_signature�s8�	�
�""�z2MockTest.test_attach_mock_patch_autospec_signaturecCsft�t�t�t�fD]&}|�t|d��|`|�t|d��|`|�t|d��|�	t
t|d�q
dS)Nr�rT)rr
r
rrE�hasattrr�rArTrZr�r�rPrrr�test_attribute_deletions��z MockTest.test_attribute_deletioncCs�t�t�t�t�fD]:}d|_|�t|d��|�|jd�|`|�t|d��d|_|�t|d��|�|jd�|`|�t|d��q
dS)Nrxr\r�)	rr
r
rr\rErrCrArPrrr�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]}|`|�t��
|`Wd�n1s wYq
dSr)rr
r
rr\rZr�rPrrr�4test_mock_raises_when_deleting_nonexistent_attribute;s����z=MockTest.test_mock_raises_when_deleting_nonexistent_attributecCs,t�}d|_|`|��|�t|d��dS)NTr�)rr�r�rArrPrrr�/test_reset_mock_does_not_raise_on_attr_deletionCs
z8MockTest.test_reset_mock_does_not_raise_on_attr_deletioncCs:t�t�fD]}|�|t�t|_|�|t�|jqdSr)rr
rvr-r"r�r\rPrrr�test_class_assignableMs�zMockTest.test_class_assignablecC�8|�tj�|�ttj�t�|�tt��j�t�dSr)�assertIsNotNonerr^rCrArrrrr�test_name_attribute_of_callU�z$MockTest.test_name_attribute_of_callcCrr)rrr�rCrArrrrr�test_parent_attribute_of_call\rz&MockTest.test_parent_attribute_of_callcCsddd�}t�}t|�|_|�dd�|�t|jd�|�|jt�dd�g�|�dt	|jj
��dS)NcSr)rrr�rrrr\fr0zBMockTest.test_parent_propagation_with_create_autospec.<locals>.foorUrwr)rrr�rZrXrCr�rr`rar)rr\rrrr�,test_parent_propagation_with_create_autospecds
z5MockTest.test_parent_propagation_with_create_autospeccCspdd�}t�}|�t|dd�d�|�dd�|�t|jd�|�|jjt�dd�g�|�	dt
|jj��dS)	NcSr)rrr�rrrr\rr0zGMockTest.test_parent_propagation_with_autospec_attach_mock.<locals>.foor_r]r�rUrwr)rr�rr�rZrXrCr�rr`rar)rr\r�rrr�1test_parent_propagation_with_autospec_attach_mockpsz:MockTest.test_parent_propagation_with_autospec_attach_mockc	s�tjj}|�dd�|�t�d��Dtjd=�fdd��|�tjt���t���ddl	m
}m}m}m
}||||tg}|D]
}|td	�}|�|t�q?Wd�dS1sXwYdS)
NcSsttjd|�S)Nr)r�rMr)rrrrr��sz9MockTest.test_isinstance_under_settrace.<locals>.<lambda>zsys.modulesz
unittest.mockcs�Srr)�frame�eventr���tracerrr�r!z6MockTest.test_isinstance_under_settrace.<locals>.tracer)rr
rr
rj)rMrrr+rbr)�modules�settrace�gettrace�
unittest.mockrr
rr
rr(r�)	rZ	old_patchrr
rr
rdrrrrr�test_isinstance_under_settrace}s"	
�

�
�"�z'MockTest.test_isinstance_under_settracecCs^Gdd�d�}|�}tjjj|dtd��Wd�n1swY|�|jjjd�dS)Nc@r�)zFMockTest.test_bool_not_called_when_passing_spec_arg.<locals>.SomethingcSstj��|_dSr)rMrr
�obj_with_bool_funcrrrrr�szOMockTest.test_bool_not_called_when_passing_spec_arg.<locals>.Something.__init__N)r$r%r&rrrrrr(�r�r(rrjr)rMrrrnrCr�__bool__rD)rr(rrrr�*test_bool_not_called_when_passing_spec_arg�s4z3MockTest.test_bool_not_called_when_passing_spec_argc	Cs$Gdd�d�}|�t��!tt�d�dd��Wd�n1s!wYWd�n1s0wY|�t�� tj|ddd��Wd�n1sNwYWd�n1s]wY|�t��!tt�d�dd��Wd�n1s|wYWd�n1s�wY|�t�� tj|ddd��Wd�n1s�wYWd�n1s�wY|�t��!tt�d�dd��Wd�n1s�wYWd�n1s�wY|�t��!tj|ddd��Wd�n	1�swYWd�n	1�swY|�t��t|dd�}Wd�n	1�s1wY|�t��$tjt�d	�tdd
��Wd�n	1�sSwYWd�n	1�scwY|�t��$tjt�d	�tdd��Wd�n	1�s�wYWd�n	1�s�wY|�t��$tjt�d	�tdd��Wd�n	1�s�wYWd�n	1�s�wYtt�d�ddd
��Wd�n	1�s�wYtj|dddd
��Wd�n	1�s�wYtt�d�ddd��Wd�n	1�swYtj|dddd��Wd�n	1�s1wYtt�d�ddd��Wd�n	1�sLwYtj|dddd��Wd�n	1�sfwYt|ddd�}tjt�d�dddd��	Wd�dS1�s�wYdS)Nc@r%)z/MockTest.test_misspelled_arguments.<locals>.Foor?Nr�rrrrr�r�rrT)r8r?)r9)r:r)r/r8)r/r9)r/r:)r�r8)r�r9)r�r:)r:r�z.Typos)r8r:r9)	rZr�rr$rnrr�Zmultiplerr�rrr�test_misspelled_arguments�s�2��0��2��0��2��2����������������4�4�4�$�z"MockTest.test_misspelled_argumentsN)�r$r%r&r?rQrSrWr[rerpr�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�rrrrrr	rrrrrrr r#r$r(r0r=rBrKrPrRrSrVr[r_rerfrhrkrlrnrorprqrrrwr|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�rrr	r
rrr
rrrrrr r!rrrrr=2s	)&	





!




	8N
#
,((
	5	




'
r=�__main__)!r.r�r)r�Ztest.supportrrMZunittest.test.testmock.supportrrrrrrr	r
rrr
rrrrrrnrr(r7r<rNr=r$�mainrrrr�<module>sD<

<�