Your IP : 3.145.78.12


Current Path : /opt/alt/python39/lib64/python3.9/unittest/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/unittest/__pycache__/mock.cpython-39.opt-2.pyc

a

R�f���@s�dZddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl
mZddlmZmZdd�ee�D�Zd	ZeZd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zd�dd�Zdd�Zdd�Zdd�Z dd �Z!d�d!d"�Z"d#d$�Z#d%d&�Z$d'd(�Z%Gd)d*�d*e&�Z'Gd+d,�d,e&�Z(e(�Z)e)j*Z*e)j+Z,e)j-Z.hd-�Z/d.d/�Z0Gd0d1�d1e1�Z2d2d3�Z3Gd4d5�d5e&�Z4Gd6d7�d7e&�Z5Gd8d9�d9e5�Z6e�7e6j8�Z9Gd:d;�d;e1�Z:d<d=�Z;Gd>d?�d?e5�Z<Gd@dA�dAe<e6�Z=dBdC�Z>dDdE�Z?GdFdG�dGe&�Z@dHdI�ZAe*dddddfdJdK�ZBd�dLdM�ZCe*dddddfdNdO�ZDGdPdQ�dQe&�ZEdRdS�ZFdTdU�ZGeBeD_&eEeD_HeCeD_IeGeD_JdVeD_KdWZLdXZMdY�NdZd[�eM�O�D��ZPdY�Nd\d[�eM�O�D��ZQhd]�ZRd^d_�ZSd`d�dY�NeLeMePeQg��O�D�ZThda�ZUdbhZVeUeVBZWeTeRBZXeXeWBZYhdc�ZZddde�dfde�dgde�dhde�di�Z[e\e\e\e\djddddkdld	djddm�
Z]dndo�Z^dpdq�Z_drds�Z`dtdu�Zae^e_e`eadv�Zbdwdx�ZcGdydz�dze5�ZdGd{d|�d|ede6�ZeGd}d~�d~ed�ZfGdd��d�ede=�ZgGd�d��d�e5�ZhGd�d��d�e5�ZiGd�d��d�eiefe=�ZjGd�d��d�e&�Zkek�Zld�d��ZmGd�d��d�en�Zoeodd��Zpd�d�d��Zqd�d��ZrGd�d��d�e&�Zseteq�etelju�fZvdawd�d��Zxd�d�d��ZyGd�d��d�e=�Zzd�d��Z{Gd�d��d��Z|dS)�)�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�seal�N)�iscoroutinefunction)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partialcCsh|]}|�d�s|�qS��_��
startswith)�.0�name�r�2/opt/alt/python39/lib64/python3.9/unittest/mock.py�	<setcomp>'�r TcCs<t|�rt|t�sdSt|d�r*t|d�}t|�p:t�|�S)NF�__func__)�_is_instance_mock�
isinstancer	�hasattr�getattrr�inspectZisawaitable��objrrr�
_is_async_obj/s


r*cCst|dd�rt|�SdSdS)N�__code__F)r&r��funcrrr�_is_async_func7sr.cCstt|�t�S�N)�
issubclass�typerr(rrrr#>sr#cCst|t�pt|t�ot|t�Sr/)r$�
BaseExceptionr1r0r(rrr�
_is_exceptionDs
�r3cCs"t|t�rt|d�r|jS|SdS�N�mock)r$�
FunctionTypesr%r5r(rrr�
_extract_mockKsr7cCs�t|t�r|s|j}d}n*t|t�sDz
|j}WntyBYdS0|rTt|d�}n|}z|t�|�fWSt	y|YdS0dS�NT)
r$r1�__init__r6�__call__�AttributeErrorrr'�	signature�
ValueError)r-Zas_instanceZeat_selfZsig_funcrrr�_get_signature_objectTs

r>FcsNt|||���durdS�\}��fdd�}t||�|t|�_�t|�_dS)Ncs�j|i|��dSr/��bind��self�args�kwargs��sigrr�checksigvsz"_check_signature.<locals>.checksig)r>�_copy_func_detailsr1�_mock_check_sig�
__signature__)r-r5�	skipfirst�instancerGrrEr�_check_signatureqs

rMc	Cs8dD].}zt||t||��Wqty0Yq0qdS)N)�__name__�__doc__�__text_signature__�
__module__�__defaults__�__kwdefaults__)�setattrr&r;)r-�funcopy�	attributerrrrH}s
rHcCs@t|t�rdSt|tttf�r(t|j�St|dd�dur<dSdS)NTr:F)r$r1�staticmethod�classmethodr�	_callabler"r&r(rrrrY�s

rYcCst|�ttfvSr/)r1�list�tupler(rrr�_is_list�sr\cCsFt|t�st|dd�duS|f|jD]}|j�d�dur&dSq&dS)Nr:TF)r$r1r&�__mro__�__dict__�get)r)�baserrr�_instance_callable�s
racs�t|t�}t|||�}|dur"|S|\}��fdd�}t||�|j}|��sRd}||d�}d|}	t|	|�||}
t|
|��|
S)Ncs�j|i|��dSr/r?�rCrDrErrrG�sz _set_signature.<locals>.checksigrU)Z
_checksig_r5zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r$r1r>rHrN�isidentifier�exec�_setup_func)r5�originalrLrK�resultr-rGr�context�srcrUrrEr�_set_signature�s$


�
rjcs���_�fdd�}�fdd�}�fdd�}�fdd�}�fd	d
�}�fdd�}�fd
d�}	��fdd�}
d�_d�_d�_t��_t��_t��_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Ncs�j|i|��Sr/)�assert_called_withrb�r5rrrk�sz'_setup_func.<locals>.assert_called_withcs�j|i|��Sr/)�
assert_calledrbrlrrrm�sz"_setup_func.<locals>.assert_calledcs�j|i|��Sr/)�assert_not_calledrbrlrrrn�sz&_setup_func.<locals>.assert_not_calledcs�j|i|��Sr/)�assert_called_oncerbrlrrro�sz'_setup_func.<locals>.assert_called_oncecs�j|i|��Sr/)�assert_called_once_withrbrlrrrp�sz,_setup_func.<locals>.assert_called_once_withcs�j|i|��Sr/)�assert_has_callsrbrlrrrq�sz%_setup_func.<locals>.assert_has_callscs�j|i|��Sr/)�assert_any_callrbrlrrrr�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_����j}t|�r6|�ur6|��dSr/)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer#)�ret�rUr5rrrv�sz_setup_func.<locals>.reset_mockFr)r5�called�
call_count�	call_argsrs�call_args_listrtrurw�side_effect�_mock_childrenrkrprqrrrvrmrnrorJ�_mock_delegate)rUr5rFrkrmrnrorprqrrrvrryrre�s8recsJtjj�_d�_d�_t��_�fdd�}dD]}t�|t||��q.dS)Nrcst�j|�|i|��Sr/)r&r5)�attrrCrDrlrr�wrapper�sz"_setup_async_mock.<locals>.wrapper)�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited)	�asyncio�
coroutines�
_is_coroutine�await_count�
await_argsrs�await_args_listrTr)r5r�rVrrlr�_setup_async_mock�s
r�cCsd|dd�|kS)N�__%s__����r�rrrr�	_is_magicsr�c@s$eZdZdd�Zdd�Zdd�ZdS)�_SentinelObjectcCs
||_dSr/r��rBrrrrr9sz_SentinelObject.__init__cCs
d|jS�Nzsentinel.%sr��rBrrr�__repr__sz_SentinelObject.__repr__cCs
d|jSr�r�r�rrr�
__reduce__sz_SentinelObject.__reduce__N)rNrQ�__qualname__r9r�r�rrrrr�sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�	_SentinelcCs
i|_dSr/)�
_sentinelsr�rrrr9"sz_Sentinel.__init__cCs|dkrt�|j�|t|��S)N�	__bases__)r;r��
setdefaultr�r�rrr�__getattr__%sz_Sentinel.__getattr__cCsdS)Nrrr�rrrr�+sz_Sentinel.__reduce__N)rNrQr�r9r�r�rrrrr� sr�>�_mock_side_effectrw�_mock_new_parentr~�
_mock_name�_mock_new_name�_mock_parent�_mock_return_valuecCs8t�|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|durt||�St||�Sr/)r�r&)rBr�	_the_namerFrrr�_get@s
z"_delegating_property.<locals>._getcSs*|j}|dur||j|<nt|||�dSr/)r�r^rT)rB�valuerr�rFrrr�_setEsz"_delegating_property.<locals>._set)�_allowed_names�add�property)rr�r�r�rrr�_delegating_property=s

r�c@seZdZdd�Zdd�ZdS)rscCslt|t�st�||�St|�}t|�}||kr2dStd||d�D]"}||||�}||krDdSqDdS)NFr�T)r$rZ�__contains__�len�range)rBr�Z	len_valueZlen_self�iZsub_listrrrr�Rs
z_CallList.__contains__cCst�t|��Sr/)�pprintZpformatrZr�rrrr�`sz_CallList.__repr__N)rNrQr�r�r�rrrrrsPsrscCs|t|�}t|�sdS|js4|js4|jdus4|jdur8dS|}|durX||urPdS|j}q<|rh||_||_|rx||_||_dS)NFT)r7r#r�r�r�r�)�parentr�r�new_name�_parentrrr�_check_and_set_parentds*��r�c@seZdZdd�Zdd�ZdS)�	_MockItercCst|�|_dSr/)�iterr))rBr)rrrr9�sz_MockIter.__init__cCs
t|j�Sr/)�nextr)r�rrr�__next__�sz_MockIter.__next__N)rNrQr�r9r�rrrrr�sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdSr/rrArrrr9�sz
Base.__init__)rNrQr�rr�r�r9rrrrr��sr�c@s`eZdZdd�ZdKdd�Zdd	�ZdLd
d�ZdMdd
�Zdd�Zdd�Z	dZ
eee	e
�Zedd��Z
ed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�ZdNddd�dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�ZdOd2d3�Z d4d5�Z!d6d7�Z"d8d9�Z#d:d;�Z$d<d=�Z%d>d?�Z&d@dA�Z'dPdBdC�Z(dDdE�Z)dFdG�Z*dQdIdJ�Z+dS)RrcOs||f}t|t�sTtj|g|�Ri|��j}|�d|�d��}|durTt|�rTt|f}t|j|d|j	i�}t
t|��|�}|S)N�spec_set�specrO)
r0�AsyncMockMixin�	_MOCK_SIGZbind_partialZ	argumentsr_r*r1rNrO�_safe_superr�__new__)�clsrC�kw�basesZ
bound_argsZspec_arg�newrLrrrr��s
zNonCallableMock.__new__N�FcKs�|dur|}|j}
||
d<||
d<||
d<||
d<d|
d<|durJ|}d}|
durZ|du}
|�|||	|
�i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t�|
d<t�|
d<t�|
d<||
d<|r�|jfi|��tt|��||||||�dS)Nr�r�r�r�F�_mock_sealedTr�_mock_wrapsr�Z_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrt�_mock_unsafe)r^�_mock_add_specrs�configure_mockr�rr9)rBr�rrr�r��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsaferDr^rrrr9�s<




�zNonCallableMock.__init__cCs0t|�}d|_d|_d|_d|_t|||�dS)Nr�)r7r�r�r�r�rT)rBr5rVZ
inner_mockrrr�attach_mock�szNonCallableMock.attach_mockcCs|�||�dSr/)r��rBr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_speccCs�d}d}g}t|�D]}tt||d��r|�|�q|dur|t|�s|t|t�rT|}nt|�}t|||�}	|	or|	d}t|�}|j}
||
d<||
d<||
d<||
d<||
d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)	�dirrr&�appendr\r$r1r>r^)rBr�r�r�r�r�r�r�r��resr^rrrr��s*
�zNonCallableMock._mock_add_speccCs8|j}|jdur|jj}|tur4|j|dd�}||_|S)N�()�r�r�)r�r�rwr�_get_child_mock)rBrxrrrZ__get_return_values
�z"NonCallableMock.__get_return_valuecCs,|jdur||j_n||_t||dd�dS)Nr�)r�rwr�r�)rBr�rrrZ__set_return_values

z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdurt|�S|jSr/)r�r1r�rrr�	__class__s
zNonCallableMock.__class__rzr{r|r}rucCsN|j}|dur|jS|j}|durJt|�sJt|t�sJt|�sJt|�}||_|Sr/)r�r�r~�callabler$r�r3)rB�	delegatedZsfrrrZ__get_side_effect's��z!NonCallableMock.__get_side_effectcCs(t|�}|j}|dur||_n||_dSr/)�	_try_iterr�r�r~)rBr�r�rrrZ__set_side_effect2s
z!NonCallableMock.__set_side_effect�rwr~cCs�|durg}t|�|vrdS|�t|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_|j�
�D](}t|t�sr|tur�qr|j|||d�qr|j
}t|�r�||ur�|�|�dS)NFrr�)�idr�rzr|r{rsrur}rtrr�r�r�valuesr$�
_SpecState�_deletedrvr#)rBZvisitedrwr~�childrxrrrrv=s,zNonCallableMock.reset_mockcKsXt|��dd�d�D]>\}}|�d�}|��}|}|D]}t||�}q6t|||�qdS)NcSs|d�d�S)Nr�.)�count)�entryrrr�<lambda>hr!z0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�)�sorted�items�split�popr&rT)rBrD�arg�valrC�finalr)r�rrrr�[s	�
zNonCallableMock.configure_mockcCs�|dvrt|��n:|jdur<||jvs.|tvrLtd|��nt|�rLt|��|jsd|�d�rdtd��|j�|�}|tur�t|��np|dur�d}|j	dur�t
|j	|�}|j|||||d�}||j|<n.t|t
�r�t|j|j|j|j|j�}||j|<|S)N>r�r�zMock object has no attribute %r)�assertZassretz1Attributes cannot start with 'assert' or 'assret')r�rrr�r�)r;r��_all_magicsr�r�rrr_r�r�r&r�r$r�rr�r�rLr�r)rBrrgrrrrr�qs:




�
�
zNonCallableMock.__getattr__cCs�|jg}|j}|}d}|dgkr$d}|durZ|}|�|j|�d}|jdkrRd}|j}q$tt|��}|jpnd}t|�dkr�|ddvr�|d7}||d<d�|�S)Nr�r�r�r5r�)r�z().r)r�r�r�rZ�reversedr�r��join)rBZ
_name_listr�Zlast�dotZ_firstrrr�_extract_mock_name�s(


z"NonCallableMock._extract_mock_namecCs^|��}d}|dvrd|}d}|jdurDd}|jr8d}||jj}dt|�j||t|�fS)Nr�)r5zmock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�r�rNr1r�)rBrZname_stringZspec_stringrrrr��s 
�zNonCallableMock.__repr__cCsvtst�|�S|jpg}tt|��}t|j�}dd�|j�	�D�}dd�|D�}dd�|D�}t
t||||��S)NcSsg|]\}}|tur|�qSr)r�)rZm_nameZm_valuerrr�
<listcomp>�s�z+NonCallableMock.__dir__.<locals>.<listcomp>cSsg|]}|�d�s|�qSrr�r�errrr��r!cSs"g|]}|�d�rt|�r|�qSr)rr�r�rrrr��s�)r
�object�__dir__r�r�r1rZr^rr�r��set)rBZextrasZ	from_typeZ	from_dictZfrom_child_mocksrrrr�s


�zNonCallableMock.__dir__csT|tvrt��||�S�jrH�jdurH|�jvrH|�jvrHtd|��n�|tvrbd|}t|��n�|tvr�jdur�|�jvr�td|��t	|�s�t
t��|t||��|���fdd�}n(t
�|d|�t
t��||�|�j|<n,|dkr�|�_dSt
�|||��r|�j|<�j�rFt�|��sF����d|��}td|����t��||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��g|�Ri|��Sr/r�rCr��rfrBrrr��r!z-NonCallableMock.__setattr__.<locals>.<lambda>r�r�zCannot set )r�r�__setattr__r�r�r^r;�_unsupported_magicsr�r#rTr1�_get_methodr�rr�r�r%r�)rBrr��msg�	mock_namerrrr�s<��

zNonCallableMock.__setattr__cCs�|tvr2|t|�jvr2tt|�|�||jvr2dS|j�|t�}||jvr\tt|��	|�n|t
urlt|��|tur||j|=t
|j|<dSr/)r�r1r^�delattrrr_�_missingr�r�__delattr__r�r;)rBrr)rrrr
s

zNonCallableMock.__delattr__cCs|jpd}t|||�Sr4)r��_format_call_signature�rBrCrDrrrr�_format_mock_call_signatures
z+NonCallableMock._format_mock_call_signaturercCs.d}|�||�}|j}|j|�}||||fS)Nz.expected %s not found.
Expected: %s
Actual: %s)rr|)rBrCrD�action�message�expected_stringr|Z
actual_stringrrr�_format_mock_failure_messages

z,NonCallableMock._format_mock_failure_messagecCsj|s
|jSd}|�dd��d�}|j}|D]:}|�|�}|dusJt|t�rPqfq*t|�}|j}|j}q*|S)Nr�r�r�)r��replacer�rr_r$r�r7)rBrrF�namesZchildrenr�rrr�_get_call_signature_from_name s
z-NonCallableMock._get_call_signature_from_namec
Cs�t|t�r&t|�dkr&|�|d�}n|j}|dur�t|�dkrNd}|\}}n
|\}}}z"|j|i|��}t||j|j�WSt	y�}z|�
d�WYd}~Sd}~00n|SdS)Nr�rr�)r$r[r�rr�r@rrCrD�	TypeError�with_traceback)rB�_callrFrrCrDZ
bound_callrrrr�
_call_matcherAs

"zNonCallableMock._call_matchercCs0|jdkr,d|jpd|j|��f}t|��dS)Nrz9Expected '%s' to not have been called. Called %s times.%sr5�r{r��_calls_repr�AssertionError�rBr	rrrrn\s
��z!NonCallableMock.assert_not_calledcCs$|jdkr d|jpd}t|��dS)Nrz"Expected '%s' to have been called.r5)r{r�rrrrrrmfs

�zNonCallableMock.assert_calledcCs0|jdks,d|jpd|j|��f}t|��dS)Nr�z:Expected '%s' to have been called once. Called %s times.%sr5rrrrrrons
��z"NonCallableMock.assert_called_oncecs��jdur.�����}d}d||f}t|�����fdd�}��t��fdd��}���j�}||kr�t|t�rv|nd}t|��|�dS)Nznot called.z0expected call not found.
Expected: %s
Actual: %scs�����}|Sr/�r�r	�rCrDrBrr�_error_message�sz:NonCallableMock.assert_called_with.<locals>._error_messageT��two)r|rrr�_Callr$�	Exception)rBrCrD�expected�actualZ
error_messager#�causerr"rrkxs
�z"NonCallableMock.assert_called_withcOs<|jdks,d|jpd|j|��f}t|��|j|i|��S)Nr�z3Expected '%s' to be called once. Called %s times.%sr5)r{r�rrrk�rBrCrDr	rrrrp�s
��z'NonCallableMock.assert_called_once_withc		s�fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||vr�|durXd}nd�dd�|D��}t|�d	t|���jd
d��d����|�dSt|�}g}|D]0}z|�|�Wq�t	y�|�
|�Yq�0q�|r�td
�jp�dt|�|f�|�dS)Ncsg|]}��|��qSr�r�r�cr�rrr��r!z4NonCallableMock.assert_has_calls.<locals>.<listcomp>css|]}t|t�r|VqdSr/�r$r'r�rrr�	<genexpr>�r!z3NonCallableMock.assert_has_calls.<locals>.<genexpr>c3s|]}��|�VqdSr/r,r-r�rrr0�r!zCalls not found.z+Error processing expected calls.
Errors: {}cSsg|]}t|t�r|nd�qSr/r/r�rrrr��s��
Expected: ZActual)�prefixr�z@%r does not contain all of %r in its call list, found %r insteadr5)
r�rsru�formatrr�rstriprZ�remover=r�r�r[)	rB�calls�	any_orderr(r*Z	all_calls�problem�	not_found�kallrr�rrq�sN
����������z NonCallableMock.assert_has_callscsj��t||fdd��}t|t�r$|nd}�fdd��jD�}|sL|t|�vrf��||�}td|�|�dS)NTr$csg|]}��|��qSrr,r-r�rrr��r!z3NonCallableMock.assert_any_call.<locals>.<listcomp>z%s call not found)rr&r$r'r}�_AnyComparerrr�rBrCrDr(r*r)rrr�rrr�s��zNonCallableMock.assert_any_callcKs�|�d�}||jdvr&tfi|��S|jrZd|vrBd|d��nd}|��|}t|��t|�}t|t�rz|t	vrzt}nbt|t
�r�|tvs�|jr�||jvr�t}q�t}n4t|t
�s�t|t�r�t}q�t|t�r�t}n
|jd}|fi|��S)Nr�r�rr�r�r�)r_r^r	r�r�r;r1r0r�_async_method_magicsr��_all_sync_magicsr��
CallableMixinrrrr])rBr�r�rVr
�_type�klassrrrr��s2

��



zNonCallableMock._get_child_mock�CallscCs"|js
dSd|�dt|j��d�S)Nr��
z: r�)rur)rBr2rrrr�szNonCallableMock._calls_repr)NNNNNNr�NFNF)F)FF)N)r)F)rB),rNrQr�r�r9r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr�rwr�r�rzr{r|r}ruZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr~rvr�r�r�r�rrr
rrrrrnrmrorkrprqrrr�rrrrrr�s^�
-
	�

�

''
!


-&rc@seZdZdd�ZdS)r;cCs,|D]"}tdd�t||�D��rdSqdS)NcSsg|]\}}||k�qSrr)rr(r)rrrr�s�z-_AnyComparer.__contains__.<locals>.<listcomp>TF)�all�zip)rB�itemrrrrr�s�z_AnyComparer.__contains__N)rNrQr�r�rrrrr;
sr;cCsJ|dur|St|�r|St|�r$|Sz
t|�WStyD|YS0dSr/)r3rYr�rr(rrrr�s
r�c
@sReZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r?Nr�c	Ks:||jd<tt|�j|||||||	|
fi|��||_dS)Nr�)r^r�r?r9r~)rBr�r~rwrrr�r�r�r�r�rDrrrr9.s


��zCallableMixin.__init__cOsdSr/rrArrrrI:szCallableMixin._mock_check_sigcOs0|j|i|��|j|i|��|j|i|��Sr/)rI�_increment_mock_call�
_mock_callrArrrr:?szCallableMixin.__call__cOs|j|i|��Sr/)�_execute_mock_callrArrrrHGszCallableMixin._mock_callcOsd|_|jd7_t||fdd�}||_|j�|�|jdu}|j}|j}|dk}|j	�td||f��|j
}|dur�|r�|j�t|||f��|jdu}|r�|jd|}t|||f�}	|j	�|	�|jr�|r�d}
nd}
|jdk}|j|
|}|j
}qpdS)NTr�r$r�r�r�)rzr{r&r|r}r�r�r�r�rur�rt)rBrCrDrZdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�rrrrGJs4


z"CallableMixin._increment_mock_callcOs�|j}|durTt|�r|�n,t|�s:t|�}t|�rH|�n||i|��}|turT|S|jturd|jS|jdur~|j|i|��S|jSr/)r~r3rYr�rr�rwr�)rBrCrD�effectrgrrrrIxs 

z CallableMixin._execute_mock_call)
rNrQr�rr9rIr:rHrGrIrrrrr?,s�
.r?c@seZdZdS)rN�rNrQr�rrrrr�srcCs6zt||�WSty0t|�t||�YS0dSr/)r&r;�
__import__)�thing�comp�import_pathrrr�_dot_lookup�s
rPcCsB|�d�}|�d�}t|�}|D]}|d|7}t|||�}q |S)Nr�rz.%s)r�r�rLrP)�targetZ
componentsrOrMrNrrr�	_importer�s

rRc@szeZdZdZgZdd�Zdd�Zdd�Zdd	�Ze	j
d
d��Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�_patchNc

Csn|dur(|turtd��|dur(td��||_||_||_||_||_||_d|_||_	||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF)
rr=�getterrVr��new_callabler��createZ	has_localr��autospecrD�additional_patchers)
rBrTrVr�r�rVr�rWrUrDrrrr9�s(��z_patch.__init__c
CsHt|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|���qSr)�copy)r�prrrr�sz_patch.copy.<locals>.<listcomp>)rSrTrVr�r�rVr�rWrUrD�attribute_namerX)rB�patcherrrrrY�s��z_patch.copycCs2t|t�r|�|�St�|�r(|�|�S|�|�Sr/)r$r1�decorate_classr'r�decorate_async_callable�decorate_callable�rBr-rrrr:s




z_patch.__call__cCsNt|�D]@}|�tj�sqt||�}t|d�s0q|��}t||||��q|S�Nr:)r�rr�TEST_PREFIXr&r%rYrT)rBrAr��
attr_valuer\rrrr]s

z_patch.decorate_classccs�g}t���f}|jD]8}|�|�}|jdur8|�|�q|jtur|�|�q|t	|�7}||fVWd�n1sx0YdSr/)
�
contextlib�	ExitStack�	patchings�
enter_contextr[�updater�rr�r[)rB�patchedrC�keywargs�
extra_args�
exit_stack�patchingr�rrr�decoration_helpers




z_patch.decoration_helpercs>t�d�r�j����St�����fdd����g�_�S)NrfcsD���||��"\}}�|i|��Wd�S1s60YdSr/�rn�rCrjZnewargsZnewkeywargs�r-rirBrrri3s�z)_patch.decorate_callable.<locals>.patched�r%rfr�rr`rrqrr_-s
z_patch.decorate_callablecs>t�d�r�j����St�����fdd����g�_�S)Nrfc�sJ���||��(\}}�|i|��IdHWd�S1s<0YdSr/rorprqrrriDs�z/_patch.decorate_async_callable.<locals>.patchedrrr`rrqrr^>s
z_patch.decorate_async_callablec	Cs�|��}|j}t}d}z|j|}Wn"ttfyFt||t�}Yn0d}|tvrdt|t	�rdd|_
|j
s�|tur�td||f��||fS)NFTz!%s does not have the attribute %r)rTrVrr^r;�KeyErrorr&�	_builtinsr$rrV)rBrQrrf�localrrr�get_originalOs 
�z_patch.get_originalcCs�|j|j|j}}}|j|j}}|j}|��|_|dur@d}|durLd}|durXd}|durp|durptd��|dus�|dur�|dvr�td��|�	�\}}|t
u�r�|du�r�d}	|dur�|}|dur�|}d}n&|dur�|dur�|}d}n|dur�|}|du�s|du�r.|t
u�rtd��t|t��r.d}	|du�rHt
|��rHt}
nt}
i}|du�r`|}
n^|du�st|du�r�|}|du�r�|}t|��r�d|v}
n
t|�}
t
|��r�t}
n
|
�r�t}
|du�r�||d<|du�r�||d	<t|
t��rt|
t��r|j�r|j|d
<|�|�|
fi|��}|	�r�t|��r�|}|du�rF|}t|��s^t|��s^t}
|�d
�|
f|dd�|��|_nl|du�r�|t
u�r�td
��|t
u�r�td��t|�}|du�r�|}t|f||jd�|��}n|�r�td��|}||_||_t� �|_!zrt"|j|j|�|j#du�rti}|jt
u�r>|||j#<|j$D](}|j!�%|�}|jt
u�rD|�|��qD|WS|WS|j&t'�(���s��Yn0dS)NFzCan't specify spec and autospec)TNz6Can't provide explicit spec_set *and* spec or autospecTz!Can't use 'spec' with create=Truer:r�r�rr�r�zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r��_namez.Can't pass kwargs to a mock we aren't creating))r�r�r�rWrDrUrTrQrrvrr$r1r*r	rr\r�rr0rrVrhr#rar�rw�boolr�
temp_original�is_localrdre�_exit_stackrTr[rXrg�__exit__�sys�exc_info)rBr�r�r�rWrDrUrfruZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrkrmr�rrr�	__enter__gs�
�








��



�
�


�

��


z_patch.__enter__cGs�|jr$|jtur$t|j|j|j�n>t|j|j�|jsbt|j|j�rP|jdvrbt|j|j|j�|`|`|`|j	}|`	|j
|�S)N)rOrQrR�__annotations__rS)rzryrrTrQrVrrVr%r{r|)rBr~rlrrrr|�s�z_patch.__exit__cCs|��}|j�|�|Sr/)r��_active_patchesr��rBrgrrr�startsz_patch.startcCs4z|j�|�Wnty$YdS0|�ddd�Sr/)r�r5r=r|r�rrr�stop	s
z_patch.stop)rNrQr�r[r�r9rYr:r]rd�contextmanagerrnr_r^rvr�r|r�r�rrrrrS�s 

rSc
sPz��dd�\�}Wn&tttfy:td�����Yn0�fdd�}||fS)Nr�r�z,Need a valid target to patch. You supplied: cst��Sr/�rRr�rQrrr�r!z_get_target.<locals>.<lambda>)�rsplitrr=r;)rQrVrTrr�r�_get_targets�
r�c

s>t��turt��d����fdd�}	t|	||||||||�	S)Nz3 must be the actual object to be patched, not a strcs�Sr/rrr�rrr�5r!z_patch_object.<locals>.<lambda>)r1�strrrS)
rQrVr�r�rVr�rWrUrDrTrr�r�
_patch_objects�
�r�c
s�t��tur�fdd�}n�fdd�}|s2td��t|���}|d\}	}
t||	|
|||||i�	}|	|_|dd�D]2\}	}
t||	|
|||||i�	}|	|_|j�|�qt|S)Ncst��Sr/r�rr�rrr�Sr!z!_patch_multiple.<locals>.<lambda>cs�Sr/rrr�rrr�Ur!z=Must supply at least one keyword argument with patch.multiplerr�)	r1r�r=rZr�rSr[rXr�)
rQr�rVr�rWrUrDrTr�rVr�r\Zthis_patcherrr�r�_patch_multiple<s,���r�c

Ks$t|�\}}	t||	|||||||�	Sr/)r�rS)
rQr�r�rVr�rWrUrDrTrVrrrrms
G
�rc@sVeZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�ZdS)�_patch_dictrFcKs,||_t|�|_|j�|�||_d|_dSr/)�in_dict�dictr�rh�clear�	_original)rBr�r�r�rDrrrr9�s

z_patch_dict.__init__cs.t�t�r����St����fdd��}|S)Ncs0���z�|i|��W���S���0dSr/)r��
_unpatch_dictr��frBrr�_inner�s�z$_patch_dict.__call__.<locals>._inner)r$r1r]r)rBr�r�rr�rr:�s


z_patch_dict.__call__cCsXt|�D]J}t||�}|�tj�rt|d�rt|j|j|j	�}||�}t
|||�q|Sra)r�r&rrrbr%r�r�r�r�rT)rBrAr�rc�	decoratorZ	decoratedrrrr]�s
�z_patch_dict.decorate_classcCs|��|jSr/)r�r�r�rrrr��sz_patch_dict.__enter__cCs�|j}t|jt�rt|j�|_|j}|j}z|��}Wn,tybi}|D]}||||<qLYn0||_|rvt	|�z|�
|�Wn(ty�|D]}||||<q�Yn0dSr/)r�r$r�r�rRr�rYr;r��_clear_dictrh)rBr�r�r�rfr�rrrr�s&z_patch_dict._patch_dictcCsP|j}|j}t|�z|�|�Wn(tyJ|D]}||||<q4Yn0dSr/)r�r�r�rhr;)rBr�rfr�rrrr�sz_patch_dict._unpatch_dictcGs|jdur|��dS�NF)r�r�)rBrCrrrr|)s
z_patch_dict.__exit__cCs|��}tj�|�|Sr/)r�rSr�r�r�rrrr�0sz_patch_dict.startcCs4ztj�|�Wnty$YdS0|�ddd�Sr/)rSr�r5r=r|r�rrrr�7s
z_patch_dict.stopN)rF)rNrQr�r9r:r]r�r�r�r|r�r�rrrrr��s
	
r�cCs<z|��Wn*ty6t|�}|D]
}||=q&Yn0dSr/)r�r;rZ)r��keysr�rrrr�Bsr�cCsttj�D]}|��q
dSr/)r�rSr�r�)rrrr�_patch_stopallKsr��testz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index round trunc floor ceil bool next fspath aiter zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr�r�nrrrr0jr!r0ccs|]}d|VqdS)zr%sNrr�rrrr0kr!>rr��__subclasses__Z__getinitargs__�
__setformat__�__getstate__�
__format__�__reversed__�__set__�__getnewargs__�__missing__�
__getformat__�__getnewargs_ex__r��
__reduce_ex__�__get__�
__delete__�__setstate__cs�fdd�}||_|S)Ncs�|g|�Ri|��Sr/r�rBrCr�r,rr�method|sz_get_method.<locals>.method)rN)rr-r�rr,rrzsrcCsh|]}d|�qS)r�r)rr�rrrr �s>�	__aexit__�	__anext__�
__aenter__�	__aiter__>rr�r9�__prepare__�__del__�__instancecheck__r��__subclasscheck__cCs
t�|�Sr/)r�__hash__r�rrrr��r!r�cCs
t�|�Sr/)r�__str__r�rrrr��r!cCs
t�|�Sr/)r�
__sizeof__r�rrrr��r!cCs"t|�j�d|���dt|���S)N�/)r1rNr�r�r�rrrr��r!)r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__r|�__complex__�	__float__�__bool__�	__index__r�cs�fdd�}|S)Ncs$�jj}|tur|S�|ur dStSr8)�__eq__r�r�NotImplemented)�other�ret_valr�rrr��sz_get_eq.<locals>.__eq__r)rBr�rr�r�_get_eq�sr�cs�fdd�}|S)Ncs �jjturtS�|urdStSr�)�__ne__r�rr�)r�r�rrr��s
z_get_ne.<locals>.__ne__r)rBr�rr�r�_get_ne�sr�cs�fdd�}|S)Ncs �jj}|turtg�St|�Sr/)�__iter__r�rr��r�r�rrr��sz_get_iter.<locals>.__iter__r)rBr�rr�r�	_get_iter�sr�cs�fdd�}|S)Ncs(�jj}|turttg��Stt|��Sr/)r�r�r�_AsyncIteratorr�r�r�rrr��sz"_get_async_iter.<locals>.__aiter__r)rBr�rr�r�_get_async_iter�sr�)r�r�r�r�cCsbt�|t�}|tur||_dSt�|�}|durB||�}||_dSt�|�}|dur^||�|_dSr/)�_return_valuesr_rrw�_calculate_return_value�_side_effect_methodsr~)r5r�rZfixedZreturn_calculatorrwZ
side_effectorrrr�_set_return_value�s

r�c@seZdZdd�Zdd�ZdS)�
MagicMixincOs*|��tt|�j|i|��|��dSr/)�_mock_set_magicsr�r�r9r�rrrr9�szMagicMixin.__init__cCs�ttB}|}t|dd�durX|�|j�}t�}||}|D]}|t|�jvr:t||�q:|tt|�j�}t|�}|D]}t	||t
||��qvdS)Nr�)�_magicsr=r&�intersectionr�rr1r^rrT�
MagicProxy)rBZorig_magicsZthese_magicsZ
remove_magicsr�r@rrrr��szMagicMixin._mock_set_magicsN)rNrQr�r9r�rrrrr��sr�c@seZdZddd�ZdS)rFcCs|�||�|��dSr/�r�r�r�rrrr�sz"NonCallableMagicMock.mock_add_specN)F�rNrQr�r�rrrrrsrc@seZdZdd�ZdS)�AsyncMagicMixincOs*|��tt|�j|i|��|��dSr/)r�r�r�r9r�rrrr9szAsyncMagicMixin.__init__N�rNrQr�r9rrrrr�sr�c@seZdZddd�ZdS)rFcCs|�||�|��dSr/r�r�rrrr�+szMagicMock.mock_add_specN)Fr�rrrrr src@s&eZdZdd�Zdd�Zddd�ZdS)	r�cCs||_||_dSr/�rr�)rBrr�rrrr97szMagicProxy.__init__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rTr�)rBr�r��mrrr�create_mock;s�zMagicProxy.create_mockNcCs|��Sr/)r�)rBr)r@rrrr�DszMagicProxy.__get__)N)rNrQr�r9r�r�rrrrr�6s	r�cs�eZdZed�Zed�Zed�Z�fdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ddd�Zdd�Z�fdd�Z�ZS)r�r�r�r�cs`t�j|i|��tjj|jd<d|jd<d|jd<t�|jd<ttd�}t	j
|_||jd<dS)Nr�rZ_mock_await_countZ_mock_await_argsZ_mock_await_args_list�r�r+)�superr9r�r�r�r^rsrrr'ZCO_COROUTINE�co_flags)rBrCrD�	code_mock�r�rrr9Ms


zAsyncMockMixin.__init__c�st||fdd�}|jd7_||_|j�|�|j}|dur�t|�rL|�nft|�s�zt|�}Wnt	yvt
�Yn0t|�r�|�n,t|�r�||i|��IdH}n||i|��}|tur�|S|j
tur�|jS|jdu�r
t|j�r�|j|i|��IdHS|j|i|��S|jS)NTr$r�)r&r�r�r�r�r~r3rYr��
StopIteration�StopAsyncIterationrrr�rwr�)rBrCrDrrJrgrrrrI]s6


z!AsyncMockMixin._execute_mock_callcCs(|jdkr$d|jpd�d�}t|��dS)Nr�	Expected r5z to have been awaited.�r�r�rrrrrr��s
zAsyncMockMixin.assert_awaitedcCs0|jdks,d|jpd�d|j�d�}t|��dS�Nr�r�r5z$ to have been awaited once. Awaited � times.r�rrrrr��s

�z"AsyncMockMixin.assert_awaited_oncecs��jdur&�����}td|�d������fdd�}��t��fdd��}���j�}||kr~t|t�rn|nd}t|��|�dS)NzExpected await: z
Not awaitedcs�j��dd�}|S)N�await)rr r!r"rrr#�sz:AsyncMockMixin.assert_awaited_with.<locals>._error_messageTr$)r�rrrr&r$r')rBrCrDr(r#r)r*rr"rr��s
z"AsyncMockMixin.assert_awaited_withcOs<|jdks,d|jpd�d|j�d�}t|��|j|i|��Sr�)r�r�rr�r+rrrr��s
�z'AsyncMockMixin.assert_awaited_once_withcsj��t||fdd��}t|t�r$|nd}�fdd��jD�}|sL|t|�vrf��||�}td|�|�dS)NTr$csg|]}��|��qSrr,r-r�rrr��r!z3AsyncMockMixin.assert_any_await.<locals>.<listcomp>z%s await not found)rr&r$r'r�r;rrr<rr�rr��s��zAsyncMockMixin.assert_any_awaitFc		s��fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||vr�|durXd}nd�dd�|D��}t|�d	t|��d
�j���|�dSt|�}g}|D]0}z|�|�Wq�ty�|�|�Yq�0q�|r�tdt	|�f�|�dS)Ncsg|]}��|��qSrr,r-r�rrr��r!z4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>css|]}t|t�r|VqdSr/r/r�rrrr0�r!z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>c3s|]}��|�VqdSr/r,r-r�rrr0�r!zAwaits not found.z,Error processing expected awaits.
Errors: {}cSsg|]}t|t�r|nd�qSr/r/r�rrrr��s�r1z	
Actual: z%r not all found in await list)
r�rsr�r3rrZr5r=r�r[)	rBr6r7r(r*Z
all_awaitsr8r9r:rr�rr��sF��������z AsyncMockMixin.assert_has_awaitscCs0|jdkr,d|jpd�d|j�d�}t|��dS)Nrr�r5z# to not have been awaited. Awaited r�r�rrrrr��s

�z!AsyncMockMixin.assert_not_awaitedcs*t�j|i|��d|_d|_t�|_dS�Nr)r�rvr�r�rsr�rAr�rrrv�szAsyncMockMixin.reset_mock)F)rNrQr�r�r�r�r�r9rIr�r�r�r�r�r�r�rv�
__classcell__rrr�rr�Hs(	
,	r�c@seZdZdS)r	NrKrrrrr	�sr	c@s$eZdZdd�Zdd�Zdd�ZdS)�_ANYcCsdSr8r�rBr�rrrr�-	sz_ANY.__eq__cCsdSr�rr�rrrr�0	sz_ANY.__ne__cCsdS)Nz<ANY>rr�rrrr�3	sz
_ANY.__repr__N)rNrQr�r�r�r�rrrrr�*	sr�cCs`d|}d}d�dd�|D��}d�dd�|��D��}|r@|}|rX|rP|d7}||7}||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)�repr)rr�rrrr�=	r!z*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�r�rrrr�>	s)r�r�)rrCrDrZformatted_argsZargs_stringZ
kwargs_stringrrrr:	s
�rc@sveZdZddd�Zddd	�Zd
d�ZejZdd
�Zdd�Z	dd�Z
dd�Zedd��Z
edd��Zdd�Zdd�ZdS)r&rr�NFTcCs�d}i}t|�}|dkr$|\}}}nr|dkrd|\}	}
t|	t�rX|	}t|
t�rR|
}qb|
}q�|	|
}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�t�|||f�St�||||f�S)Nr�r�r�)r�r$r�r[r�)r�r�rr�r%�	from_kallrCrD�_len�first�secondrrrr�_	s.



z
_Call.__new__cCs||_||_||_dSr/)r�r��_mock_from_kall)rBr�rr�r%r�rrrr9	sz_Call.__init__cCs\zt|�}Wnty"tYS0d}t|�dkr>|\}}n
|\}}}t|dd�rpt|dd�rp|j|jkrpdSd}|dkr�di}}n�|dkr�|\}}}n�|dkr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}di}}nd}|	}nV|dk�r4|\}
}t|
t��r(|
}t|t��r|i}}n
d|}}n
|
|}}ndS|�rL||k�rLdS||f||fkS)	Nr�r�r�Frrr�r�)r�rr�r&r�r$r[r�)rBr�Z	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsr�r�r�rrrr��	sN



�


z_Call.__eq__cOs<|jdurtd||fdd�S|jd}t|j||f||d�S)Nr�r�r�r��r�r&rrrrr:�	s

z_Call.__call__cCs2|jdurt|dd�Sd|j|f}t||dd�S)NF)rr�z%s.%s)rr�r�r�)rBr�rrrrr��	s
z_Call.__getattr__cCs|tjvrt�t�||�Sr/)r[r^r;�__getattribute__)rBr�rrrr��	s
z_Call.__getattribute__cCs(t|�dkr|\}}n
|\}}}||fS)Nr�)r�rrrr�_get_call_arguments�	s

z_Call._get_call_argumentscCs|��dSr��r�r�rrrrC�	sz
_Call.argscCs|��dS)Nr�r�r�rrrrD�	sz_Call.kwargscCs||js&|jpd}|�d�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|�d�shd|}nd|}t|||�S)Nrr�zcall%sr�zcall.%s)r�r�rr�r)rBrrCrDrrrr��	s





z_Call.__repr__cCs4g}|}|dur(|jr |�|�|j}qtt|��Sr/)r�r�r�rsr�)rBZvalsrMrrr�	call_list�	s
z_Call.call_list)rr�NFT)rNNFT)rNrQr�r�r9r�rr�r:r�r�r�r�rCrDr�r�rrrrr&L	s$�
 �
5

r&)r�c	Ksht|�rt|�}t|t�}t|�}d|i}|r8d|i}n|durDi}|rT|rTd|d<|�|�t}	t�|�rri}n8|r�|r�td��t	}	n"t
|�s�t}	n|r�|r�t|�s�t}	|�
d|�}|}
|dur�d}
|	f|||
|d�|��}t|t��rt||�}|�rt|�nt||||�|du�r,|�s,||j|<|�rV|�sVd	|v�rVt||dd
|d�|_t|�D�]}t|��rr�q^zt||�}
Wnt�y�Y�q^Yn0d|
i}|�r�d|
i}t|
t��s�t|
||||�}||j|<nn|}t|t��r�|j}t|||�}||d<t|
��rt	}nt}|f||||d
�|��}||j|<t|
||d�t|t��r^t|||��q^|S)Nr�r�Tr�zJInstance can not be True when create_autospec is mocking an async functionrr�)r�r�r�rrwr�)rLrwr�r�)r�rr�r�)rK)r\r1r$r.rhrr'Zisdatadescriptor�RuntimeErrorr	rYrrar�r6rjr�rMrrrwr�r�r&r;r�r5�
_must_skiprrT)r�r�rLr�rwrD�is_typeZ
is_async_funcr�rr�r5r�rfr�r�rKZchild_klassrrrr
s�




��


�


��
rcCsxt|t�s$|t|di�vrdS|j}|jD]H}|j�|t�}|turFq*t|tt	f�rZdSt|t
�rl|SdSq*|S)Nr^F)r$r1r&r�r]r^r_rrWrXr6)r�r�rrArgrrrr�
s


rc@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dSr/)r��idsr�r�rLr)rBr�r�r�rrrLrrrr9�
sz_SpecState.__init__)FNNNFr�rrrrr��
s�r�cCs"t|t�rt�|�St�|�SdSr/)r$�bytes�io�BytesIO�StringIO)�	read_datarrr�
_to_stream�
s

r	r�cs&t��}|dg���fdd�}��fdd�}��fdd����fdd����fd	d
�}tdur�ddl}ttt|j���tt|j����a|dur�t	dt
d
�}t	td����j_d�j
_d�j_d�j_d�j_|�j_���d<�d�j_|�j_��j_|�j_����fdd�}||_�|_|S)Ncs(�jjdur�jjS�dj|i|��Sr�)�	readlinesrwrb��_state�handlerr�_readlines_side_effect�
sz)mock_open.<locals>._readlines_side_effectcs(�jjdur�jjS�dj|i|��Sr�)�readrwrbrrr�_read_side_effect�
sz$mock_open.<locals>._read_side_effectc?s(��EdH�dj|i|��VqdSr�)�readlinerb)�_iter_side_effectrrr�_readline_side_effect�
sz(mock_open.<locals>._readline_side_effectc3s0�jjdur�jjVq�dD]
}|Vq dSr�)rrw)�linerrrr�
sz$mock_open.<locals>._iter_side_effectcs �jjdur�jjSt�d�Sr�)rrwr�rrrr�_next_side_effect�
sz$mock_open.<locals>._next_side_effectr�open)rr�)r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)r	rr~rrb)rrr
rrr�
reset_datas

zmock_open.<locals>.reset_data)r	�	file_spec�_iorZrr��
TextIOWrapper�unionrrrr�rw�writerrr
r~r�r�)r5rZ
_read_datarrrrrr)rrrr
rrr
�
s8"

r
c@s&eZdZdd�Zddd�Zdd�ZdS)	rcKstfi|��Sr/)r)rBrDrrrr�szPropertyMock._get_child_mockNcCs|�Sr/r)rBr)Zobj_typerrrr�szPropertyMock.__get__cCs||�dSr/r)rBr)r�rrrr�!szPropertyMock.__set__)N)rNrQr�r�r�r�rrrrrs	
rc	Cspd|_t|�D]\}zt||�}Wnty6YqYn0t|t�sDqt|j�|�t�rXq|j	|urt
|�qdSr8)r�r�r&r;r$rrr_r�r�r)r5r�r�rrrr%s



rc@seZdZdd�Zdd�ZdS)r�cCs&||_ttd�}tj|_||jd<dS)Nr�r+)�iteratorrrr'ZCO_ITERABLE_COROUTINEr�r^)rBrr�rrrr9As
z_AsyncIterator.__init__c�s(zt|j�WStyYn0t�dSr/)r�rr�r�r�rrrr�Gs
z_AsyncIterator.__anext__N)rNrQr�r9r�rrrrr�=sr�)F)F)NFNNN)FFNN)Nr�)}�__all__r�rdrr'r�r}�builtinsr�typesrrrZ
unittest.utilr�	functoolsrrr�rtr
r�r�r*r.r#r3r7r>rMrHrYr\rarjrer�r�rr�r�rr�MISSINGrZDELETEDr�r�r�rZrsr�r�r�rr<r9r�r;r�r?rrPrRrSr�r�r�rr�r�r�r�ZmultipleZstopallrbZ
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsrr�r=Z_sync_async_magicsZ
_async_magicsr>r�rr�r�r�r�r�r�r�r�r�r�rr�rr�r�r	r�rrr[r&rrrr�r1r�r6rr	r
rrr�rrrr�<module>s0	



1h4<�
�
2�
N	��	���
	
	�	8+:
�
�
N

?>