AlkantarClanX12

Your IP : 3.144.253.195


Current Path : /usr/lib64/python3.8/unittest/__pycache__/
Upload File :
Current File : //usr/lib64/python3.8/unittest/__pycache__/mock.cpython-38.opt-2.pyc

U

e5d��@s�dZdZddlZddlZddlZddlZddlZddlZddlZddl	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.d-d.d/d0d1d2d3d4hZ/d5d6�Z0Gd7d8�d8e1�Z2d9d:�Z3Gd;d<�d<e&�Z4Gd=d>�d>e&�Z5Gd?d@�d@e5�Z6dAdB�Z7GdCdD�dDe5�Z8GdEdF�dFe8e6�Z9dGdH�Z:dIdJ�Z;GdKdL�dLe&�Z<dMdN�Z=e*dddddfdOdP�Z>d�dQdR�Z?e*dddddfdSdT�Z@GdUdV�dVe&�ZAdWdX�ZBdYdZ�ZCe>e@_&eAe@_De?e@_EeCe@_Fd[e@_Gd\ZHd]ZId^�Jd_d`�eI�K�D��ZLd^�Jdad`�eI�K�D��ZMdbdcdddedfdgdhdidjdkdldmdndodpdqdrdshZNdtdu�ZOdvd�d^�JeHeIeLeMg��K�D�ZPdwdxdyhZQdzhZReQeRBZSePeNBZTeTeSBZUd{d|d}d~dd�d�d�hZVd�d��d�d��d�d��d�d��d��ZWeXeXeXeXd�dddd�d�d	d�dd��
ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]eZe[e\e]d��Z^d�d��Z_Gd�d��d�e5�Z`Gd�d��d�e`e6�ZaGd�d��d�e`�ZbGd�d��d�e`e9�ZcGd�d��d�e5�ZdGd�d��d�e5�ZeGd�d��d�eeebe9�ZfGd�d��d�e&�Zgeg�Zhd�d��ZiGd�d��d�ej�Zkekdd��Zld�d�d��Zmd�d��ZnGd�d��d�e&�Zoepem�epehjq�fZrdasd�d��Ztd�d�d��ZuGd�d��d�e9�Zvd�d��ZwGd�d��d��ZxdS)�)�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�sealz1.0�N)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partialcCsh|]}|�d�s|�qS��_��
startswith)�.0�name�r�%/usr/lib64/python3.8/unittest/mock.py�	<setcomp>(s
rTcCs>t|�rt|t�sdSt|d�r*t|d�}t�|�p<t�|�S)NF�__func__)	�_is_instance_mock�
isinstancer	�hasattr�getattr�asyncio�iscoroutinefunction�inspectZisawaitable��objrrr�
_is_async_obj0s


r*cCst|dd�rt�|�SdSdS)N�__code__F)r$r%r&��funcrrr�_is_async_func8s
r.cCstt|�t�S�N)�
issubclass�typerr(rrrr!?sr!cCst|t�pt|t�ot|t�Sr/)r"�
BaseExceptionr1r0r(rrr�
_is_exceptionEs
�r3cCs"t|t�rt|d�r|jS|SdS�N�mock)r"�
FunctionTypesr#r5r(rrr�
_extract_mockLsr7cCs�t|t�r|s|j}d}n,t|t�sFz
|j}Wntk
rDYdSX|rVt|d�}n|}z|t�|�fWSt	k
r�YdSXdS�NT)
r"r1�__init__r6�__call__�AttributeErrorrr'�	signature�
ValueError)r-Zas_instanceZeat_selfZsig_funcrrr�_get_signature_objectUs

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

rMc	Cs:dD]0}zt||t||��Wqtk
r2YqXqdS)N)�__name__�__doc__�__text_signature__�
__module__�__defaults__�__kwdefaults__)�setattrr$r;)r-�funcopy�	attributerrrrH~s
rHcCs@t|t�rdSt|tttf�r(t|j�St|dd�dk	r<dSdS)NTr:F)r"r1�staticmethod�classmethodr�	_callabler r$r(rrrrY�s

rYcCst|�ttfkSr/)r1�list�tupler(rrr�_is_list�sr\cCsFt|t�st|dd�dk	S|f|jD]}|j�d�dk	r&dSq&dS)Nr:TF)r"r1r$�__mro__�__dict__�get)r)�baserrr�_instance_callable�s
racs�t|t�}t|||�}|dkr"|S|\}��fdd�}t||�|j}|��sRd}||d�}d|}	t|	|�||}
t|
|��|
S)Ncs�j||�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||�Sr/)�assert_called_withrb�r5rrrk�sz'_setup_func.<locals>.assert_called_withcs�j||�Sr/)�
assert_calledrbrlrrrm�sz"_setup_func.<locals>.assert_calledcs�j||�Sr/)�assert_not_calledrbrlrrrn�sz&_setup_func.<locals>.assert_not_calledcs�j||�Sr/)�assert_called_oncerbrlrrro�sz'_setup_func.<locals>.assert_called_oncecs�j||�Sr/)�assert_called_once_withrbrlrrrp�sz,_setup_func.<locals>.assert_called_once_withcs�j||�Sr/)�assert_has_callsrbrlrrrq�sz%_setup_func.<locals>.assert_has_callscs�j||�Sr/)�assert_any_callrbrlrrrr�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_����j}t|�r6|�k	r6|��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|�||�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)	r%�
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�rw�_mock_return_valuer~�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCs8t�|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�Sr/)r�r$)rBr�	_the_namerFrrr�_getAs
z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<nt|||�dSr/)r�r^rT)rB�valuerr�rFrrr�_setFs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�Ss
z_CallList.__contains__cCst�t|��Sr/)�pprintZpformatrZr�rrrr�asz_CallList.__repr__N)rNrQr�r�r�rrrrrsQsrscCs|t|�}t|�sdS|js4|js4|jdk	s4|jdk	r8dS|}|dk	rX||krPdS|j}q<|rh||_||_|rx||_||_dS)NFT)r7r!r�r�r�r�)�parentr�r�new_name�_parentrrr�_check_and_set_parentes*��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)Rrc	Os�|f}t|t�s^t�tj�}|j|f|�|�j}dd�|��D�}|r^t	||d�r^t
|f}t|j|d|j
i�}tt|��|�}|S)NcSsg|]}|�d�r|�qS��specr�r�argrrr�
<listcomp>�s
�z+NonCallableMock.__new__.<locals>.<listcomp>rrO)r0r	r'r<rr9Zbind_partialZ	arguments�keysr*�AsyncMockMixinr1rNrO�_safe_super�__new__)	�clsrC�kw�basesrFZ
bound_argsZspec_arg�newrLrrrr��s
�zNonCallableMock.__new__N�FcKs�|dkr|}|j}
||
d<||
d<||
d<||
d<d|
d<|dk	rJ|}d}|
dkrZ|dk	}
|�|||	|
�i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t�|
d<t�|
d<t�|
d<||
d<|r�|jf|�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�rr�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsaferDr^rrrr9�sD



�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] }t�t||d��r|�|�q|dk	r~t|�s~t|t�rV|}nt|�}t|||�}	|	ot|	d}t|�}|j	}
||
d<||
d<||
d<||
d<||
d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)
�dirr%r&r$�appendr\r"r1r>r^)rBr�r�r�r�r�r�r�r��resr^rrrr��s,
�zNonCallableMock._mock_add_speccCs8|j}|jdk	r|jj}|tkr4|j|dd�}||_|S)N�()�r�r�)r�r�rwr�_get_child_mock)rBrxrrrZ__get_return_values
�z"NonCallableMock.__get_return_valuecCs,|jdk	r||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|jdkrt|�S|jSr/)r�r1r�rrr�	__class__!s
zNonCallableMock.__class__rzr{r|r}rucCsN|j}|dkr|jS|j}|dk	rJt|�sJt|t�sJt|�sJt|�}||_|Sr/)r�r�r~�callabler"r�r3)rB�	delegatedZsfrrrZ__get_side_effect.s��z!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dSr/)�	_try_iterr�r�r~)rBr�r�rrrZ__set_side_effect9s
z!NonCallableMock.__set_side_effect)rwr~cCs�|dkrg}t|�|krdS|�t|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_|j�
�D]"}t|t�sr|tkr�qr|�|�qr|j
}t|�r�||k	r�|�|�dS)NFr)�idr�rzr|r{rsrur}rtrr�r�r�valuesr"�
_SpecState�_deletedrvr!)rBZvisitedrwr~�childrxrrrrvDs,zNonCallableMock.reset_mockcKsXt|��dd�d�D]>\}}|�d�}|��}|}|D]}t||�}q6t|||�qdS)NcSs|d�d�S)Nr�.)�count)�entryrrr�<lambda>o�z0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�)�sorted�items�split�popr$rT)rBrDr��valrC�finalr)r�rrrr�bs	�
zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk	r<||jks.|tkrLtd|��nt|�rLt|��|jsd|�d�rdtd��|j�|�}|tkr�t|��np|dkr�d}|j	dk	r�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�xsF




�
�
zNonCallableMock.__getattr__cCs�|jg}|j}|}d}|dgkr$d}|dk	rZ|}|�|j|�d}|jdkrRd}|j}q$tt|��}|jpnd}t|�dkr�|ddkr�|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}|dkrd|}d}|jdk	rDd}|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|]\}}|tk	r|�qSr)r�)rZm_nameZm_valuerrrr��s�z+NonCallableMock.__dir__.<locals>.<listcomp>cSsg|]}|�d�s|�qSrr�r�errrr��s
cSs"g|]}|�d�rt|�r|�qSr)rr�rrrrr��s
�)r
�object�__dir__r�r�r1rZr^rr�r��set)rBZextrasZ	from_typeZ	from_dictZfrom_child_mocksrrrr�s


�zNonCallableMock.__dir__csT|tkrt��||�S�jrH�jdk	rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk	r�|�jkr�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��f|�|�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�|tkr2|t|�jkr2tt|�|�||jkr2dS|j�|t�}||jkr\tt|��	|�n|t
krlt|��|tk	r||j|=t
|j|<dSr/)r�r1r^�delattrrr_�_missingr�r�__delattr__r�r;)rBrr)rrrrs

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]:}|�|�}|dksJt|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}|dk	r�t|�dkrNd}|\}}n
|\}}}z||j||�fWStk
r�}z|�d�WY�Sd}~XYq�Xn|SdS)Nr�rr�)r"r[r�rr�r@�	TypeError�with_traceback)rB�_callrFrrCrDrrrr�
_call_matcherHs

"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
rrrrnbs
��z!NonCallableMock.assert_not_calledcCs$|jdkr d|jpd}t|��dS)Nrz"Expected '%s' to have been called.r5)r{r�rr rrrrmls

�zNonCallableMock.assert_calledcCs0|jdks,d|jpd|j|��f}t|��dS)Nr�z:Expected '%s' to have been called once. Called %s times.%sr5rr rrrrots
��z"NonCallableMock.assert_called_oncecs��jdkr.�����}d}d||f}t|�����fdd�}����f�}���j�}||kr~t|t�rn|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_message)r|rrrr"�	Exception)rBrCrD�expected�actualZ
error_messager$�causerr#rrk~s
�z"NonCallableMock.assert_called_withcOs8|jdks,d|jpd|j|��f}t|��|j||�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�||kr�|dkrXd}nd�dd�|D��}t|�d	t|���jd
d��d����|�dSt|�}g}|D]2}z|�|�Wq�t	k
r�|�
|�Yq�Xq�|�rtd
�jp�dt|�|f�|�dS)Ncsg|]}��|��qSr�r�r�cr�rrr��sz4NonCallableMock.assert_has_calls.<locals>.<listcomp>css|]}t|t�r|VqdSr/�r"r%rrrr�	<genexpr>�s
z3NonCallableMock.assert_has_calls.<locals>.<genexpr>c3s|]}��|�VqdSr/r*r+r�rrr.�szCalls not found.z+Error processing expected calls.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��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�sH
��"������z NonCallableMock.assert_has_callscsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)Ncsg|]}��|��qSrr*r+r�rrr��sz3NonCallableMock.assert_any_call.<locals>.<listcomp>z%s call not found)rr}r"r%rr�rBrCrDr&r'r(rrr�rrr�s��zNonCallableMock.assert_any_callcKs�|�d�}||jdkr"tf|�St|�}t|t�rB|tkrBt}nbt|t�rp|tksd|j	rj||j	krjt}q�t}n4t|t
�s�t|t�r�t}q�t|t�r�t
}n
|jd}|jr�d|kr�d|dnd}|��|}t|��|f|�S)Nr�r�r�rr�r�)r_r^r	r1r0r�_async_method_magicsr��_all_sync_magicsr��
CallableMixinrrrr]r�r�r;)rBr�r��_type�klassrVrrrrr��s2


��



zNonCallableMock._get_child_mock�CallscCs"|js
dSd|�dt|j��d�S)Nr��
z: r�)rur)rBr0rrrrszNonCallableMock._calls_repr)NNNNNNr�NFNF)F)FF)N)r)F)r?),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�rrrrrrrrnrmrorkrprqrrr�rrrrrr�sn�
-
	�

�

''
!


-'rcCsL|dkr|St|�r|St|�r$|Sz
t|�WStk
rF|YSXdSr/)r3rYr�rr(rrrr�s
r�c
@sReZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r<Nr�c	Ks6||jd<tt|�j|||||||	|
f|�||_dS)Nr�)r^r�r<r9r~)rBr�r~rwrrr�r�r�r�r�rDrrrr9#s

��zCallableMixin.__init__cOsdSr/rrArrrrI/szCallableMixin._mock_check_sigcOs$|j||�|j||�|j||�Sr/)rI�_increment_mock_call�
_mock_callrArrrr:4szCallableMixin.__call__cOs|j||�Sr/)�_execute_mock_callrArrrrB<szCallableMixin._mock_callcOsd|_|jd7_t||fdd�}||_|j�|�|jdk	}|j}|j}|dk}|j	�td||f��|j
}|dk	r�|r�|j�t|||f��|jdk	}|r�|jd|}t|||f�}	|j	�|	�|jr�|r�d}
nd}
|jdk}|j|
|}|j
}qpdS)NTr���twor�r�r�)rzr{�_Callr|r}r�r�r�r�rur�rt)rBrCrDrZdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�rrrrA?s4


z"CallableMixin._increment_mock_callcOs||j}|dk	rPt|�r|�n(t|�s:t|�}t|�rD|�n
|||�}|tk	rP|S|jtk	r`|jS|jdk	rv|j||�S|jSr/)r~r3rYr�rr�rwr�)rBrCrD�effectrgrrrrCms 


z CallableMixin._execute_mock_call)
rNrQr�rr9rIr:rBrArCrrrrr<!s�
.r<c@seZdZdS)rN�rNrQr�rrrrr�srcCs8zt||�WStk
r2t|�t||�YSXdSr/)r$r;�
__import__)�thing�comp�import_pathrrr�_dot_lookup�s
rMcCsB|�d�}|�d�}t|�}|D]}|d|7}t|||�}q |S)Nr�rz.%s)r�r�rIrM)�targetZ
componentsrLrJrKrrr�	_importer�s

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

Csn|dk	r(|tk	rtd��|dk	r(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)
rBrQrVr�r�rSr�rTrRrDrrrr9�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>)rPrQrVr�r�rSr�rTrRrD�attribute_namerU)rB�patcherrrrrV�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#rVrT)rBr>r��
attr_valuerYrrrrZs

z_patch.decorate_classc	csrg}t���\}|jD]8}|�|�}|jdk	r8|�|�q|jtkr|�|�q|t	|�7}||fVW5QRXdSr/)
�
contextlib�	ExitStack�	patchings�
enter_contextrX�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)Nrcc
s4���||��\}}�||�W5QR�SQRXdSr/�rk�rCrgZnewargsZnewkeywargs�r-rfrBrrrf(s�z)_patch.decorate_callable.<locals>.patched�r#rcr�rr]rrnrr\"s
z_patch.decorate_callablecs>t�d�r�j����St�����fdd����g�_�S)Nrcc
�s:���||��"\}}�||�IdHW5QR�SQRXdSr/rlrmrnrrrf9s�z/_patch.decorate_async_callable.<locals>.patchedror]rrnrr[3s
z_patch.decorate_async_callablec	Cs�|��}|j}t}d}z|j|}Wn$ttfk
rHt||t�}YnXd}|tkrft|t	�rfd|_
|j
s�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r)rQrVrr^r;�KeyErrorr$�	_builtinsr"rrS)rBrNrrf�localrrr�get_originalDs 
�z_patch.get_originalcCs�|j|j|j}}}|j|j}}|j}|��|_|dkr@d}|dkrLd}|dkrXd}|dk	rp|dk	rptd��|dk	s�|dk	r�|dkr�td��|�	�\}}|t
k�r||dk�r|d}	|dkr�|}|dkr�|}d}n&|dk	r�|dkr�|}d}n|dkr�|}|dk	�s|dk	�r.|t
k�rtd��t|t��r.d}	|dk�rHt
|��rHt}
nt}
i}|dk	�r`|}
n^|dk	�st|dk	�r�|}|dk	�r�|}t|��r�d|k}
n
t|�}
t
|��r�t}
n
|
�r�t}
|dk	�r�||d<|dk	�r�||d	<t|
t��rt|
t��r|j�r|j|d
<|�|�|
f|�}|	�r�t|��r�|}|dk	�rB|}t|��sZt|��sZt}
|�d
�|
f|dd�|��|_nl|dk	�r�|t
k	�r�td
��|t
k�r�td��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t� �|_!zrt"|j|j|�|j#dk	�rpi}|jt
k�r:|||j#<|j$D](}|j!�%|�}|jt
k�r@|�|��q@|WS|WS|j&t'�(���s��YnXdS)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�rTrDrRrQrNrrsrr"r1r*r	rr\r�rr0rrVrer!rar�rw�boolr�
temp_original�is_localrarb�_exit_stackrTrXrUrd�__exit__�sys�exc_info)rBr�r�r�rTrDrRrfrrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrhrjr�rrr�	__enter__\s�
�








��




�
�


�

��


z_patch.__enter__cGs�|jr$|jtk	r$t|j|j|j�n>t|j|j�|jsbt|j|j�rP|jdkrbt|j|j|j�|`|`|`|j	}|`	|j
|�S)N)rOrQrR�__annotations__rS)rwrvrrTrNrVrrSr#rxry)rBr{rirrrry�s�z_patch.__exit__cCs|��}|j�|�|Sr/)r~�_active_patchesr�)rBrgrrr�start�sz_patch.startcCs6z|j�|�Wntk
r&YdSX|�ddd�Sr/)r�r3r=ryr�rrr�stop�s
z_patch.stop)rNrQr�rXr�r9rVr:rZra�contextmanagerrkr\r[rsr~ryr�r�rrrrrP�s 

rPc	sPz��dd�\�}Wn&ttfk
r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��Sr/�rOr�rNrrr�r�z_get_target.<locals>.<lambda>)�rsplitrr=)rNrVrQrr�r�_get_target
s�r�c

s>t��tkrt��d����fdd�}	t|	||||||||�	S)Nz3 must be the actual object to be patched, not a strcs�Sr/rrr�rrr�*r�z_patch_object.<locals>.<lambda>)r1�strrrP)
rNrVr�r�rSr�rTrRrDrQrr�r�
_patch_objects ��r�c
s�t��tkr�fdd�}n�fdd�}|s2td��t|���}|d\}	}
t||	|
|||||i�	}|	|_|dd�D]2\}	}
t||	|
|||||i�	}|	|_|j�|�qt|S)Ncst��Sr/r�rr�rrr�Hr�z!_patch_multiple.<locals>.<lambda>cs�Sr/rrr�rrr�Jr�z=Must supply at least one keyword argument with patch.multiplerr�)	r1r�r=rZr�rPrXrUr�)
rNr�rSr�rTrRrDrQr�rVr�rYZthis_patcherrr�r�_patch_multiple1sH���r�c

Ks$t|�\}}	t||	|||||||�	Sr/)r�rP)
rNr�r�rSr�rTrRrDrQrVrrrrbsF�rc@sNeZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	eZ
e	ZdS)�_patch_dictrFcKs,||_t|�|_|j�|�||_d|_dSr/)�in_dict�dictr�re�clear�	_original)rBr�r�r�rDrrrr9�s

z_patch_dict.__init__cs.t�t�r����St����fdd��}|S)Ncs&���z�||�W�S���XdSr/)r��
_unpatch_dictr��frBrr�_inner�sz$_patch_dict.__call__.<locals>._inner)r"r1rZr)rBr�r�rr�rr:�s


z_patch_dict.__call__cCsXt|�D]J}t||�}|�tj�rt|d�rt|j|j|j	�}||�}t
|||�q|Sr^)r�r$rrr_r#r�r�r�r�rT)rBr>r�r`Z	decoratorZ	decoratedrrrrZ�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.tk
rdi}|D]}||||<qNYnX||_|rxt	|�z|�
|�Wn*tk
r�|D]}||||<q�YnXdSr/)r�r"r�r�rOr�rVr;r��_clear_dictre)rBr�r�r�rfr�rrrr��s&z_patch_dict._patch_dictcCsR|j}|j}t|�z|�|�Wn*tk
rL|D]}||||<q6YnXdSr/)r�r�r�rer;)rBr�rfr�rrrr�sz_patch_dict._unpatch_dictcGs|��dS�NF)r�)rBrCrrrrysz_patch_dict.__exit__N)rF)rNrQr�r9r:rZr~r�r�ryr�r�rrrrr��s
	
r�cCs>z|��Wn,tk
r8t|�}|D]
}||=q(YnXdSr/)r�r;rZ)r�r�r�rrrr�&sr�cCsttj�D]}|��q
dSr/)r�rPr�r�)rrrr�_patch_stopall/sr�Ztestz�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�nrrrr.Nsr.ccs|]}d|VqdS)zr%sNrr�rrrr.Os�__get__�__set__�
__delete__�__reversed__�__missing__r��
__reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__�
__getformat__Z
__setformat__r�r�__subclasses__�
__format__�__getnewargs_ex__cs�fdd�}||_|S)Ncs�|f|�|�Sr/r�rBrCr�r,rr�method`sz_get_method.<locals>.method)rN)rr-r�rr,rr	^sr	cCsh|]}d|�qS)r�r)rr�rrrrfs�
__aenter__�	__aexit__�	__anext__�	__aiter__r�rr9r��__prepare__�__instancecheck__�__subclasscheck__�__del__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__ry�__complex__�	__float__�__bool__�	__index__r�cs�fdd�}|S)Ncs$�jj}|tk	r|S�|kr 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 �jjtk	rtS�|krdStSr�)�__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}|tkrtg�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}|tkrttg��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�}|tk	r||_dSt�|�}|dk	rB||�}||_dSt�|�}|dk	r^||�|_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||�|��dSr/)�_mock_set_magicsr�r�r9r�rrrr9�szMagicMixin.__init__cCs�ttB}|}t|dd�dk	rX|�|j�}t�}||}|D]}|t|�jkr:t||�q:|tt|�j�}t|�}|D]}t	||t
||��qvdS)Nr�)�_magicsr:r$�intersectionr�rr1r^rrT�
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||�|��dSr/)r�r�r�r9r�rrrr9�szAsyncMagicMixin.__init__N�rNrQr�r9rrrrr��sr�c@seZdZddd�ZdS)rFcCs|�||�|��dSr/r�r�rrrr�szMagicMock.mock_add_specN)Fr�rrrrrsrc@s&eZdZdd�Zdd�Zddd�ZdS)	r�cCs||_||_dSr/�rr�)rBrr�rrrr9szMagicProxy.__init__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rTr�)rBr�r��mrrr�create_mocks�zMagicProxy.create_mockNcCs|��Sr/)r�)rBr)r=rrrr�(szMagicProxy.__get__)N)rNrQr�r9r�r�rrrrr�s	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||�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�rrr91s


zAsyncMockMixin.__init__c�st||fdd�}|jd7_||_|j�|�|j}|dk	r�t|�rL|�nbt|�s�zt|�}Wnt	k
rxt
�YnXt|�r�|�n&t�|�r�|||�IdH}n
|||�}|t
k	r�|S|jt
k	r�|jS|jdk	r�t�|j�r�|j||�IdHS|j||�S|jS)NTrDr�)rFr�r�r�r�r~r3rYr��
StopIteration�StopAsyncIterationr%r&rr�rwr�)rBrCrDrrGrgrrrrCAs6




z!AsyncMockMixin._execute_mock_callcCs(|jdkr$d|jpd�d�}t|��dS)Nr�	Expected r5z to have been awaited.�r�r�rr rrrr�is
zAsyncMockMixin.assert_awaitedcCs0|jdks,d|jpd�d|j�d�}t|��dS�Nr�r�r5z$ to have been awaited once. Awaited � times.r�r rrrr�qs
z"AsyncMockMixin.assert_awaited_oncecsz�jdkr&�����}td|�d������fdd�}����f�}���j�}||krvt|t�rf|nd}t|��|�dS)NzExpected await: z
Not awaitedcs�j��dd�}|S)N�await)rr!r"r#rrr$�sz:AsyncMockMixin.assert_awaited_with.<locals>._error_message)r�rrrr"r%)rBrCrDr&r$r'r(rr#rr�zs
z"AsyncMockMixin.assert_awaited_withcOs8|jdks,d|jpd�d|j�d�}t|��|j||�Sr�)r�r�rr�r)rrrr��s
z'AsyncMockMixin.assert_awaited_once_withcsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)Ncsg|]}��|��qSrr*r+r�rrr��sz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>z%s await not found)rr�r"r%rrr9rr�rr��s��zAsyncMockMixin.assert_any_awaitFc		s��fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�dd�|D��}t|�d	t|��d
�j���|�dSt|�}g}|D]2}z|�|�Wq�tk
r�|�|�Yq�Xq�|r�tdt	|�f�|�dS)Ncsg|]}��|��qSrr*r+r�rrr��sz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>css|]}t|t�r|VqdSr/r-rrrrr.�s
z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>c3s|]}��|�VqdSr/r*r+r�rrr.�szAwaits not found.z,Error processing expected awaits.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s�r/z	
Actual: z%r not all found in await list)
r�rsr�r1rrZr3r=r�r[)	rBr4r5r&r(Z
all_awaitsr6r7r8rr�rr��s>������z AsyncMockMixin.assert_has_awaitscCs0|jdkr,d|jpd�d|j�d�}t|��dS)Nrr�r5z# to not have been awaited. Awaited r�r�r rrrr��s
z!AsyncMockMixin.assert_not_awaitedcs&t�j||�d|_d|_t�|_dS�Nr)r�rvr�r�rsr�rAr�rrrv�szAsyncMockMixin.reset_mock)F)rNrQr�r�r�r�r�r9rCr�r�r�r�r�r�r�rv�
__classcell__rrr�rr�,s(	
,	r�c@seZdZdS)r	NrHrrrrr	�sr	c@s$eZdZdd�Zdd�Zdd�ZdS)�_ANYcCsdSr8r�rBr�rrrr�	sz_ANY.__eq__cCsdSr�rr�rrrr�	sz_ANY.__ne__cCsdS)Nz<ANY>rr�rrrr�	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)�reprr�rrrr�!	sz*_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@s�eZdZd dd�Zd!dd	�Zd
d�ZejZdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zdd�Zdd�ZdS)"rFrr�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�rE�	from_kallrCrD�_len�first�secondrrrr�C	s.



z
_Call.__new__cCs||_||_||_dSr/)r�r��_mock_from_kall)rBr�rr�rEr�rrrr9c	sz_Call.__init__cCsh|tkrdSzt|�}Wntk
r.YdSXd}t|�dkrJ|\}}n
|\}}}t|dd�r|t|dd�r||j|jkr|dSd}|dkr�di}}n�|dkr�|\}}}n�|d	kr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}di}}nd}|	}nV|dk�r@|\}
}t|
t��r4|
}t|t��r(|i}}n
d|}}n
|
|}}ndS|�rX||k�rXdS||f||fkS)
NTFr�r�r�rrr�r�)rr�rr$r�r"r[r�)rBr�Z	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsr�r�r�rrrr�j	sR


�

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

z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rr�z%s.%s)rr�r�r�)rBr�rrrrr��	s
z_Call.__getattr__cCs|tjkrt�t�||�Sr/)r[r^r;�__getattribute__)rBr�rrrr��	s
z_Call.__getattribute__cOs|�d�||�S)Nr��r�rArrrr��	sz_Call.countcOs|�d�||�S)N�indexr�rArrrr��	sz_Call.indexcCs(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}|}|dk	r(|jr |�|�|j}qtt|��Sr/)r�r�r�rsr�)rBZvalsrJrrr�	call_list�	s
z_Call.call_list)rr�NFT)rNNFT)rNrQr�r�r9r�rr�r:r�r�r�r�r�r�rCrDr�r�rrrrrF0	s(�
 �
7

rF)r�c	Kslt|�rt|�}t|t�}t|�}d|i}|r8d|i}n|dkrDi}|rT|rTd|d<|�|�t}	t�|�rri}n8|r�|r�td��t	}	n"t
|�s�t}	n|r�|r�t|�s�t}	|�
d|�}|}
|dkr�d}
|	f|||
|d�|��}t|t��rt||�}|�rt|�nt||||�|dk	�r,|�s,||j|<|�rV|�sVd	|k�rVt||dd
|d�|_t|�D�]}t|��rr�q^zt||�}
Wntk
�r�Y�q^YnXd|
i}|�r�d|
i}t|
t��s�t|
||||�}||j|<np|}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�)rLrtr�r�)r�rr�r�)rK)r\r1r"r.rerr'Zisdatadescriptor�RuntimeErrorr	rYrrar�r6rjr�rMrrrwr�r�r$r;r�r5�
_must_skipr%r&rT)r�r�rLr�rtrD�is_typeZ
is_async_funcr}r|r�r5r�rfr�r�rKZchild_klassrrrr�	s�




��


�

��
rcCsxt|t�s$|t|di�krdS|j}|jD]H}|j�|t�}|tkrFq*t|tt	f�rZdSt|t
�rl|SdSq*|S)Nr^F)r"r1r$r�r]r^r_rrWrXr6)r�r�r�r>rgrrrr�w
s


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

rr�cs&t��}|dg���fdd�}��fdd�}��fdd����fdd����fd	d
�}tdkr�ddl}ttt|j���tt|j����a|dkr�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$�jjdk	r�jjS�dj||�Sr�)�	readlinesrwrb��_state�handlerr�_readlines_side_effect�
sz)mock_open.<locals>._readlines_side_effectcs$�jjdk	r�jjS�dj||�Sr�)�readrwrbrrr�_read_side_effect�
sz$mock_open.<locals>._read_side_effectc?s$��EdH�dj||�VqdSr�)�readlinerb)�_iter_side_effectrrr�_readline_side_effect�
sz(mock_open.<locals>._readline_side_effectc3s0�jjdk	r�jjVq�dD]
}|Vq dSr�)rrw)�linerrrr�
sz$mock_open.<locals>._iter_side_effectcs �jjdk	r�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�)rrr~rrb)r
rrrrr�
reset_data�
s

zmock_open.<locals>.reset_data)r�	file_spec�_iorZrr��
TextIOWrapper�unionrrrr~rw�writer	rrr~r�r�)r5rZ
_read_datarr
rrrr)rr
rrrrr
�
s8"

r
c@s&eZdZdd�Zddd�Zdd�ZdS)	rcKs
tf|�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�rrrrr�
s	
rc	Cs^d|_t|�D]J}zt||�}Wntk
r8YqYnXt|t�sFq|j|krt|�qdSr8)r�r�r$r;r"rr�r)r5r�r�rrrrs



rc@s$eZdZdd�Zdd�Zdd�ZdS)r�cCs&||_ttd�}tj|_||jd<dS)Nr�r+)�iteratorrrr'ZCO_ITERABLE_COROUTINEr�r^)rBrr�rrrr9+s
z_AsyncIterator.__init__cCs|Sr/rr�rrrr�1sz_AsyncIterator.__aiter__c�s*zt|j�WStk
r YnXt�dSr/)r�rr�r�r�rrrr�4s
z_AsyncIterator.__anext__N)rNrQr�r9r�r�rrrrr�'sr�)F)F)NFNNN)FFNN)Nr�)y�__all__�__version__r%rar�r'r�rz�builtins�typesrrrZ
unittest.utilr�	functoolsrrr�rqr
r�r�r*r.r!r3r7r>rMrHrYr\rarjrer�r�rr�r�rr�MISSINGr
ZDELETEDr�r�r�rZrsr�r�r�rr�r<rrMrOrPr�r�r�rr�r�r�r�ZmultipleZstopallr_Z
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr	r�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[rFrrr�r�r1r�r6rrr
rrr�rrrr�<module>s~	



1�	h4<�
�
2�
Mw	���	�
���
	
	�	8+B
�
�
N