ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/mock/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/mock/__pycache__/mock.cpython-311.pyc

�

�܋f/����dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZddlmZmZddlmZddlmZdd	lmZGd
�de��Zd�ee��D��Zd
ZeZd�Zd�Zd�Z d�Z!d�Z"d�Z#d�d�Z$d�Z%d�Z&d�Z'd�Z(d�d�Z)d�d�Z*d�Z+d�Z,d�Z-Gd�d e.��Z/Gd!�d"e.��Z0e0��Z1e1j2Z2e1j3Z4e1j5Z6hd#�Z7d$�Z8Gd%�d&e9��Z:d'�Z;Gd(�d)e.��Z<Gd*�d+e.��Z=Gd,�d-e=��Z>	e?j@Z@n#eA$rd.�Z@YnwxYweBd/�ee>��D����ZCGd0�d1e9��ZDd2�ZEGd3�d4e=��ZFGd5�d6eFe>��ZGd7�ZHd8�ZId9�ZJGd:�d;e.��ZKd<�ZLe2dddddfdd=�d>�ZM		d�d?�ZNe2dddddfdd=�d@�ZOGdA�dBe.��ZPdC�ZQdD�ZReMeO_.ePeO_SeNeO_TeReO_UdEeO_VdFZWereW�XdGdH��ZWdIZYdJ�ZdK�eY�[��D����Z\dJ�ZdL�eY�[��D����Z]hdM�Z^dN�Z_dO�dJ�ZeWeYe\e]g���[��D��Z`hdP�ZadQhZbeaebzZce`e^zZdedeczZehdR�ZfdS�dT�dU�dV�dW�ZgehehehehdddddXdYd
dddZ�
Zid[�Zjd\�Zkd]�Zld^�Zmejekelemd_�Znd`�ZoGda�dbe=��ZpGdc�ddepe>��ZqGde�dfep��ZrGdg�dhepeG��ZsGdi�dje=��Ztee
��Zuejvee
jwd����ZxGdk�dle=��ZyGdm�dneyereG��ZzGdo�dpe.��Z{e{��Z|dq�Z}Gdr�dse~��Zed�t��Z�		d�dd=�du�Z�dv�Z�Gdw�dxe.��Z�e�e���e�e|j���fZ�da�da�dy�Z�d�dz�Z�Gd{�d|eG��Z�e1j�Z�Gd}�d~e=��Z�Gd�d�e�epeG��Z�d��Z�Gd��d���Z�dS)�)�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
ThreadingMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�seal�N)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partial)�RLock)�IS_PYPY�)�iscoroutinefunctionc��eZdZdZdS)�InvalidSpecErrorz8Indicates that an invalid value was used as a mock spec.N��__name__�
__module__�__qualname__�__doc__���Z/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/mock/mock.pyrr-s������B�B�B�Br%rc�<�h|]}|�d���|��S��_��
startswith��.0�names  r&�	<setcomp>r/1s)��H�H�H�d�4�?�?�3�3G�3G�H�T�H�H�Hr%Tc���t|��rt|t��sdSt|d��rt	|d��}t|��pt
j|��S)NF�__func__)�_is_instance_mock�
isinstancer
�hasattr�getattrr�inspect�isawaitable��objs r&�
_is_async_objr:9sg�������j��i�&@�&@���u��s�J���'��c�:�&�&���s�#�#�?�w�':�3�'?�'?�?r%c�F�t|dd��rt|��SdS)N�__code__F)r5r)�funcs r&�_is_async_funcr>As)���t�Z��&�&��"�4�(�(�(��ur%c�F�tt|��t��S�N)�
issubclass�typer
r8s r&r2r2Hs���d�3�i�i��1�1�1r%c��t|t��p)t|t��ot|t��Sr@)r3�
BaseExceptionrBrAr8s r&�
_is_exceptionrENs6���3�
�&�&�	A��3����@�*�S�-�"@�"@�r%c�^�t|t��rt|d��r|jS|S�N�mock)r3�
FunctionTypesr4rHr8s r&�
_extract_mockrJUs3���#�}�%�%��'�#�v�*>�*>���x���
r%c��t|t��r|s
|j}d}njt|ttf��rt|t��rd}|j}n/t|t��s	|j}n#t$rYdSwxYw|rt|d��}n|}	|tj|��fS#t$rYdSwxYw)z�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    TN)
r3rB�__init__�classmethod�staticmethodr1rI�__call__�AttributeErrorrr6�	signature�
ValueError)r=�as_instance�eat_self�sig_funcs    r&�_get_signature_objectrV^s����$�����k���}�����	�D�;��5�	6�	6���d�K�(�(�	��H��}���
��m�
,�
,��	��=�D�D���	�	�	��4�4�	�������4��&�&�������W�&�x�0�0�0�0�������t�t����s$�3A;�;
B	�B	�"B8�8
C�CFc���t|||�����dS�\}��fd�}t||��|t|��_�t|��_dS)Nc�"���j|i|��dSr@��bind)�
_mock_self�args�kwargs�sigs   �r&�checksigz"_check_signature.<locals>.checksig�� ������$�!�&�!�!�!�!�!r%)rV�_copy_func_detailsrB�_mock_check_sig�
__signature__)r=rH�	skipfirst�instancer_r^s     @r&�_check_signaturerf�sr���
��h�	�
:�
:�C�
�{����I�D�#�"�"�"�"�"��t�X�&�&�&�!)�D��J�J��"�D��J�J���r%c	�p�dD]2}	t||t||�����##t$rY�/wxYwdS)N)r r#�__text_signature__r!�__defaults__�__kwdefaults__)�setattrr5rP)r=�funcopy�	attributes   r&rara�sa�����	�	��G�Y���i�(@�(@�A�A�A�A���	�	�	��D�	����
�s�&�
3�3c���t|t��rdSt|tttf��rt|j��St|dd���dSdS)NTrOF)r3rBrNrMr�	_callabler1r5r8s r&roro�s^���#�t�����t��#��k�:�>�?�?�'����&�&�&��s�J��%�%�1��t��5r%c�<�t|��ttfvSr@)rB�list�tupler8s r&�_is_listrs�s����9�9��u�
�%�%r%c��t|t��st|dd��duS|f|jzD]}|j�d���dS� dS)ztGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.rONTF)r3rBr5�__mro__�__dict__�get)r9�bases  r&�_instance_callablery�sn���c�4� � �:��s�J��-�-�T�9�9�����$�����=���Z�(�(�4��4�4�5��5r%c�0��t|t��}t|||��}|�|S|\}��fd�}t||��|j}|���sd}||d�}d|z}	t
|	|��||}
t|
|���|
S)Nc�"���j|i|��dSr@rY�r\r]r^s  �r&r_z _set_signature.<locals>.checksig�r`r%rl��
_checksig_rHzYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r3rBrVrar �isidentifier�exec�_setup_func)rH�originalrerd�resultr=r_r.�context�srcrlr^s           @r&�_set_signaturer��s����
�8�T�*�*�I�
"�8�X�y�
A�
A�F�
�~����I�D�#�"�"�"�"�"��t�X�&�&�&���D���������%�t�4�4�G�$�&*�+�C�	�#�w�����d�m�G����s�#�#�#��Nr%c���t|t��}t|||��\}��fd�}t||��|j}||d�}d|z}	t|	|��||}
t
|
|���t|
��|
S)Nc�"���j|i|��dSr@rYr|s  �r&r_z&_set_async_signature.<locals>.checksig�r`r%r}zeasync def %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return await mock(*args, **kwargs))r3rBrVrar r�r��_setup_async_mock)rHr�re�
is_async_mockrdr=r_r.r�r�rlr^s           @r&�_set_async_signaturer��s����
�8�T�*�*�I�%�h��)�D�D�I�D�#�"�"�"�"�"��t�X�&�&�&���D�%�t�4�4�G�*�,0�1�C�	�#�w�����d�m�G����s�#�#�#��g�����Nr%c�������_�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}	��fd�}
d	�_d
�_d�_t	���_t	���_t	���_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Nc����j|i|��Sr@)�assert_called_with�r\r]rHs  �r&r�z'_setup_func.<locals>.assert_called_with�����&�t�&��7��7�7�7r%c����j|i|��Sr@)�
assert_calledr�s  �r&r�z"_setup_func.<locals>.assert_called�s���!�t�!�4�2�6�2�2�2r%c����j|i|��Sr@)�assert_not_calledr�s  �r&r�z&_setup_func.<locals>.assert_not_called�s���%�t�%�t�6�v�6�6�6r%c����j|i|��Sr@)�assert_called_oncer�s  �r&r�z'_setup_func.<locals>.assert_called_once�r�r%c����j|i|��Sr@)�assert_called_once_withr�s  �r&r�z,_setup_func.<locals>.assert_called_once_with�s���+�t�+�T�<�V�<�<�<r%c����j|i|��Sr@)�assert_has_callsr�s  �r&r�z%_setup_func.<locals>.assert_has_calls�s���$�t�$�d�5�f�5�5�5r%c����j|i|��Sr@)�assert_any_callr�s  �r&r�z$_setup_func.<locals>.assert_any_call�s���#�t�#�T�4�V�4�4�4r%c����t���_t���_�����j}t|��r|�ur|���dSdSdSr@)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer2)�retrlrHs ��r&r�z_setup_func.<locals>.reset_mock�so���(�{�{���&�[�[����������"���S�!�!�	�#��+�+��N�N������	�	�+�+r%Fr)rH�called�
call_count�	call_argsr��call_args_listr�r�r��side_effect�_mock_childrenr�r�r�r�r�r�r�r�rc�_mock_delegate)rlrHr^r�r�r�r�r�r�r�r�s``         r&r�r��s������G�L�8�8�8�8�8�3�3�3�3�3�7�7�7�7�7�8�8�8�8�8�=�=�=�=�=�6�6�6�6�6�5�5�5�5�5��������G�N��G���G��&�[�[�G��$�;�;�G��"���G���,�G���*�G��!�0�G��!3�G��&=�G�#�/�G��-�G��#�G��)�G�� 1�G��!3�G���G��!�D���r%c	����tjj�_d�_d�_t���_�fd�}dD]!}t�|t||�����"dS)Nrc�:��t�j|��|i|��Sr@)r5rH)�attrr\r]rHs   �r&�wrapperz"_setup_async_mock.<locals>.wrapper$s$���'�w�t�y�$�'�'��8��8�8�8r%)�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_argsr��await_args_listrkr)rHr�rms`  r&r�r�s���� �+�9�D���D���D�O�$�;�;�D��
9�9�9�9�9�,�>�>�	�	��i���)�!<�!<�=�=�=�=�>�>r%c�$�d|dd�z|kS)N�__%s__����r$�r.s r&�	_is_magicr�6s���d�1�R�4�j� �D�(�(r%c�$�eZdZdZd�Zd�Zd�ZdS)�_SentinelObjectz!A unique, named, sentinel object.c��||_dSr@r���selfr.s  r&rLz_SentinelObject.__init__<s
����	�	�	r%c��d|jzS�Nzsentinel.%sr��r�s r&�__repr__z_SentinelObject.__repr__?����t�y�(�(r%c��d|jzSr�r�r�s r&�
__reduce__z_SentinelObject.__reduce__Br�r%N)r r!r"r#rLr�r�r$r%r&r�r�:sG������'�'����)�)�)�)�)�)�)�)r%r�c�$�eZdZdZd�Zd�Zd�ZdS)�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.c��i|_dSr@)�
_sentinelsr�s r&rLz_Sentinel.__init__Hs
������r%c�l�|dkrt�|j�|t|����S)N�	__bases__)rPr��
setdefaultr�r�s  r&�__getattr__z_Sentinel.__getattr__Ks3���;��� � ���)�)�$���0E�0E�F�F�Fr%c��dS)Nrr$r�s r&r�z_Sentinel.__reduce__Qs���zr%N)r r!r"r#rLr�r�r$r%r&r�r�FsJ������K�K����G�G�G�����r%r�>�
_mock_namer��_mock_parentr��_mock_new_name�_mock_new_parent�_mock_side_effect�_mock_return_valuec�x�t�|��d|z}||fd�}||fd�}t||��S)N�_mock_c�T�|j}|�t||��St||��Sr@)r�r5)r�r.�	_the_namer^s    r&�_getz"_delegating_property.<locals>._getfs/���!���;��4��+�+�+��s�D�!�!�!r%c�R�|j}|�||j|<dSt|||��dSr@)r�rvrk)r��valuer.r�r^s     r&�_setz"_delegating_property.<locals>._setks9���!���;�',�D�M�)�$�$�$��C��u�%�%�%�%�%r%)�_allowed_names�add�property)r.r�r�r�s    r&�_delegating_propertyr�cse�����t�����4��I��	�"�"�"�"�
 $�y�&�&�&�&��D�$���r%c��eZdZd�Zd�ZdS)r�c��t|t��st�||��St|��}t|��}||krdSt	d||z
dz��D]}||||z�}||krdS�dS)NFrrT)r3rq�__contains__�len�range)r�r��	len_value�len_self�i�sub_lists      r&r�z_CallList.__contains__xs����%��&�&�	2��$�$�T�5�1�1�1���J�J�	��t�9�9���x����5��q�(�Y�.��2�3�3�	�	�A��A�a�	�k�M�*�H��5� � ��t�t�!��ur%c�D�tjt|����Sr@)�pprint�pformatrqr�s r&r�z_CallList.__repr__�s���~�d�4�j�j�)�)�)r%N)r r!r"r�r�r$r%r&r�r�vs2���������*�*�*�*�*r%r�c���t|��}t|��sdS|js|js|j�|j�dS|}|�||urdS|j}|�|r||_||_|r||_||_dS)NFT)rJr2r�r�r�r�)�parentr�r.�new_name�_parents     r&�_check_and_set_parentr��s����%� � �E��U�#�#���u�	�	��U�1��	�	�	'�	�	�	+��u��G�
�
��e����5��*���
��(�!'���'���� �#�������4r%c��eZdZd�Zd�ZdS)�	_MockIterc�.�t|��|_dSr@)�iterr9)r�r9s  r&rLz_MockIter.__init__�s����9�9����r%c�*�t|j��Sr@)�nextr9r�s r&�__next__z_MockIter.__next__�s���D�H�~�~�r%N)r r!r"rLrr$r%r&r�r��s2�������������r%r�c��eZdZeZdZd�ZdS)�BaseNc��dSr@r$�r�r\r]s   r&rLz
Base.__init__�s���r%)r r!r"rr�r�rLr$r%r&rr�s/������ ����
�
�
�
�
r%rc��eZdZdZe��Z			d-d�Z			d-d�Zd�Zd.d�Z			d/d	�Z
d
�Zd�ZdZ
eeee
��Zed
���Zed��Zed��Zed��Zed��Zed��Zd�Zd�Zeee��Zd0ddd�d�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d1d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)d'�Z*d.d(�Z+d)�Z,d*�Z-d2d,�Z.dS)3r
z A non-callable version of `Mock`N�Fc��|f}
t|t��s|p|}|�t|��r	t|f}
t|j|
d|ji��}t
t|���|��}|S)Nr#)	rA�AsyncMockMixinr:rBr r#�_safe_superr
�__new__)�cls�specrr.�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_self�unsafer]�bases�spec_arg�newres                 r&r
zNonCallableMock.__new__�s�������#�~�.�.�	.��'�4�H��#�
�h�(?�(?�#�'��-���3�<���C�K�(@�A�A�����4�4�<�<�S�A�A���r%c��|�|}|j}
||
d<||
d<||
d<||
d<d|
d<|�|}d}|
�|du}
|�|||	|
��i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t��|
d<t��|
d<t��|
d<||
d<|r
|jdi|��t	t
|���||||||��dS)Nr�r�r�r�F�_mock_sealedTr��_mock_wrapsr��_mock_called�_mock_call_argsr�_mock_call_count�_mock_call_args_list�_mock_mock_callsr��_mock_unsafer$)rv�_mock_add_specr��configure_mockr	r
rL)r�rrr.r
r�rrrrrrr]rvs              r&rLzNonCallableMock.__init__�sV��
�� �K��=��#)��� �!%����%.��!�"�'2��#�$�#(��� ����D��H����d�*�I����D�(�,=�y�I�I�I�%'��!�"�"'����%)��!�"�#(��� �&*��"�#�'(��#�$�+4�;�;��'�(�'0�{�{��#�$�#,�;�;��� �#)��� ��	*��D��)�)�&�)�)�)��O�T�*�*�3�3��%��x���	
�	
�	
�	
�	
r%c�~�t|��}d|_d|_d|_d|_t|||��dS)z�
        Attach a mock as an attribute of this one, replacing its name and
        parent. Calls to the attached mock will be recorded in the
        `method_calls` and `mock_calls` attributes of this one.Nr)rJr�r�r�r�rk)r�rHrm�
inner_mocks    r&�attach_mockzNonCallableMock.attach_mock�sI��
#�4�(�(�
�"&�
��&*�
�#� "�
��$(�
�!���i��&�&�&�&�&r%c�2�|�||��dS�z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r �r�rr
s   r&�
mock_add_speczNonCallableMock.mock_add_spec
s ��	
���D�(�+�+�+�+�+r%c�,�t|��rtd|�d����d}d}g}|��t|��s�t|t��r|}nt	|��}t|||��}|o|d}t
|��}	|	D]d}
tj||
d��}|}	tj	|��}n#t$rYnwxYwt|��r|�|
���e|	}|j
}
||
d<||
d<||
d<||
d<||
d<dS)	Nz#Cannot spec a Mock object. [object=�]r�_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)r2rrsr3rBrV�dirr6�getattr_static�unwraprRr�appendrv)r�rr
rrr+r-r/�res�	spec_listr��static_attr�unwrapped_attrrvs              r&r zNonCallableMock._mock_add_specsi���T�"�"�	T�"�#R��#R�#R�#R�S�S�S���������H�T�N�N���$��%�%�
)�"���"�4�j�j��'��(9�9�F�F�C�!�n�c�!�f�O��D�	�	�I�!�
.�
.��%�4�T�4��F�F��!,���%,�^�N�%C�%C�N�N��!�����D�����&�~�6�6�.� �'�'��-�-�-���D��=��"-���� (����&5��"�#�$(���!�#/��� � � s�(B=�=
C
�	C
c��|j}|j�|jj}|tur|�|d���}||_|S)N�()�rr)r�r�r�r�_get_child_mock)r�r�s  r&�__get_return_valuez"NonCallableMock.__get_return_value=sU���%����*��%�2�C��'�>�>��&�&� �D�'���C�!$�D���
r%c�b�|j�||j_dS||_t||dd��dS)Nr9)r�r�r�r�)r�r�s  r&�__set_return_valuez"NonCallableMock.__set_return_valueJs>����*�/4�D��,�,�,�&+�D�#�!�$��t�T�:�:�:�:�:r%z1The value to be returned when the mock is called.c�<�|j�t|��S|jSr@)r+rBr�s r&�	__class__zNonCallableMock.__class__Vs ����#���:�:����r%r�r�r�r�r�c���|j}|�|jS|j}|�It|��s:t	|t
��s%t
|��st|��}||_|Sr@)r�r�r��callabler3r�rE)r��	delegated�sfs   r&�__get_side_effectz!NonCallableMock.__get_side_effectcsj���'�	����)�)�
�
"���N�8�B�<�<�N�"�2�y�1�1�
�:G��:K�:K�
��2���B�$&�I�!��	r%c�V�t|��}|j}|�	||_dS||_dSr@)�	_try_iterr�r�r�)r�r�rCs   r&�__set_side_effectz!NonCallableMock.__set_side_effectns9���%� � ���'�	���%*�D�"�"�"�$)�I�!�!�!r%�r�r�c�N�|�g}t|��|vrdS|�t|����d|_d|_d|_t��|_t��|_t��|_|rt|_
|rd|_|j�
��D]9}t|t��s	|t ur�!|�|||����:|j
}t%|��r||ur|�|��dSdSdS)z-Restore the mock object to its initial state.NFrrI)�idr3r�r�r�r�r�r�r�rr�r�r��valuesr3�
_SpecState�_deletedr�r2)r��visitedr�r��childr�s      r&r�zNonCallableMock.reset_mockys5���?��G�
�d�8�8�w����F����r�$�x�x� � � ����������#�+�+���'�k�k���%�K�K����	.�&-�D�#��	*�%)�D�"��(�/�/�1�1�	Z�	Z�E��%��,�,�
���0A�0A�����W�<�[��Y�Y�Y�Y��%���S�!�!�	$�c��o�o��N�N�7�#�#�#�#�#�	$�	$�o�or%c��t|���d����D]V\}}|�d��}|���}|}|D]}t	||��}�t|||���WdS)aZSet attributes on the mock through keyword arguments.

        Attributes plus return values and side effects can be set on child
        mocks using standard dot notation and unpacking a dictionary in the
        method call:

        >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
        >>> mock.configure_mock(**attrs)c�8�|d�d��S)Nr�.)�count)�entrys r&�<lambda>z0NonCallableMock.configure_mock.<locals>.<lambda>�s���q�����1D�1D�r%)�keyrSN)�sorted�items�split�popr5rk)r�r]�arg�valr\�finalr9rUs        r&r!zNonCallableMock.configure_mock�s����v�|�|�~�~�$E�#D�	F�F�F�
	%�
	%�H�C��
�9�9�S�>�>�D��H�H�J�J�E��C��
*�
*���c�5�)�)����C���$�$�$�$�
	%�
	%r%c
��|dvrt|���|j�%||jvs	|tvrtd|z���nt|��rt|���|jsC|jr	||jvr3|�d��s	|tvrt|�d|�d����tj5|j	�
|��}|turt|���|�Cd}|j�t|j|��}|�|||||���}||j	|<n�t|t ��rv	t#|j|j|j|j|j��}n>#t.$r1|jdp|}t/d|�d	|�d
|�d|j�d�	���wxYw||j	|<ddd��n#1swxYwY|S)
N>rr.zMock object has no attribute %r)�assert�assret�asert�aseert�assrtz6 is not a valid assertion. Use a spec for the mock if z is meant to be an attribute.)r�r.rrrr��Cannot autospec attr �
 from target �, as it has already been mocked out. [target=�, attr=r*)rPr.�_all_magicsr�rr+�_ATTRIB_DENY_LISTr
�_lockr�rwrNrr5r;r3rMr	rr
rer�r.rrv)r�r.r�r�target_names     r&r�zNonCallableMock.__getattr__�s����4�4�4� ��&�&�&�
�
�
+��4�-�-�-���1D�1D�$�%F��%M�N�N�N�2E�
�t�_�_�	'� ��&�&�&�� �	N�$�*<�	N��D�L^�@^�@^����O�P�P�
N�TX�\m�Tm�Tm�$��M�M�'+�M�M�M�N�N�N��
"�	4�	4��(�,�,�T�2�2�F���!�!�$�T�*�*�*������#�/�$�D�$4�d�;�;�E��-�-��d�%�4� $�.����.4��#�D�)�)��F�J�/�/�
4�
D�,���V�_�f�o��
�v�{���F�F��(�D�D�D�"&�-��"=�"E��K�*�C��C�C�&�C�C�#'�C�C�28�+�C�C�C�D�D�D�D����.4��#�D�)�;	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�>�
s+�4B
G�,E/�.G�/;F*�*
G�G�
Gc�n�|jg}|j}|}d}|dgkrd}|�7|}|�|j|z��d}|jdkrd}|j}|�7tt	|����}|jpd}t
|��dkr|ddvr|dz
}||d<d�|��S)NrSr9rrHr)r9z().r)r�r�r3rq�reversedr�r��join)r��
_name_listr��last�dot�_firsts      r&�_extract_mock_namez"NonCallableMock._extract_mock_name�s����)�*�
��'�������$�����C��!��D����g�4�s�:�;�;�;��C��%��-�-����.�G��!��(�:�.�.�/�/�
���*�F���z�?�?�Q����!�}�M�1�1��#�
���
�1�
��w�w�z�"�"�"r%c���|���}d}|dvrd|z}d}|j�d}|jrd}||jjz}dt	|��j�|�|�dt|���d�S)	Nr)rHzmock.z name=%rz spec=%rz spec_set=%r�<z id='z'>)rtr+r,r rBrK)r�r.�name_string�spec_strings    r&r�zNonCallableMock.__repr__�s����&�&�(�(�����(�(�(�$�t�+�K�����'�$�K��~�
-�,��%��(8�(A�A�K����J�J����K��K�K��t�H�H�H�H�	
�	
r%c�v�tst�|��S|jpg}t	t|����}t
|j��}d�|j�	��D��}d�|D��}d�|D��}tt||z|z|z����S)z8Filter the output of `dir(mock)` to only useful members.c�*�g|]\}}|tu�|��Sr$)rN)r-�m_name�m_values   r&�
<listcomp>z+NonCallableMock.__dir__.<locals>.<listcomp>s1��(�(�(�&�v�w��h�&�&�
�&�&�&r%c�<�g|]}|�d���|��Sr(r*�r-�es  r&r}z+NonCallableMock.__dir__.<locals>.<listcomp>s)��C�C�C�1����c�1B�1B�C�Q�C�C�Cr%c�Z�g|](}|�d��rt|���&|��)Sr()r+r�rs  r&r}z+NonCallableMock.__dir__.<locals>.<listcomp>sE��#�#�#�1����c�1B�1B�#��q�\�\�#�Q�#�#�#r%)r�object�__dir__r.r0rBrqrvr�rYrX�set)r��extras�	from_type�	from_dict�from_child_mockss     r&r�zNonCallableMock.__dir__
s����	(��>�>�$�'�'�'��#�)�r����T�
�
�O�O�	����'�'�	�(�(�*.�*=�*C�*C�*E�*E�(�(�(��D�C�	�C�C�C�	�#�#�	�#�#�#�	��c�&�9�,�y�8�;K�K�L�L�M�M�Mr%c�T���|tvrt��||��S�jr+�j�$|�jvr|�jvrt
d|z���|tvrd|z}t
|���|tvr��j�|�jvrt
d|z���t|��s5tt���|t||����|���fd�}nft�|d|��tt���||��|�j|<n+|dkr	|�_dSt�|||��r
|�j|<�jr;t#�|��s+�����d|��}t
d|�����t��||��S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.c�����g|�Ri|��Sr@r$)r\�kwr�r�s  ��r&rVz-NonCallableMock.__setattr__.<locals>.<lambda>1s!���H�H�T�,G�D�,G�,G�,G�B�,G�,G�r%r@rSzCannot set )r�r��__setattr__r,r.rvrP�_unsupported_magicsrir2rkrB�_get_methodr�r�r+rr4rt)r�r.r��msg�	mock_namer�s`    @r&r�zNonCallableMock.__setattr__s������>�!�!��%�%�d�D�%�8�8�8��n�	2��!3�!?���*�*�*���
�%�%� �!D�t�!K�L�L�L�
�(�
(�
(�B�T�I�C� ��%�%�%�
�[�
 �
 ��!�-�$�d�>P�2P�2P�$�%H�4�%O�P�P�P�$�U�+�+�	
2���T�
�
�D�+�d�E�*B�*B�C�C�C� ��G�G�G�G�G���&�d�E�4��>�>�>���T�
�
�D�%�0�0�0�,1��#�D�)�)�
�[�
 �
 �$�D���F�$�T�5�$��=�=�
2�,1��#�D�)���	<�W�T�4�%8�%8�	<��2�2�4�4�=�=�t�=�=�I� �!:�y�!:�!:�;�;�;��!�!�$��e�4�4�4r%c��|tvr>|t|��jvr(tt|��|��||jvrdS|j�|t��}||jvr)tt|���	|��n|turt|���|tur|j|=t|j|<dSr@)rirBrv�delattrr�rw�_missingr	r
�__delattr__rNrP)r�r.r9s   r&r�zNonCallableMock.__delattr__Fs����;���4�4��:�:�+>�#>�#>��D��J�J��%�%�%��4�=�(�(����!�%�%�d�H�5�5���4�=� � ����.�.�:�:�4�@�@�@�@�
�H�_�_� ��&�&�&��h����#�D�)�$,���D�!�!�!r%c�6�|jpd}t|||��SrG)r��_format_call_signature�r�r\r]r.s    r&�_format_mock_call_signaturez+NonCallableMock._format_mock_call_signatureXs ����(�&��%�d�D�&�9�9�9r%rc�d�d}|�||��}|j}|j|�}||||fzS)Nz.expected %s not found.
Expected: %s
Actual: %s)r�r�)r�r\r]�action�message�expected_stringr��
actual_strings        r&�_format_mock_failure_messagez,NonCallableMock._format_mock_failure_message]sD��D���:�:�4��H�H���N�	�8��8�)�D�
��&�/�=�A�A�Ar%c��|s|jSd}|�dd���d��}|j}|D]M}|�|��}|�t|t��rnt|��}|j}|j}�N|S)aH
        * If call objects are asserted against a method/function like obj.meth1
        then there could be no name for the call object to lookup. Hence just
        return the spec_signature of the method/function being asserted against.
        * If the name is not empty then remove () and split by '.' to get
        list of names to iterate through the children until a potential
        match is found. A child mock is created only during attribute access
        so if we get a _SpecState then no attributes of the spec were accessed
        and can be safely exited.
        Nr9rrS)r-�replacerZr�rwr3rMrJ)r�r.r^�names�childrenrPs      r&�_get_call_signature_from_namez-NonCallableMock._get_call_signature_from_namees����	(��'�'������T�2�&�&�,�,�S�1�1���&���
	,�
	,�D��L�L��&�&�E��}�
�5�*� =� =�}���
&�e�,�,�� �/���+����
r%c��t|t��r/t|��dkr|�|d��}n|j}|�vt|��dkrd}|\}}n|\}}}	|j|i|��}t
||j|j��S#t$r}|�
d��cYd}~Sd}~wwxYw|S)a
        Given a call (or simply an (args, kwargs) tuple), return a
        comparison key suitable for matching with other calls.
        This is a best effort method which relies on the spec's signature,
        if available, or falls back on the arguments themselves.
        r�rNr)r3rrr�r�r-rZrr\r]�	TypeError�with_traceback)r��_callr^r.r\r]�
bound_callr�s        r&�
_call_matcherzNonCallableMock._call_matcher�s����e�U�#�#�	'��E�
�
�Q����4�4�U�1�X�>�>�C�C��&�C��?��5�z�z�Q�����$���f�f�%*�"��d�F�
.�%�S�X�t�6�v�6�6�
��D�*�/�:�3D�E�E�E���
.�
.�
.��'�'��-�-�-�-�-�-�-�-�����
.�����Ls�0'B�
C�"B<�6C�<Cc��|}|jdkr8d|jpd�d|j�d|�����}t|���dS)z/assert that the mock was never called.
        r�
Expected 'rHz"' to not have been called. Called � times.N�r�r��_calls_repr�AssertionError�r[r�r�s   r&r�z!NonCallableMock.assert_not_called�sc�����?�a�����o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%� �r%c�V�|}|jdkrd|jpdz}t|���dS)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.rHN)r�r�r�r�s   r&r�zNonCallableMock.assert_called�s@�����?�a���7��?�,�f�.�C� ��%�%�%� �r%c��|}|jdks8d|jpd�d|j�d|�����}t|���dS)z3assert that the mock was called only once.
        rr�rHz#' to have been called once. Called r�Nr�r�s   r&r�z"NonCallableMock.assert_called_once�sc������!�#�#�#��o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%�$�#r%c�x����|��j�/������}d}d|�d|��}t|������fd�}��t	��fd�����}���j��}||kr1t|t��r|nd}t|����|�dS)z�assert that the last call was made with the specified arguments.

        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock.Nznot called.z#expected call not found.
Expected: �	
Actual: c�4��������}|Sr@�r��r�r\r]r�s ���r&�_error_messagez:NonCallableMock.assert_called_with.<locals>._error_message�s����3�3�D�&�A�A�C��Jr%T��two)r�r�r�r��_Callr3�	Exception)	r[r\r]�expected�actual�
error_messager��causer�s	 ``     @r&r�z"NonCallableMock.assert_called_with�s������
���>�!��7�7��f�E�E�H�"�F�F��x�x���)�M� ��/�/�/�	�	�	�	�	�	�	��%�%�e�T�6�N��&E�&E�&E�F�F���#�#�D�N�3�3���X��� *�8�Y� ?� ?�I�H�H�T�E� ���!1�!1�2�2��=��r%c��|}|jdks8d|jpd�d|j�d|�����}t|���|j|i|��S)ziassert that the mock was called exactly once and that that call was
        with the specified arguments.rr�rHz' to be called once. Called r�)r�r�r�r�r��r[r\r]r�r�s     r&r�z'NonCallableMock.assert_called_once_with�ss������!�#�#�#��o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%�&�t�&��7��7�7�7r%c����fd�|D��}td�|D��d��}t�fd��jD����}|su||vro|�d}nd�d�|D����}t	|�dt|�����d	�
���d������|�dSt|��}g}|D]=}	|�|���#t$r|�
|��Y�:wxYw|r-t	�jpd�d
t|���d|�d���|�dS)a�assert the mock has been called with the specified calls.
        The `mock_calls` list is checked for the calls.

        If `any_order` is False (the default) then the calls must be
        sequential. There can be extra calls before or after the
        specified calls.

        If `any_order` is True then the calls can be in any order, but
        they must all appear in `mock_calls`.c�:��g|]}��|����Sr$�r��r-�cr�s  �r&r}z4NonCallableMock.assert_has_calls.<locals>.<listcomp>��'���9�9�9�a�D�&�&�q�)�)�9�9�9r%c3�DK�|]}t|t���|V��dSr@�r3r�rs  r&�	<genexpr>z3NonCallableMock.assert_has_calls.<locals>.<genexpr>�s1����F�F�A�Z��9�-E�-E�F�a�F�F�F�F�F�Fr%Nc3�B�K�|]}��|��V��dSr@r�r�s  �r&r�z3NonCallableMock.assert_has_calls.<locals>.<genexpr>�s1�����M�M��d�0�0��3�3�M�M�M�M�M�Mr%zCalls not found.z+Error processing expected calls.
Errors: {}c�@�g|]}t|t��r|nd��Sr@r�rs  r&r}z4NonCallableMock.assert_has_calls.<locals>.<listcomp>��;��$7�$7�$7�()�*4�A�y�)A�)A�$K�A�A�t�$7�$7�$7r%�
Expected: �Actual)�prefixrSrHz does not contain all of z in its call list, found z instead)
r�r�r��formatr�r��rstriprq�removerRr3r�rr)	r��calls�	any_orderr�r��	all_calls�problem�	not_found�kalls	`        r&r�z NonCallableMock.assert_has_calls�s����:�9�9�9�5�9�9�9���F�F��F�F�F��M�M���M�M�M�M�T�_�M�M�M�M�M�	��	��y�(�(��=�0�G�G� ,�-3�V�$7�$7�-5�$7�$7�$7�.8�.8��%��G�G�!*�5�!1�!1�G��'�'�x�'�8�8�?�?��D�D�G�G����	�

�F���O�O�	��	��	'�	'�D�
'�� � ��&�&�&�&���
'�
'�
'�� � ��&�&�&�&�&�
'�����	� �&*�o�&?��&?�&?�&+�I�&6�&6�&6�&6�	�	�	�C����	
�	�	s�C-�-D�Dc�$����t||fd�����}t|t��r|nd}�fd��jD��}|s|t|��vr)��||��}td|z��|�dS)z�assert the mock has been called with the specified arguments.

        The assert passes if the mock has *ever* been called, unlike
        `assert_called_with` and `assert_called_once_with` that only pass if
        the call is the most recent one.Tr�Nc�:��g|]}��|����Sr$r�r�s  �r&r}z3NonCallableMock.assert_any_call.<locals>.<listcomp>s'���E�E�E�A�$�$�$�Q�'�'�E�E�Er%z%s call not found)r�r�r3r�r��_AnyComparerr�r�)r�r\r]r�r�r�r�s`      r&r�zNonCallableMock.assert_any_calls�����%�%�e�T�6�N��&E�&E�&E�F�F��&�x��;�;�E�����E�E�E�E��1D�E�E�E���	�H�L��$8�$8�8�8�"�>�>�t�V�L�L�O� �#�o�5����
�9�8r%c��|jr7d|vrd|d��nd}|���|z}t|���|�d��}||jdvrtdi|��St
|��}t|t��r|tvrt
}n�t|t��r)|tvs|jr||jvrt}ndt
}n\t|t��s:t|t��rt}n*t|t��rt }n
|jd}|di|��S)aPCreate the child mocks for attributes and return value.
        By default child mocks will be the same type as the parent.
        Subclasses of Mock may want to override this to customize the way
        child mocks are made.

        For non-callable mocks the callable variant will be used (rather than
        any custom subclass).r.rSr9rr/rr$)rrtrPrwrvr
rBrAr�_async_method_magicsr�_all_sync_magicsr.�
CallableMixinrr
rru)r�r�rmr�r�_type�klasss       r&r;zNonCallableMock._get_child_mock!s[����	,�,2�b�L�L�(�B�v�J�(�(�(�d�I��/�/�1�1�I�=�I� ��+�+�+��F�F�;�'�'�	���
�n�5�5�5��?�?�r�?�?�"��T�
�
���e�Y�'�'�	%�I�9M�,M�,M��E�E�
��~�
.�
.�
	%��-�-�-��&�.�+4��8J�+J�+J�!���!����E�=�1�1�	%��%�!5�6�6�
�!����E�?�3�3�
�����M�!�$�E��u�{�{�r�{�{�r%�Callsc�J�|jsdSd|�dt|j���d�S)z�Renders self.mock_calls as a string.

        Example: "
Calls: [call(1), call(2)]."

        If self.mock_calls is empty, an empty string is returned. The
        output will be truncated if very long.
        r�
z: rS)r�r)r�r�s  r&r�zNonCallableMock._calls_reprGs6����	��2�;�F�;�;�i���8�8�;�;�;�;r%)NNNNNNrNFNF�F�FFr@)r)r�)/r r!r"r#rrkr
rLr$r(r �"_NonCallableMock__get_return_value�"_NonCallableMock__set_return_value�"_NonCallableMock__return_value_docr�r�r@r�r�r�r�r�r��!_NonCallableMock__get_side_effect�!_NonCallableMock__set_side_effectr�r�r!r�rtr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r;r�r$r%r&r
r
�s�������*�*�
�E�G�G�E�=A�EI�<A�����(>B�EI�<A�*
�*
�*
�*
�Z'�'�'�,�,�,�,�@E�!&�%0�%0�%0�%0�N
�
�
�;�;�;�M���8�.�0B�.�0�0�L�� � ��X� �
"�
!�(�
+�
+�F�%�%�l�3�3�J�$�$�[�1�1�I�)�)�*:�;�;�N�%�%�l�3�3�J�	�	�	�*�*�*��(�,�.?�@�@�K�$�u�%�$�$�$�$�$�<%�%�%�,-�-�-�`#�#�#�6
�
�
�*N�N�N�$$5�$5�$5�N-�-�-�$:�:�:�
B�B�B�B����B���6	&�	&�	&�&�&�&�	&�	&�	&�>�>�>�.
8�
8�
8�*�*�*�*�Z
�
�
� #�#�#�L
<�
<�
<�
<�
<�
<r%r
c�0�|t|��d�Sr@�r�)r.r�s  r&�removeprefixr�Xs���C��K�K�L�L�!�!r%c�X�h|]'}|�d���t|d����(S)�assert_)r+r�r,s  r&r/r/\sD���������y�!�!����y�!�!���r%c��eZdZdZd�ZdS)r�z�A list which checks if it contains a call which may have an
    argument of ANY, flipping the components of item and self from
    their traditional locations so that ANY is guaranteed to be on
    the left.c��|D]N}t|��t|��ksJ�td�t||��D����rdS�OdS)Nc� �g|]\}}||k��Sr$r$)r-r�r�s   r&r}z-_AnyComparer.__contains__.<locals>.<listcomp>ks1�����$�H�f��F�"���r%TF)r��all�zip)r��itemr�s   r&r�z_AnyComparer.__contains__hs{���	�	�E��t�9�9��E�
�
�*�*�*�*����(+�D�%�(8�(8������
��t�t�	
�
�ur%N)r r!r"r#r�r$r%r&r�r�cs-������������r%r�c��|�|St|��r|St|��r|S	t|��S#t$r|cYSwxYwr@)rEror�r�r8s r&rGrGssk��
�{��
��S�����
���~�~���
���C�y�y��������
�
�
����s�7�A�Ac
�H�eZdZddedddddddf
d�Zd�Zd�Zd�Zd�Zd�Z	dS)	r�Nrc
�x�||jd<tt|��j|||||||	|
fi|��||_dS)Nr�)rvr	r�rLr�)r�rr�r�rr.r
r�rrrr]s            r&rLzCallableMixin.__init__�sa��/;��
�*�+�1��M�4�(�(�1��%��x����K�	
�	
�39�	
�	
�	
�
'����r%c��dSr@r$rs   r&rbzCallableMixin._mock_check_sig�s���r%c�P�|j|i|��|j|i|��|j|i|��Sr@)rb�_increment_mock_call�
_mock_call�r[r\r]s   r&rOzCallableMixin.__call__�sL��	#�
�"�D�3�F�3�3�3�'�
�'��8��8�8�8�$�z�$�d�5�f�5�5�5r%c��|j|i|��Sr@)�_execute_mock_callrs   r&r�zCallableMixin._mock_call�s��,�z�,�d�=�f�=�=�=r%c��|}d|_|xjdz
c_t||fd���}||_|j�|��|jdu}|j}|j}|dk}|j	�td||f����|j
}	|	��|rB|	j�t|||f����|	jdu}|r
|	jdz|z}t|||f��}
|	j	�|
��|	jr|rd}nd}|	jdk}|	j|z|z}|	j
}	|	��dSdS)NTrr�r9rrS)r�r�r�r�r�r3r�r�r�r�r�r�)r[r\r]r�r��do_method_calls�method_call_name�mock_call_name�	is_a_callr�this_mock_callrrs            r&r�z"CallableMixin._increment_mock_call�s�����������1����
�t�V�n�$�/�/�/�������"�"�5�)�)�)��+�4�7���?���,��"�d�*�	�����u�b�$��%7�8�8�9�9�9��+���%��
W��(�/�/��7G��v�6V�0W�0W�X�X�X�"-�":�$�"F��"�W�'2�'=��'C�FV�'V�$�#�N�D�&�#A�B�B�N��"�)�)�.�9�9�9��)�
S����C�C��C�'�6�$�>�	�!,�!;�c�!A�N�!R��&�6�K�-�%�%�%�%�%r%c� �|}|j}|�Tt|��r|�t|��s!t|��}t|��r|�n||i|��}|tur|S|jtur|jS|j�
|j|i|��S|jSr@)r�rEror�rr�r�r)r[r\r]r��effectr�s      r&rz CallableMixin._execute_mock_call�s������!�����V�$�$�
1����v�&�&�
1��f���� ��(�(�!� �L�!� ���0��0�0���W�$�$��
��"�'�1�1��$�$���'�#�4�#�T�4�V�4�4�4�� � r%)
r r!r"rrLrbrOr�r�rr$r%r&r�r��s������� �d���$��d�!�R�T�	'�	'�	'�	'�
�
�
�
6�6�6�>�>�>�-7�-7�-7�^!�!�!�!�!r%r�c��eZdZdZdS)ra�
    Create a new `Mock` object. `Mock` takes several optional arguments
    that specify the behaviour of the Mock object:

    * `spec`: This can be either a list of strings or an existing object (a
      class or instance) that acts as the specification for the mock object. If
      you pass in an object then a list of strings is formed by calling dir on
      the object (excluding unsupported magic attributes and methods). Accessing
      any attribute not in this list will raise an `AttributeError`.

      If `spec` is an object (rather than a list of strings) then
      `mock.__class__` returns the class of the spec object. This allows mocks
      to pass `isinstance` tests.

    * `spec_set`: A stricter variant of `spec`. If used, attempting to *set*
      or get an attribute on the mock that isn't on the object passed as
      `spec_set` will raise an `AttributeError`.

    * `side_effect`: A function to be called whenever the Mock is called. See
      the `side_effect` attribute. Useful for raising exceptions or
      dynamically changing return values. The function is called with the same
      arguments as the mock, and unless it returns `DEFAULT`, the return
      value of this function is used as the return value.

      If `side_effect` is an iterable then each call to the mock will return
      the next value from the iterable. If any of the members of the iterable
      are exceptions they will be raised instead of returned.

    * `return_value`: The value returned when the mock is called. By default
      this is a new Mock (created on first access). See the
      `return_value` attribute.

    * `unsafe`: By default, accessing any attribute whose name starts with
      *assert*, *assret*, *asert*, *aseert*, or *assrt* raises an AttributeError.
      Additionally, an AttributeError is raised when accessing
      attributes that match the name of an assertion method without the prefix
      `assert_`, e.g. accessing `called_once` instead of `assert_called_once`.
      Passing `unsafe=True` will allow access to these attributes.

    * `wraps`: Item for the mock object to wrap. If `wraps` is not None then
      calling the Mock will pass the call through to the wrapped object
      (returning the real result). Attribute access on the mock will return a
      Mock object that wraps the corresponding attribute of the wrapped object
      (so attempting to access an attribute that doesn't exist will raise an
      `AttributeError`).

      If the mock has an explicit `return_value` set then calls are not passed
      to the wrapped object and the `return_value` is returned instead.

    * `name`: If the mock has a name then it will be used in the repr of the
      mock. This can be useful for debugging. The name is propagated to child
      mocks.

    Mocks can also be called with arbitrary keyword arguments. These will be
    used to set attributes on the mock after it is created.
    Nrr$r%r&rr�s������7�7�7�7r%rc��	t||��S#t$r"t|��t||��cYSwxYwr@)r5rP�
__import__)�thing�comp�import_paths   r&�_dot_lookupr'sV��$��u�d�#�#�#���$�$�$��;�����u�d�#�#�#�#�#�$���s��)>�>c��|�d��}|�d��}t|��}|D]}|d|zz
}t|||��}�|S)NrSrz.%s)rZr[r
r)�target�
componentsrrrs     r&�	_importerr/sf�����c�"�"�J��.�.��#�#�K��{�#�#�E��6�6���u�t�|�#���E�4��5�5����Lr%c�@�d}|D]}||vrt|�d�����dS)N)�	autospect�	auto_spec�set_specz5 might be a typo; use unsafe=True if this is intended)�RuntimeError)�kwargs_to_check�typos�typos   r&�_check_spec_arg_typosr<sN��2�E������?�"�"���P�P�P���
�#��r%c�~�eZdZdZgZdd�d�Zd�Zd�Zd�Ze	j
d���Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�ZdS)�_patchNF�rc
��|�)|turtd���|�td���|
st|	��t|��rt	d|�d|�d����t|��rt	d|�d|�d����||_||_||_||_||_	||_
d|_||_||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherzCannot spec attr z0 as the spec has already been mocked out. [spec=r*z? as the spec_set target has already been mocked out. [spec_set=F)rrRrr2r�getterrmr�new_callabler�create�	has_localr
�autospecr]�additional_patchers)r�r#rmrrr%r
r'r$r]rs           r&rLz_patch.__init__JsV���#��'�!�!� �B�����#� �G�����	*�!�&�)�)�)��T�"�"�	A�"�@�I�@�@�6:�@�@�@�A�A�
A��X�&�&�	P�"�O�I�O�O�AI�O�O�O�P�P�
P����"������(�����	������� ��
� ��
����#%�� � � r%c���t|j|j|j|j|j|j|j|j|j	�	�	}|j
|_
d�|jD��|_|S)Nc�6�g|]}|�����Sr$)�copy)r-�ps  r&r}z_patch.copy.<locals>.<listcomp>vs-��'
�'
�'
��A�F�F�H�H�'
�'
�'
r%)r r#rmrrr%r
r'r$r]�attribute_namer()r��patchers  r&r+z_patch.copyosq����K�����4�9��K����M�4�,�d�k�
�
��
"&�!4���'
�'
�"�6�'
�'
�'
��#��r%c���t|t��r|�|��Stj|��r|�|��S|�|��Sr@�r3rB�decorate_classr6r�decorate_async_callable�decorate_callable)r�r=s  r&rOz_patch.__call__|sc���d�D�!�!�	-��&�&�t�,�,�,��&�t�,�,�	6��/�/��5�5�5��%�%�d�+�+�+r%c��t|��D]q}|�tj��s�"t	||��}t|d��s�C|���}t||||�����r|S�NrO)r0r+r�TEST_PREFIXr5r4r+rk)r�r�r��
attr_valuer.s     r&r1z_patch.decorate_class�s�����J�J�		6�		6�D��?�?�5�#4�5�5�
�� ���-�-�J��:�z�2�2�
���i�i�k�k�G��E�4����!4�!4�5�5�5�5��r%c#�TK�g}tj��5}|jD]W}|�|��}|j�|�|���4|jtur|�|���X|t|��z
}||fV�ddd��dS#1swxYwYdSr@)
�
contextlib�	ExitStack�	patchings�
enter_contextr-�updaterrr3rr)r��patchedr\�keywargs�
extra_args�
exit_stack�patchingr\s        r&�decoration_helperz_patch.decoration_helper�s�����
�
�
!�
#�
#�		#�z�#�-�
+�
+�� �.�.�x�8�8���*�6��O�O�C�(�(�(�(��\�W�,�,��%�%�c�*�*�*���E�*�%�%�%�D���"�"�"�"�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#����		#�		#�		#�		#�		#�		#s�A8B�B!�$B!c�����t�d��r�j�����St������fd�����g�_�S)Nr;c�|�����||��5\}}�|i|��cddd��S#1swxYwYdSr@�rC�r\r?�newargs�newkeywargsr=r>r�s    ���r&r>z)_patch.decorate_callable.<locals>.patched�s�����'�'��(,�(0�2�2�
5�5K�g�{��t�W�4��4�4�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5�
5�
5s�1�5�5�r4r;r3r�r�r=r>s``@r&r3z_patch.decorate_callable�sv������4��%�%�	��N�!�!�$�'�'�'��K�	�t���	5�	5�	5�	5�	5�	5�
��	5�"�F����r%c�����t�d��r�j�����St������fd�����g�_�S)Nr;c���K����||��5\}}�|i|���d{V��cddd��S#1swxYwYdSr@rFrGs    ���r&r>z/_patch.decorate_async_callable.<locals>.patched�s�������'�'��(,�(0�2�2�
;�5K�g�{�!�T�7�:�k�:�:�:�:�:�:�:�:�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;�
;�
;s
�9�=�=rJrKs``@r&r2z_patch.decorate_async_callable�sv������4��%�%�	��N�!�!�$�'�'�'��K�	�t���	;�	;�	;�	;�	;�	;�
��	;�"�F����r%c�`�|���}|j}t}d}	|j|}d}n-#tt
f$rt
||t��}YnwxYw|tvrt|t��rd|_
|j
s|turt	|�d|�����||fS)NFTz does not have the attribute )r#rmrrvrP�KeyErrorr5�	_builtinsr3rr%)r�rr.r��locals     r&�get_originalz_patch.get_original�s����������~������	���t�,�H��E�E����)�	6�	6�	6��v�t�W�5�5�H�H�H�	6����
�9����F�J�!?�!?���D�K��{�	�x�7�2�2� �7=�v�v�t�t�D���
����s�
6�'A �A c��|j|j|j}}}|j|j}}|j}|���|_|durd}|durd}|durd}|�|�td���|�|�|dvrtd���|�	��\}}|tu�r�|���d}	|dur|}|dur|}d}n|�	|dur|}d}n|dur|}|�|�/|turtd���t|t��rd}	|�t|��rt}
nt}
i}|�|}
nN|�|�J|}|�|}t!|��rd|v}
nt#|��}
t|��rt}
n	|
rt$}
|�||d	<|�||d
<t|
t��r&t'|
t(��r|jr
|j|d<|�|��|
di|��}|	r_t/|��rP|}|�|}t!|��st1|��st$}
|�d��|
d|dd
�|��|_n�|��|turtd���|turtd���t7|��}|dur|}t/|j��r#t9d|j�d|j�d|�d����t/|��rAt;|jd|j��}t9d|j�d|�d|j�d|�d�	���t=|f||jd�|��}n|rtd���|}||_||_ tCj"��|_#	tI|j|j|��|j%�ci}|jtur
|||j%<|j&D]?}|j#�'|��}|jtur|�|���@|S|S#|j(tSj*���s�YdSxYw)zPerform the patch.FNzCan't specify spec and autospec)TNz6Can't provide explicit spec_set *and* spec or autospecTz!Can't use 'spec' with create=TruerOrr
r.r9r:zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=Truerez: as the patch target has already been mocked out. [target=rhr*r rfrg)r
�_namez.Can't pass kwargs to a mock we aren't creatingr$)+rrr
r'r]r$r#rr�rRrr3rBr:r
rrsrBrrAr
rmr=r2ryr[r��boolrr5r	�
temp_original�is_localr9r:�_exit_stackrkr-r(r<�__exit__�sys�exc_info)r�rrr
r'r]r$r�rQ�inherit�Klass�_kwargs�	this_spec�not_callablerl�new_attrr@rBr\s                   r&�	__enter__z_patch.__enter__�s���"�h��	�4�=�8�T���=�$�+�&���(���k�k�m�m����5�=�=��D��u����H��u����H���� 4��=�>�>�>�
�
��!5��L�(�(��T�U�U�U��+�+�-�-���%��'�>�>�h�.��G��t�|�|����t�#�#�'�H��D���!��t�#�#�#�H��D���T�!�!�#����8�#7��w�&�&�#�$G�H�H�H��h��-�-�#�"�G��|�
�h� 7� 7�|�!���!���G��'�$����!�X�%9� �	��'� (�I��I�&�&�;�#-�Y�#>�L�L�'/�	�':�':�#:�L� ��+�+�1�%�E�E�!�1�0�E���"&�����#�&.��
�#��5�$�'�'�
1��5�/�2�2�
1�7;�~�
1�"&�.�����N�N�6�"�"�"��%�"�"�'�"�"�C��
4�,�S�1�1�
4�!�	��'� (�I� ��+�+�1�&�y�1�1�1�0�E����F�#�#�#�#(�5�$4�S�D�$4�$4�+2�$4�$4�� ��
�
!��'�!�!��(�����7�"�"�� G�H�H�H��H�~�~�H��4���#�� ���-�-�
D�&�C�D�N�C�C�#�{�C�C�5=�C�C�C�D�D�D�!��*�*�
D�%�d�k�:�t�{�K�K��&�C�D�N�C�C�"�C�C�#�{�C�C�5=�C�C�C�D�D�D�
"�(�B�X�(,��B�B�:@�B�B�C�C�
�	N��L�M�M�M���%�����
�%�/�1�1���	��D�K����:�:�:��"�.��
��8�w�&�&�7:�J�t�2�3� $� 8�/�/�H��*�8�8��B�B�C��|�w�.�.�"�)�)�#�.�.�.��!�!��J��	� �4�=�#�,�.�.�1�
��
�
�
���s�BO�O�O<c�h�|jr/|jtur!t|j|j|j��ndt
|j|j��|jsCt|j|j��r	|jdvr t|j|j|j��|`|`|`|j	}|`	|j
|�S)zUndo the patch.)r#r!ri�__annotations__rj)rWrVrrkrrmr�r%r4rXrY)r�r[rAs   r&rYz_patch.__exit__ms����=�		I�T�/�w�>�>��D�K����1C�D�D�D�D��D�K���0�0�0��;�
I����T�^�(L�(L�
I���+=�=�=����T�^�T�5G�H�H�H����M��K��%�
���"�z�"�H�-�-r%c�b�|���}|j�|��|S�z-Activate a patch, returning any created mock.)rb�_active_patchesr3�r�r�s  r&�startz_patch.start�s-�����!�!����#�#�D�)�)�)��
r%c��	|j�|��n#t$rYdSwxYw|�ddd��S�zStop an active patch.N)rgr�rRrYr�s r&�stopz_patch.stop�s[��	�� �'�'��-�-�-�-���	�	�	��4�4�	�����}�}�T�4��.�.�.s��
+�+)r r!r"r-rgrLr+rOr1r9�contextmanagerrCr3r2rRrbrYrirlr$r%r&r r Es��������N��O�AF�"&�"&�"&�"&�"&�J
�
�
�,�,�,������#�#���#����"���"���0P�P�P�d.�.�.�*���/�/�/�/�/r%r c���	��dd��\�}n-#tttf$rtd������wxYw�fd�}||fS)NrSrz,Need a valid target to patch. You supplied: c�"��t���Sr@�r�rs�r&rVz_get_target.<locals>.<lambda>�s���Y�v�&�&�r%)�rsplitr�rRrP)rrmr#s`  r&�_get_targetrs�s����G�"�M�M�#�q�1�1���	�	���z�>�2�G�G�G��E�6�E�E�G�G�	G�G����'�
&�
&�
&�F��9��s	��*Ar!c���t���turt��d�����fd�}
t|
||||||||	|��
�
S)a
    patch the named member (`attribute`) on an object (`target`) with a mock
    object.

    `patch.object` can be used as a decorator, class decorator or a context
    manager. Arguments `new`, `spec`, `create`, `spec_set`,
    `autospec` and `new_callable` have the same meaning as for `patch`. Like
    `patch`, `patch.object` takes arbitrary keyword arguments for configuring
    the mock object it creates.

    When used as a class decorator `patch.object` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    z3 must be the actual object to be patched, not a strc����Sr@r$rqs�r&rVz_patch_object.<locals>.<lambda>�s���V�r%r!)rB�strr�r )rrmrrr%r
r'r$rr]r#s`          r&�
_patch_objectrw�sn���$�F�|�|�s�����L�L�L�
�
�	
��^�^�^�F���	�3��f��(�L�&�����r%c���t���tur�fd�}n�fd�}|std���t|�����}|d\}	}
t||	|
|||||i�	�	}|	|_|dd�D]=\}	}
t||	|
|||||i�	�	}|	|_|j�|���>|S)a�Perform multiple patches in a single call. It takes the object to be
    patched (either as an object or a string to fetch the object by importing)
    and keyword arguments for the patches::

        with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
            ...

    Use `DEFAULT` as the value if you want `patch.multiple` to create
    mocks for you. In this case the created mocks are passed into a decorated
    function by keyword, and a dictionary is returned when `patch.multiple` is
    used as a context manager.

    `patch.multiple` can be used as a decorator, class decorator or a context
    manager. The arguments `spec`, `spec_set`, `create`,
    `autospec` and `new_callable` have the same meaning as for `patch`. These
    arguments will be applied to *all* patches done by `patch.multiple`.

    When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    c�"��t���Sr@rprqs�r&rVz!_patch_multiple.<locals>.<lambda>�s����6�*�*�r%c����Sr@r$rqs�r&rVz!_patch_multiple.<locals>.<lambda>�s����r%z=Must supply at least one keyword argument with patch.multiplerrN)	rBrvrRrqrYr r-r(r3)
rrr%r
r'r$r]r#rYrmrr.�this_patchers
`            r&�_patch_multipler|�s���,�F�|�|�s���*�*�*�*���������
��K�
�
�	
�
������ � �E��1�X�N�I�s���	�3��f�h��,����G�'�G������)�9�9��	�3���I�s�D�&�(��l�B�
�
��'0��#��#�*�*�<�8�8�8�8��Nr%c�X�t|��\}	}
t|	|
||||||||��
�
S)a:
    `patch` acts as a function decorator, class decorator or a context
    manager. Inside the body of the function or with statement, the `target`
    is patched with a `new` object. When the function/with statement exits
    the patch is undone.

    If `new` is omitted, then the target is replaced with an
    `AsyncMock if the patched object is an async function or a
    `MagicMock` otherwise. If `patch` is used as a decorator and `new` is
    omitted, the created mock is passed in as an extra argument to the
    decorated function. If `patch` is used as a context manager the created
    mock is returned by the context manager.

    `target` should be a string in the form `'package.module.ClassName'`. The
    `target` is imported and the specified object replaced with the `new`
    object, so the `target` must be importable from the environment you are
    calling `patch` from. The target is imported when the decorated function
    is executed, not at decoration time.

    The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
    if patch is creating one for you.

    In addition you can pass `spec=True` or `spec_set=True`, which causes
    patch to pass in the object being mocked as the spec/spec_set object.

    `new_callable` allows you to specify a different class, or callable object,
    that will be called to create the `new` object. By default `AsyncMock` is
    used for async functions and `MagicMock` for the rest.

    A more powerful form of `spec` is `autospec`. If you set `autospec=True`
    then the mock will be created with a spec from the object being replaced.
    All attributes of the mock will also have the spec of the corresponding
    attribute of the object being replaced. Methods and functions being
    mocked will have their arguments checked and will raise a `TypeError` if
    they are called with the wrong signature. For mocks replacing a class,
    their return value (the 'instance') will have the same spec as the class.

    Instead of `autospec=True` you can pass `autospec=some_object` to use an
    arbitrary object as the spec instead of the one being replaced.

    By default `patch` will fail to replace attributes that don't exist. If
    you pass in `create=True`, and the attribute doesn't exist, patch will
    create the attribute for you when the patched function is called, and
    delete it again afterwards. This is useful for writing tests against
    attributes that your production code creates at runtime. It is off by
    default because it can be dangerous. With it switched on you can write
    passing tests against APIs that don't actually exist!

    Patch can be used as a `TestCase` class decorator. It works by
    decorating each test method in the class. This reduces the boilerplate
    code when your test methods share a common patchings set. `patch` finds
    tests by looking for method names that start with `patch.TEST_PREFIX`.
    By default this is `test`, which matches the way `unittest` finds tests.
    You can specify an alternative prefix by setting `patch.TEST_PREFIX`.

    Patch can be used as a context manager, with the with statement. Here the
    patching applies to the indented block after the with statement. If you
    use "as" then the patched object will be bound to the name after the
    "as"; very useful if `patch` is creating a mock object for you.

    Patch will raise a `RuntimeError` if passed some common misspellings of
    the arguments autospec and spec_set. Pass the argument `unsafe` with the
    value True to disable that check.

    `patch` takes arbitrary keyword arguments. These will be passed to
    `AsyncMock` if the patched object is asynchronous, to `MagicMock`
    otherwise or to `new_callable` if specified.

    `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
    available for alternate use-cases.
    r!)rsr )rrrr%r
r'r$rr]r#rms           r&rr�sD��V$�F�+�+��F�I���	�3��f��(�L�&�����r%c�V�eZdZdZdd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�ZdS)�_patch_dicta#
    Patch a dictionary, or dictionary like object, and restore the dictionary
    to its original state after the test.

    `in_dict` can be a dictionary or a mapping like container. If it is a
    mapping then it must at least support getting, setting and deleting items
    plus iterating over keys.

    `in_dict` can also be a string specifying the name of the dictionary, which
    will then be fetched by importing it.

    `values` can be a dictionary of values to set in the dictionary. `values`
    can also be an iterable of `(key, value)` pairs.

    If `clear` is True then the dictionary will be cleared before the new
    values are set.

    `patch.dict` can also be called with arbitrary keyword arguments to set
    values in the dictionary::

        with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()):
            ...

    `patch.dict` can be used as a context manager, decorator or class
    decorator. When used as a class decorator `patch.dict` honours
    `patch.TEST_PREFIX` for choosing which methods to wrap.
    r$Fc��||_t|��|_|j�|��||_d|_dSr@)�in_dict�dictrLr=�clear�	_original)r�r�rLr�r]s     r&rLz_patch_dict.__init__\s>������6�l�l�������6�"�"�"���
�����r%c���t|t��r|�|��Stj|��r|�|��S|�|��Sr@r0)r��fs  r&rOz_patch_dict.__call__esc���a����	*��&�&�q�)�)�)��&�q�)�)�	3��/�/��2�2�2��%�%�a�(�(�(r%c�@���t�����fd���}|S)Nc�������	�|i|������S#����wxYwr@�r�
_unpatch_dict�r\r�r�r�s  ��r&�_innerz-_patch_dict.decorate_callable.<locals>._innernsV���������
%��q�$�~�"�~�~��"�"�$�$�$�$���"�"�$�$�$�$���s	�3�A	�r�r�r�r�s`` r&r3z_patch_dict.decorate_callablem�9����	�q���	%�	%�	%�	%�	%�
��	%��
r%c�@���t�����fd���}|S)Nc���K�����	�|i|���d{V��	����S#����wxYwr@r�r�s  ��r&r�z3_patch_dict.decorate_async_callable.<locals>._innerzso�����������
%��Q��^��^�^�+�+�+�+�+�+�+��"�"�$�$�$�$���"�"�$�$�$�$���s	�
<�Ar�r�s`` r&r2z#_patch_dict.decorate_async_callableyr�r%c� �t|��D]}}t||��}|�tj��rLt|d��r<t
|j|j|j	��}||��}t|||���~|Sr5)r0r5r+rr6r4rr�rLr�rk)r�r�r�r7�	decorator�	decorateds      r&r1z_patch_dict.decorate_class�s�����J�J�	0�	0�D� ���-�-�J����� 1�2�2�
0���Z�0�0�
0�'���d�k�4�:�N�N�	�%�I�j�1�1�	���t�Y�/�/�/���r%c�8�|���|jS)zPatch the dict.)rr�r�s r&rbz_patch_dict.__enter__�s���������|�r%c��|j}t|jt��rt	|j��|_|j}|j}	|���}n"#t$ri}|D]
}||||<�YnwxYw||_|rt|��	|�
|��dS#t$r|D]
}||||<�YdSwxYwr@)rLr3r�rvrr�r+rPr��_clear_dictr=)r�rLr�r�r�rWs      r&rz_patch_dict._patch_dict�s������d�l�C�(�(�	3�$�T�\�2�2�D�L��,���
��	-��|�|�~�~�H�H���	-�	-�	-��H��
-�
-�� '�����
�
�
-�
-�		-����"����	!��� � � �	+��N�N�6�"�"�"�"�"���	+�	+�	+��
+�
+��%�c�{�����
+�
+�
+�	+���s$�
A�A>�=A>�B1�1C�Cc��|j}|j}t|��	|�|��dS#t$r|D]
}||||<�YdSwxYwr@)r�r�r�r=rP)r�r�r�rWs    r&r�z_patch_dict._unpatch_dict�s����,���>���G����	-��N�N�8�$�$�$�$�$���	-�	-�	-��
-�
-��'��}�����
-�
-�
-�	-���s�6�A�Ac�<�|j�|���dS)zUnpatch the dict.NF)r�r�)r�r\s  r&rYz_patch_dict.__exit__�s!���>�%���� � � ��ur%c�l�|���}tj�|��|Srf)rbr rgr3rhs  r&riz_patch_dict.start�s-�����!�!����%�%�d�+�+�+��
r%c��	tj�|��n#t$rYdSwxYw|�ddd��Srk)r rgr�rRrYr�s r&rlz_patch_dict.stop�s[��	��"�)�)�$�/�/�/�/���	�	�	��4�4�	�����}�}�T�4��.�.�.s�"�
0�0N)r$F)r r!r"r#rLrOr3r2r1rbrr�rYrirlr$r%r&rr?s���������8����)�)�)�	�	�	�	�	�	�������+�+�+�8
-�
-�
-�������/�/�/�/�/r%rc��	|���dS#t$rt|��}|D]}||=�YdSwxYwr@)r�rPrq)r��keysrWs   r&r�r��se����
�
������������G�}�}���	�	�C�����	�	�	����s��!=�=c�f�ttj��D]}|����dS)z7Stop all active patches. LIFO to unroll nested patches.N)rnr rgrl)rs r&�_patch_stopallr��s5���&�0�1�1����
�
�
������r%�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 zsizeof rzDadd sub mul matmul truediv floordiv mod lshift rshift and xor or pow� c#� K�|]	}d|zV��
dS)zi%sNr$�r-�ns  r&r�r�s&����7�7��5�1�9�7�7�7�7�7�7r%c#� K�|]	}d|zV��
dS)zr%sNr$r�s  r&r�r�s&����5�5�q����5�5�5�5�5�5r%>r��__get__�__set__r��
__delete__�
__format__r��__missing__�__getstate__�__reversed__�__setstate__�
__getformat__�
__reduce_ex__�__getnewargs__�__subclasses__�__getinitargs__�__getnewargs_ex__c� ���fd�}||_|S)z:Turns a callable object (like a mock) into a real functionc����|g|�Ri|��Sr@r$)r�r\r�r=s   �r&�methodz_get_method.<locals>.methods#����t�D�&�4�&�&�&�2�&�&�&r%)r )r.r=r�s ` r&r�r�s(���'�'�'�'�'��F�O��Mr%c��h|]}d|z��S)r�r$)r-r�s  r&r/r/s*����� �H�v����r%>�	__aexit__�	__anext__�
__aenter__�	__aiter__>�__del__r
rLr��__prepare__r��__instancecheck__�__subclasscheck__c�6�t�|��Sr@)r��__hash__r�s r&rVrV2s��V�_�_�T�2�2�r%c�6�t�|��Sr@)r��__str__r�s r&rVrV3s��F�N�N�4�0�0�r%c�6�t�|��Sr@)r��
__sizeof__r�s r&rVrV4s��v�0�0��6�6�r%c�x�t|��j�d|����dt|����S)N�/)rBr rtrKr�s r&rVrV5s;��$�t�*�*�"5�^�^��8O�8O�8Q�8Q�^�^�TV�W[�T\�T\�^�^�r%)r�r�r��
__fspath__y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__rY�__complex__�	__float__�__bool__�	__index__r�c����fd�}|S)Nc�L���jj}|tur|S�|urdStS�NT)�__eq__r�r�NotImplemented)�other�ret_valr�s  �r&r�z_get_eq.<locals>.__eq__Js1����+�0���'�!�!��N��5�=�=��4��r%r$)r�r�s` r&�_get_eqr�Is#���������Mr%c����fd�}|S)Nc�R���jjturtS�|urdStS�NF)�__ne__r�rr�)r�r�s �r&r�z_get_ne.<locals>.__ne__Ts,����;�)��8�8��N��5�=�=��5��r%r$)r�r�s` r&�_get_ner�Ss#���������Mr%c����fd�}|S)Nc�j���jj}|turtg��St|��Sr@)�__iter__r�rr��r�r�s �r&r�z_get_iter.<locals>.__iter__]s1����-�2���g�����8�8�O��G�}�}�r%r$)r�r�s` r&�	_get_iterr�\s#���������Or%c����fd�}|S)Nc����jj}|turtt	g����Stt	|����Sr@)r�r�r�_AsyncIteratorr�r�s �r&r�z"_get_async_iter.<locals>.__aiter__gs@����.�3���g���!�$�r�(�(�+�+�+��d�7�m�m�,�,�,r%r$)r�r�s` r&�_get_async_iterr�fs$���-�-�-�-�-�
�r%)r�r�r�r�c�&�t�|t��}|tur	||_dSt�|��}|�||��}||_dSt
�|��}|�||��|_dSdSr@)�_return_valuesrwrr��_calculate_return_value�_side_effect_methodsr�)rHr�r.�fixed�return_calculatorr��
side_effectors       r&�_set_return_valuer�ws������t�W�-�-�E��G���#�����/�3�3�D�9�9���$�(�(��.�.��*�����(�,�,�T�2�2�M�� �*�]�4�0�0�����!� r%c��eZdZd�Zd�ZdS)�
MagicMixinc��|���tt|��j|i|��|���dSr@)�_mock_set_magicsr	r�rL)r�r\r�s   r&rLzMagicMixin.__init__�sN��������.��J��%�%�.��;��;�;�;��������r%c	��ttz}|}t|dd���X|�|j��}t��}||z
}|D](}|t
|��jvrt||���)|tt
|��j��z
}t
|��}|D]!}t||t||�����"dS)Nr.)�_magicsr�r5�intersectionr.r�rBrvr�rk�
MagicProxy)r��orig_magics�these_magics�
remove_magicsrUr�s      r&r�zMagicMixin._mock_set_magics�s���� 4�4��"���4��$�/�/�;�&�3�3�D�4F�G�G�L��E�E�M�'�,�6�M�&�
)�
)���D��J�J�/�/�/��D�%�(�(�(��$�c�$�t�*�*�*=�&>�&>�>���T�
�
��!�	;�	;�E��E�5�*�U�D�"9�"9�:�:�:�:�	;�	;r%N)r r!r"rLr�r$r%r&r�r��s2������ � � �;�;�;�;�;r%r�c��eZdZdZdd�ZdS)rz-A version of `MagicMock` that isn't callable.Fc�Z�|�||��|���dSr&�r r�r's   r&r(z"NonCallableMagicMock.mock_add_spec��2��	
���D�(�+�+�+��������r%Nr��r r!r"r#r(r$r%r&rr�s.������7�7� � � � � � r%rc��eZdZdS)�AsyncMagicMixinN)r r!r"r$r%r&rr�s�������Dr%rc��eZdZdZdd�ZdS)ra�
    MagicMock is a subclass of Mock with default implementations
    of most of the magic methods. You can use MagicMock without having to
    configure the magic methods yourself.

    If you use the `spec` or `spec_set` arguments then *only* magic
    methods that exist in the spec will be created.

    Attributes and the return value of a `MagicMock` will also be `MagicMocks`.
    Fc�Z�|�||��|���dSr&r�r's   r&r(zMagicMock.mock_add_spec�r�r%Nr�rr$r%r&rr�s2������	�	� � � � � � r%rc�"�eZdZd�Zd�Zdd�ZdS)r�c�"�||_||_dSr@�r.r�)r�r.r�s   r&rLzMagicProxy.__init__�s����	�����r%c��|j}|j}|�|||���}t|||��t	|||��|S)N)r.rr)r.r�r;rkr�)r�rUr��ms    r&�create_mockzMagicProxy.create_mock�sZ���	������"�"���/5�
#�
7�
7�����q�!�!�!��&�!�U�+�+�+��r%Nc�*�|���Sr@)r
)r�r9r�s   r&r�zMagicProxy.__get__�s�����!�!�!r%r@)r r!r"rLr
r�r$r%r&r�r��sF������������"�"�"�"�"�"r%r�c���eZdZed��Zed��Zed��Z�fd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
dd�Zd
�Z�fd�Z�xZS)rr�r�r�c�T��t��j|i|��tjj|jd<d|jd<d|jd<t
��|jd<tt���}t|jd<t|jd<tjtj
ztjz|_d|_d	|_	d|_n#t&$rYnwxYwd|_||jd
<d|jd<t+��|jd
<i|jd<d|jd<dS)Nr�r�_mock_await_count�_mock_await_args�_mock_await_args_list�r
r+r-)r\r]r<r
r rirjrd)�superrLr�r�r�rvr�r
�_CODE_ATTRSr�	_CODE_SIGr6�CO_COROUTINE�
CO_VARARGS�CO_VARKEYWORDS�co_flags�co_argcount�co_varnames�co_posonlyargcountrP�co_kwonlyargcountrr)r�r\r]�	code_mockr@s    �r&rLzAsyncMockMixin.__init__�sA��������$�)�&�)�)�)�*1�);�)I��
�o�&�-.��
�)�*�,0��
�(�)�1:����
�-�.�#�[�9�9�9�	�,4�	��=�)�09�	��,�-�� �� �
!��$�
%�	��
!"�	�� 2�	��	�+,�I�(�(���	�	�	��D�	����'(�	�#�$-��
�j�!�$/��
�j�!�(-����
�n�%�*,��
�&�'�+/��
�'�(�(�(s�C�
C �C c��dK�|}t||fd���}|xjdz
c_||_|j�|��|j}|��t
|��r|�t|��s8	t|��}n#t$rt�wxYwt
|��r|�n&t|��r||i|���d{V��}n||i|��}|tur|S|j
tur|jS|j�4t|j��r|j|i|���d{V��S|j|i|��S|jS)NTr�r)r�r�r�r�r3r�rEror��
StopIteration�StopAsyncIterationrrr�r�r)r[r\r]r�r�r
r�s       r&rz!AsyncMockMixin._execute_mock_call	s��������t�V�n�$�/�/�/�����A���������#�#�E�*�*�*��!�����V�$�$�
1����v�&�&�
1�-�!�&�\�\�F�F��$�-�-�-�-�,�-����!��(�(�!� �L�!�$�V�,�,�
1�%�v�t�6�v�6�6�6�6�6�6�6�6������0��0�0���W�$�$��
��"�'�1�1��$�$���'�"�4�#3�4�4�
?�-�T�-�t�>�v�>�>�>�>�>�>�>�>�>�#�4�#�T�4�V�4�4�4�� � s�3B�Bc�X�|}|jdkrd|jpd�d�}t|���dS)zA
        Assert that the mock was awaited at least once.
        r�	Expected rHz to have been awaited.N�r�r�r�r�s   r&r�zAsyncMockMixin.assert_awaited4	sD������q� � �O�d�o�7��O�O�O�C� ��%�%�%�!� r%c�h�|}|jdks$d|jpd�d|j�d�}t|���dS)z@
        Assert that the mock was awaited exactly once.
        rr"rH�$ to have been awaited once. Awaited r�Nr#r�s   r&r�z"AsyncMockMixin.assert_awaited_once=	s\������1�$�$�9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�%�$r%c�l����|��j�)������}td|�d�������fd�}��t	��fd�����}���j��}||kr1t|t��r|nd}t|����|�dS)zN
        Assert that the last await was with the specified arguments.
        NzExpected await: z
Not awaitedc�8������d���}|S)N�await)r�r�r�s ���r&r�z:AsyncMockMixin.assert_awaited_with.<locals>._error_messageP	s"����3�3�D�&��3�Q�Q�C��Jr%Tr�)r�r�r�r�r�r3r�)r[r\r]r�r�r�r�r�s ``    @r&r�z"AsyncMockMixin.assert_awaited_withG	s���������?�"��7�7��f�E�E�H� �!K�H�!K�!K�!K�L�L�L�	�	�	�	�	�	�	��%�%�e�T�6�N��&E�&E�&E�F�F���#�#�D�O�4�4���X��� *�8�Y� ?� ?�I�H�H�T�E� ���!1�!1�2�2��=��r%c�~�|}|jdks$d|jpd�d|j�d�}t|���|j|i|��S)zi
        Assert that the mock was awaited exactly once and with the specified
        arguments.
        rr"rHr%r�)r�r�r�r�r�s     r&r�z'AsyncMockMixin.assert_awaited_once_withZ	sl��
����1�$�$�9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�'�t�'��8��8�8�8r%c�(��|���t||fd�����}t|t��r|nd}�fd��jD��}|s|t|��vr)��||��}td|z��|�dS)zU
        Assert the mock has ever been awaited with the specified arguments.
        Tr�Nc�:��g|]}��|����Sr$r�r�s  �r&r}z3AsyncMockMixin.assert_any_await.<locals>.<listcomp>m	s'���F�F�F�A�$�$�$�Q�'�'�F�F�Fr%z%s await not found)r�r�r3r�r�r�r�r�)r[r\r]r�r�r�r�r�s       @r&r�zAsyncMockMixin.assert_any_awaitf	s�������%�%�e�T�6�N��&E�&E�&E�F�F��&�x��;�;�E�����F�F�F�F��1E�F�F�F���	�H�L��$8�$8�8�8�"�>�>�t�V�L�L�O� �$��6����
�9�8r%Fc�2�	�|�	�	fd�|D��}td�|D��d��x}}t�	fd��	jD����}|sT||vrN|�d}nd�d�|D����}t	|�dt|���d	�	j����|�dSt|��}g}|D]=}	|�|���#t$r|�|��Y�:wxYw|r t	t|���d
���|�dS)a�
        Assert the mock has been awaited with the specified calls.
        The :attr:`await_args_list` list is checked for the awaits.

        If `any_order` is False (the default) then the awaits must be
        sequential. There can be extra calls before or after the
        specified awaits.

        If `any_order` is True then the awaits can be in any order, but
        they must all appear in :attr:`await_args_list`.
        c�:��g|]}��|����Sr$r�r�s  �r&r}z4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>�	r�r%c3�DK�|]}t|t���|V��dSr@r�rs  r&r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>�	s1����N�N�A�Z��9�5M�5M�N�a�N�N�N�N�N�Nr%Nc3�B�K�|]}��|��V��dSr@r�r�s  �r&r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>�	s1�����S�S��t�1�1�!�4�4�S�S�S�S�S�Sr%zAwaits not found.z,Error processing expected awaits.
Errors: {}c�@�g|]}t|t��r|nd��Sr@r�rs  r&r}z4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>�	r�r%r�r�z not all found in await list)
r�r�r�r�r�rqr�rRr3rr)
r[r�r�r�r��
all_awaitsr�r�r�r�s
         @r&r�z AsyncMockMixin.assert_has_awaitst	s������9�9�9�9�5�9�9�9���N�N��N�N�N�PT�U�U�U����S�S�S�S�d�>R�S�S�S�S�S�
��	��z�)�)��=�1�G�G� ,�-3�V�$7�$7�-5�$7�$7�$7�.8�.8��%��6�6�!*�5�!1�!1�6�6�#�3�6�6����	�

�F��*�%�%�
��	��	'�	'�D�
'��!�!�$�'�'�'�'���
'�
'�
'�� � ��&�&�&�&�&�
'�����	� �49�)�4D�4D�4D�4D�F����
�	�	s�:C�C2�1C2c�h�|}|jdkr$d|jpd�d|j�d�}t|���dS)z9
        Assert that the mock was never awaited.
        rr"rHz# to not have been awaited. Awaited r�Nr#r�s   r&r�z!AsyncMockMixin.assert_not_awaited�	s\������q� � �9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�!� r%c�|��t��j|i|��d|_d|_t	��|_dS)�0
        See :func:`.Mock.reset_mock()`
        rN)rr�r�r�r�r��r�r\r]r@s   �r&r�zAsyncMockMixin.reset_mock�	sB���	�����D�+�F�+�+�+�������(�{�{����r%r�)r r!r"r�r�r�r�rLrr�r�r�r�r�r�r�r��
__classcell__�r@s@r&rr�s�������&�&�}�5�5�K�%�%�l�3�3�J�*�*�+<�=�=�O� 0� 0� 0� 0� 0�D'!�'!�'!�R&�&�&�&�&�&�>�>�>�&
9�
9�
9����+�+�+�+�Z&�&�&�+�+�+�+�+�+�+�+�+r%rc��eZdZdZdS)r
aY
    Enhance :class:`Mock` with features allowing to mock
    an async function.

    The :class:`AsyncMock` object will behave so the object is
    recognized as an async function, and the result of a call is an awaitable:

    >>> mock = AsyncMock()
    >>> iscoroutinefunction(mock)
    True
    >>> inspect.isawaitable(mock())
    True


    The result of ``mock()`` is an async function which will have the outcome
    of ``side_effect`` or ``return_value``:

    - if ``side_effect`` is a function, the async function will return the
      result of that function,
    - if ``side_effect`` is an exception, the async function will raise the
      exception,
    - if ``side_effect`` is an iterable, the async function will return the
      next value of the iterable, however, if the sequence of result is
      exhausted, ``StopIteration`` is raised immediately,
    - if ``side_effect`` is not defined, the async function will return the
      value defined by ``return_value``, hence, by default, the async function
      returns a new :class:`AsyncMock` object.

    If the outcome of ``side_effect`` or ``return_value`` is an async function,
    the mock async function obtained when the mock object is called will be this
    async function itself (and not an async function returning an async
    function).

    The test author can also specify a wrapped object with ``wraps``. In this
    case, the :class:`Mock` object behavior is the same as with an
    :class:`.Mock` object: the wrapped object may have methods
    defined as async function functions.

    Based on Martin Richard's asynctest project.
    Nrr$r%r&r
r
�	s������'�'�'�'r%r
c�$�eZdZdZd�Zd�Zd�ZdS)�_ANYz2A helper object that compares equal to everything.c��dSr�r$�r�r�s  r&r�z_ANY.__eq__�	s���tr%c��dSr�r$r<s  r&r�z_ANY.__ne__�	s���ur%c��dS)Nz<ANY>r$r�s r&r�z
_ANY.__repr__�	s���wr%N)r r!r"r#r�r�r�r$r%r&r:r:�	sG������8�8�����������r%r:c���d|z}d}d�d�|D����}d�d�|���D����}|r|}|r|r|dz
}||z
}||zS)Nz%s(%%s)rz, c�,�g|]}t|����Sr$)�repr)r-r\s  r&r}z*_format_call_signature.<locals>.<listcomp>�	s��7�7�7�3�T�#�Y�Y�7�7�7r%c�"�g|]\}}|�d|����
S)�=r$)r-rWr�s   r&r}z*_format_call_signature.<locals>.<listcomp>�	s4�����#-�3��3�3�3������r%)rorY)r.r\r]r��formatted_args�args_string�
kwargs_strings       r&r�r��	s����$��G��N��)�)�7�7�$�7�7�7�8�8�K��I�I���17����������M��%�$���(��	#��d�"�N��-�'���^�#�#r%c��eZdZdZ		dd�Z		dd�Zd	�ZejZd
�Z	d�Z
d�Zd
�Ze
d���Ze
d���Zd�Zd�ZdS)r�a�
    A tuple for holding the results of a call to a mock, either in the form
    `(args, kwargs)` or `(name, args, kwargs)`.

    If args or kwargs are empty then a call tuple will compare equal to
    a tuple without those values. This makes comparisons less verbose::

        _Call(('name', (), {})) == ('name',)
        _Call(('name', (1,), {})) == ('name', (1,))
        _Call(((), {'a': 'b'})) == ({'a': 'b'},)

    The `_Call` object provides a useful shortcut for comparing with call::

        _Call(((1, 2), {'a': 3})) == call(1, 2, a=3)
        _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3)

    If the _Call has no name then it will match any name.
    r$rNFTc��d}i}t|��}|dkr|\}}}n~|dkr<|\}	}
t|	t��r|	}t|
t��r|
}nD|
}nA|	|
}}n<|dkr6|\}t|t��r|}nt|t��r|}n|}|rt�|||f��St�||||f��S)Nr$�r�r)r�r3rvrrr
)rr�r.r�r��	from_kallr\r]�_len�first�seconds           r&r
z
_Call.__new__
s�������5�z�z���1�9�9�!&��D�$���
�Q�Y�Y�!�M�E�6��%��%�%�
-����f�e�,�,�$�!�D�D�#�F�F�$�f�f���
�Q�Y�Y��F�E��%��%�%�
�����E�5�)�)�
�������	6��=�=��t�V�n�5�5�5��}�}�S�4��v�"6�7�7�7r%c�0�||_||_||_dSr@)r�r��_mock_from_kall)r�r�r.r�r�rJs      r&rLz_Call.__init__5
s�����"���(����r%c�r�	t|��}n#t$r
tcYSwxYwd}t|��dkr|\}}n|\}}}t|dd��r#t|dd��r|j|jkrdSd}|dkrdi}}n�|dkr|\}}}n�|dkr?|\}	t|	t��r|	}i}nit|	t��r|	}di}}nMd}|	}nH|dkr@|\}
}t|
t��r!|
}t|t��r|i}}nd|}}n|
|}}ndS|r||krdS||f||fkS)	Nrr�r�Frr$rIr)r�r�r�r5r�r3rrrv)r�r��	len_other�	self_name�	self_args�self_kwargs�
other_name�
other_args�other_kwargsr�rLrMs            r&r�z_Call.__eq__<
s���	"��E�
�
�I�I���	"�	"�	"�!�!�!�!�	"�����	��t�9�9��>�>�%)�"�I�{�{�04�-�I�y�+��D�.�$�/�/�	�G�E�>�SW�4X�4X�	��%��);�;�;��5��
���>�>�')�2��J�J�
�!�^�^�38�0�J�
�L�L�
�!�^�^��F�E��%��'�'�
%�"�
�!����E�3�'�'�
%�"�
�+-�r�L�
�
��
�$���
�!�^�^�!�M�E�6��%��%�%�
9�"�
��f�e�,�,�:�/5�r��J�J�/1�6��J�J�+0�&�L�
�
��5��	��y�0�0��5��L�)�i��-E�E�Es��&�&c��|j�td||fd���S|jdz}t|j||f||���S)Nrr9r�r�r�r�r�s    r&rOz_Call.__call__t
sN���?�"��"�d�F�+�$�7�7�7�7����%���d�o�t�V�4�4��M�M�M�Mr%c�n�|j�t|d���S|j�d|��}t||d���S)NF)r.rJrS)r.r�rJrY)r�r�r.s   r&r�z_Call.__getattr__|
sD���?�"��d�e�4�4�4�4��/�/�/�4�4�0���$�t�u�=�=�=�=r%c�b�|tjvrt�t�||��Sr@)rrrvrP�__getattribute__)r�r�s  r&r\z_Call.__getattribute__�
s+���5�>�!�!� � ��%�%�d�D�1�1�1r%c�H�t|��dkr|\}}n|\}}}||fS)Nr�r�r�s    r&�_get_call_argumentsz_Call._get_call_arguments�
s2���t�9�9��>�>��L�D�&�&�!%��D�$���V�|�r%c�6�|���dS�Nr�r^r�s r&r\z
_Call.args�
����'�'�)�)�!�,�,r%c�6�|���dS)Nrrar�s r&r]z_Call.kwargs�
rbr%c��|js%|jpd}|�d��rd|z}|St|��dkrd}|\}}n+|\}}}|sd}n |�d��sd|z}nd|z}t	|||��S)Nrr9zcall%sr�zcall.%s)rOr�r+r�r�)r�r.r\r]s    r&r�z_Call.__repr__�
s����#�	��?�,�f�D����t�$�$�
'��$����K��t�9�9��>�>��D��L�D�&�&�!%��D�$���
'�����_�_�T�*�*�
'� �4�'����$���%�d�D�&�9�9�9r%c��g}|}|�%|jr|�|��|j}|�%tt	|����S)z�For a call object that represents multiple calls, `call_list`
        returns a list of all the intermediate calls as well as the
        final call.)rOr3r�r�rn)r��valsrs   r&�	call_listz_Call.call_list�
sW���������$�
#����E�"�"�"��&�E�����$���(�(�(r%)r$rNFT)r$NNFT)r r!r"r#r
rLr�r�r�rOr�r\r^r�r\r]r�rgr$r%r&r�r�
s��������$:?��8�8�8�8�@>C��)�)�)�)�2F�2F�2F�j�]�F�N�N�N�>�>�>�2�2�2�����-�-��X�-��-�-��X�-�:�:�:�*
)�
)�
)�
)�
)r%r�)rJc	���t|��rt|��}t|t��}t|��rt	d|�d����t|��}d|i}	|rd|i}	n|�i}	|	r|rd|	d<|st
|��|	�|��t}
tj
|��ri}	nL|r|rtd���t}
n1t|��st}
n|r|rt|��st}
|	�d	|��}|}|�d
}|
d||||d�|	��}t|t"��r$|rt%||��}n#t'||��}nt)||||��|�|s
||j|<|r|sd|vrt-||dd
|���|_t1|��D�]"}
t3|
��r�	t5||
��}n#t6$rY�1wxYwd|i}|rd|i}t|t"��st9||||
|��}||j|
<n�|}t|t"��r|j}t=||
|��}||d<t?|��rt}nt}|d||
|
|d�|��}||j|
<|��|_t)|||���t|t"��rtA||
|����$|S)aCreate a mock object using another object as a spec. Attributes on the
    mock will use the corresponding attribute on the `spec` object as their
    spec.

    Functions or methods being mocked will have their arguments checked
    to check that they are called with the correct signature.

    If `spec_set` is True then attempting to set attributes that don't exist
    on the spec object will raise an `AttributeError`.

    If a class is used as a spec then the return value of the mock (the
    instance of the class) will have the same spec. You can use a class as the
    spec for an instance object by passing `instance=True`. The returned mock
    will only be callable if instances of the mock are callable.

    `create_autospec` will raise a `RuntimeError` if passed some common
    misspellings of the arguments autospec and spec_set. Pass the argument
    `unsafe` with the value True to disable that check.

    `create_autospec` also takes arbitrary keyword arguments that are passed to
    the constructor of the created mock.z'Cannot autospec a Mock object. [object=r*rr
NTrzJInstance can not be True when create_autospec is mocking an async functionr.r)r�rrr.r�r9)rerTr�r)r�r.rr)rdr$)!rsrBr3r2rr>rr=rr6�isdatadescriptorrr
rorryr[rIr�r�rfr�r	r�r0r�r5rPrMrH�
_must_skiprrk)rr
rer�rTrr]�is_type�
is_async_funcr^r]rrHrUr�rr�rd�child_klasss                   r&r	r	�
s���.��~�~���D�z�z����t�$�$�G�����5�� 4�*.� 4� 4� 4�5�5�	5�"�4�(�(�M��t�n�G����t�$���	
�����,�8�,�'+��#�$��&��f�%�%�%��N�N�6�����E����%�%�%����	�%��	?�� >�?�?�
?����
�t�_�_�%�$���	�%�X�%�&8��&>�&>�%�$���K�K���&�&�E��I����	��5�(��W�	��(�(�&�(�(�D��$�
�&�&�8��	.�'��d�3�3�D�D�!�$��-�-�D�D���t�W�h�7�7�7���8��(,���u�%��F�x�F�N�&�$@�$@�+�D�(�T�26��F�F�F����T���1&�1&���U���	��	��t�U�+�+�H�H���	�	�	��H�	�����(�#���	,� �(�+�F��(�M�2�2�	A��X�x��u�h�G�G�C�),�D���&�&��F��$�
�.�.�
#����"�4���8�8�I�"+�F�;��"�8�,�,�
(�'���'���+�(�V�%�5�*0�(�(� &�(�(�C�*-�D���&�*�{�}�}�C���X�s�i�@�@�@�@��c�=�)�)�	&��D�%��%�%�%���Ks�G$�$
G1�0G1c�D�t|t��s|t|di��vrdS|j}|jD]f}|j�|t��}|tur�,t|ttf��rdSt|t��r|cSdS|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    rvF)r3rBr5r@rurvrwrrNrMrI)rrUrkr�r�s     r&rjrjLs���
�d�D�!�!���G�D�*�b�1�1�1�1��5��~���������#�#�E�7�3�3���W�����f�|�[�9�:�:�	��5�5�
��
�
.�
.�	��N�N�N��5�5��Nr%c��eZdZ		dd�ZdS)rMFNc�Z�||_||_||_||_||_||_dSr@)r�idsr
r�rer.)r�rr
r�r.rqres       r&rLz_SpecState.__init__js0����	���� ��
���� ��
���	�	�	r%)FNNNF)r r!r"rLr$r%r&rMrMhs.������48�/4������r%rMc�|�t|t��rtj|��Stj|��Sr@)r3�bytes�io�BytesIO�StringIO)�	read_datas r&�
_to_streamrx�s4���)�U�#�#�&��z�)�$�$�$��{�9�%�%�%r%c	�x��	�
���t���}|dg���fd�}��fd�}�	�fd��
��fd��	��fd�}�fd�}t�dddl}tt	t|j�����t	t|j��������at�2ddl}tt	t|j
������a	|�td	t�
��}tt������j_
d�j_
d�j_
d�j_
d�j_
|�j_�
���d<�d�j_|�j_�	�j_|�j_|�j_�
���fd
�}||_�|_
|S)a�
    A helper function to create a mock to replace the use of `open`. It works
    for `open` called directly or used as a context manager.

    The `mock` argument is the mock object to configure. If `None` (the
    default) then a `MagicMock` will be created for you, with the API limited
    to methods or attributes available on standard file handles.

    `read_data` is a string for the `read`, `readline` and `readlines` of the
    file handle to return.  This is an empty string by default.
    Nc�Z���jj��jjS�dj|i|��Sr`)�	readlinesr��r\r]�_state�handles  ��r&�_readlines_side_effectz)mock_open.<locals>._readlines_side_effect�s7�����(�4��#�0�0�"�v�a�y�"�D�3�F�3�3�3r%c�Z���jj��jjS�dj|i|��Sr`)�readr�r|s  ��r&�_read_side_effectz$mock_open.<locals>._read_side_effect�s4����;�#�/��;�+�+��v�a�y�~�t�.�v�.�.�.r%c?�V�K����Ed{V��	�dj|i|��V���NTr)�readline)r\r]�_iter_side_effectr}s  ��r&�_readline_side_effectz(mock_open.<locals>._readline_side_effect�sT�����$�$�&�&�&�&�&�&�&�&�&�	6�$�&��)�$�d�5�f�5�5�5�5�5�	6r%c3�b�K��jj�	�jjV���dD]}|V��dSr�)r�r�)�liner}r~s ��r&r�z$mock_open.<locals>._iter_side_effect�sU������?�'�3�
3��o�2�2�2�2�
3��1�I�	�	�D��J�J�J�J�	�	r%c�^���jj��jjSt�d��Sr`)r�r�r�)r}r~s��r&�_next_side_effectz$mock_open.<locals>._next_side_effect�s)����?�'�3��?�/�/��F�1�I���r%c�0������dSr@)�close)�exctype�excinst�exctbr~s   �r&�_exit_side_effectz$mock_open.<locals>._exit_side_effect�s����������r%r�open)r.r)rrc���t����d<�jj�dkr����d<�d�j_tS)Nrr)rxr�r�r)r\r]r�r}r~rws  ����r&�
reset_datazmock_open.<locals>.reset_data�sM����y�)�)��q�	��?�&�&��)�3�3�-�-�/�/�F�1�I�*0��)�F�O�'��r%)rx�	file_spec�_iorqr�r0�
TextIOWrapper�unionru�	open_specr�rrbr��writer�r�r{r�r�rrY)
rHrw�
_read_datarr�r�r�r�r�r�r�r}r~s
 `       @@@@r&rr�s;��������I�&�&�J��$�
�F�4�4�4�4�4�4�
/�/�/�/�/�/�
6�6�6�6�6�6�
������������
��������
�
�
���S��!2�3�3�4�4�:�:�3�s�3�;�?O�?O�;P�;P�Q�Q�R�R�	����
�
�
���S���]�]�+�+�,�,�	��|��f�9�5�5�5��
�I�
&�
&�
&�F�$*�F��!� $�F�L��#�F�K��#'�F�O� �$(�F��!�/�F�K��%�%�'�'�F�1�I�"(��)�F�O��#9�F�� �"3�F�O��"3�F�O��"3�F�O����������"�D���D���Kr%c�&�eZdZdZd�Zdd�Zd�ZdS)raW
    A mock intended to be used as a property, or other descriptor, on a class.
    `PropertyMock` provides `__get__` and `__set__` methods so you can specify
    a return value when it is fetched.

    Fetching a `PropertyMock` instance from an object calls the mock, with
    no args. Setting it calls the mock with the value being set.
    c��tdi|��S)Nr$)r)r�r]s  r&r;zPropertyMock._get_child_mock�s���"�"�6�"�"�"r%Nc��|��Sr@r$)r�r9�obj_types   r&r�zPropertyMock.__get__�s
���t�v�v�
r%c��||��dSr@r$)r�r9r]s   r&r�zPropertyMock.__set__�s����S�	�	�	�	�	r%r@)r r!r"r#r;r�r�r$r%r&rr�sP��������#�#�#���������r%rc�^��eZdZdZ�fd�Zed��fd�
Z�fd�Zd�Z�fd�Z	ed�d�Z
d	�Z�xZS)
�ThreadingMixinNc���t|�d��t��r|dj|d<n8t|�d��t��r|dj|d<t	��jdi|��S)Nr��timeoutrr$)r3rwr��_mock_wait_timeoutrr;)r�r�r@s  �r&r;zThreadingMixin._get_child_mock�s�����b�f�f�X�&�&��7�7�	A��x�L�;�B�y�M�M�
����}�-�-�~�
>�
>�	A��}�-�@�B�y�M�&�u�w�w�&�,�,��,�,�,r%�r�c����t��j|i|��|tur|j}t	j��|jd<g|jd<t	j��|jd<||jd<dS)N�_mock_event�_mock_calls_events�_mock_calls_events_lockr�)rrL�_timeout_unset�DEFAULT_TIMEOUT�	threading�Eventrv�Lock)r�r�r\r]r@s    �r&rLzThreadingMixin.__init__�s{��������$�)�&�)�)�)��n�$�$��*�G�'0��'8�'8��
�m�$�.0��
�*�+�3<�>�3C�3C��
�/�0�.5��
�*�+�+�+r%c���t��j|i|��tj��|jd<g|jd<dS)r4r�r�N)rr�r�r�rvr5s   �r&r�zThreadingMixin.reset_mocksH���	�����D�+�F�+�+�+�'0��'8�'8��
�m�$�.0��
�*�+�+�+r%c���|j5|jD] \}}}||f||fkr|ccddd��S�!tj��}|j�|||f��ddd��n#1swxYwY|Sr@)r�r�r�r�r3)r��
expected_args�expected_kwargsr\r]�event�	new_events       r&�__get_eventzThreadingMixin.__get_event
s��
�
)�	X�	X�'+�'>�
!�
!�#��f�e��&�>�m�_�%E�E�E� �L�L�	X�	X�	X�	X�	X�	X�	X�	X�E�!��)�)�I��#�*�*�M�?�I�+V�W�W�W�	X�	X�	X�	X�	X�	X�	X�	X�	X�	X�	X����	X�	X�	X�	X��s�A-�1A-�-A1�4A1c���t��j|i|��}|�||��}|���|j���|Sr@)rr��_ThreadingMixin__get_eventr�r�)r�r\r]�	ret_value�
call_eventr@s     �r&r�zThreadingMixin._mock_calls^���&�E�G�G�&��7��7�7�	��%�%�d�F�3�3�
���������������r%c��|tur|j}|j�|���s|jpd�d|�d�}t|���dS)z�Wait until the mock object is called.

        `timeout` - time to wait for in seconds, waits forever otherwise.
        Defaults to the constructor provided timeout.
        Use None to block undefinetively.
        r�rHz was not called before timeout(z).N)r�r�r��waitr�r�)r�r�r�s   r&�wait_until_calledz ThreadingMixin.wait_until_called ss���n�$�$��-�G���$�$�W�$�5�5�	&��o�/��+�+�&�+�+�+�C� ��%�%�%�	&�	&r%c��|�||��}|�|j���s(|�||��}t	|�d����dS)z�Wait until the mock object is called with given args.

        Waits for the timeout in seconds provided in the constructor.
        r�z call not foundN)r�r�r�r�r�)r�r\r]r�r�s     r&�wait_until_any_call_withz'ThreadingMixin.wait_until_any_call_with.sk��
� � ��v�.�.���z�z�$�"9�z�:�:�	F�"�>�>�t�V�L�L�O� �O�!D�!D�!D�E�E�E�	F�	Fr%)
r r!r"r�r;r�rLr�r�r�r�r�r6r7s@r&r�r��s���������O�-�-�-�-�-�'5�6�6�6�6�6�6�6�1�1�1�1�1���������,:�&�&�&�&�&�F�F�F�F�F�F�Fr%r�c��eZdZdZdS)ra�
    A mock that can be used to wait until on calls happening
    in a different thread.

    The constructor can take a `timeout` argument which
    controls the timeout in seconds for all `wait` calls of the mock.

    You can change the default timeout of all instances via the
    `ThreadingMock.DEFAULT_TIMEOUT` attribute.

    If no timeout is set, it will block undefinetively.
    Nrr$r%r&rr9s��������	�Dr%rc�4�d|_t|��D]�}	t||��}n#t$rY� wxYwt	|t
��s�:t	|j�|��t��r�h|j	|urt|����dS)a�Disable the automatic generation of child mocks.

    Given an input Mock, seals it to ensure no further mocks will be generated
    when accessing an attribute that was not already defined.

    The operation recursively seals the mock passed in, meaning that
    the mock itself, any mocks generated by accessing one of its attributes,
    and all assigned mocks without a name or spec will be sealed.
    TN)rr0r5rPr3r
r�rwrMr�r)rHr�r	s   r&rrIs����D���D�	�	�
�
��	���d�#�#�A�A���	�	�	��H�	�����!�_�-�-�	���a�&�*�*�4�0�0�*�=�=�	�����%�%���G�G�G��
�
s�+�
8�8c��eZdZdZd�Zd�ZdS)r�z8
    Wraps an iterator in an asynchronous iterator.
    c�t�||_tt���}tj|_||jd<dS)Nrr<)�iteratorr
rr6�CO_ITERABLE_COROUTINErrv)r�r�rs   r&rLz_AsyncIterator.__init__es6�� ��
�#�X�6�6�6�	�$�:�	��$-��
�j�!�!�!r%c��^K�	t|j��S#t$rYnwxYwt�r@)r�r�rr r�s r&r�z_AsyncIterator.__anext__ksA����	���
�&�&�&���	�	�	��D�	���� � s��
%�%N)r r!r"r#rLr�r$r%r&r�r�as<��������.�.�.�!�!�!�!�!r%r�r�r�)NFNNN)FFNN)Nr)��__all__r�r9rtr6r�rZr��builtins�typesrrr�
unittest.utilr�	functoolsrrrrHr�	backportsrr�rr0rPrrr	r:r>r2rErJrVrfrarorsryr�r�r�r�r�r�r�r�rr�MISSINGr��DELETEDrNr�r�rqr�r�r�rr
rvr�rP�	frozensetrjr�rGr�rrrrr rsrwr|rrr�r�r��multiple�stopallr6�
magic_methodsr��numericsrorZ�inplace�right�
_non_defaultsr�r�r��_sync_async_magics�
_async_magicsr�rir�r�r�r�r�r�r�r�r�r�r�rrrr�rrQrLrrr
r:rr�rrr�rr	rjrMrBr�rIr�r�rxrr�
TIMEOUT_UNSETr�r�rrr�r$r%r&�<module>r�s�����(��������	�	�	�	�����
�
�
�
�
�
�
�
���������2�2�2�2�2�2�2�2�2�2�#�#�#�#�#�#�$�$�$�$�$�$�$�$�������������*�*�*�*�*�*�C�C�C�C�C�y�C�C�C�
I�H�c�c�(�m�m�H�H�H�	�
�
���@�@�@����2�2�2������� � � �F	#�	#�	#�	#�
�
�
����&�&�&��������4����.."�."�."�b>�>�>�6)�)�)�	)�	)�	)�	)�	)�f�	)�	)�	)�����������9�;�;��
�
������������ � � �&*�*�*�*�*��*�*�*�(���6���������
�
�
�
�
�6�
�
�
�^
<�^
<�^
<�^
<�^
<�d�^
<�^
<�^
<�B"��#�L�L���"�"�"�"�"�"�"�"�"�����I�����O�$�$�������
�
�
�
�
�4�
�
�
� ���f!�f!�f!�f!�f!�D�f!�f!�f!�T8�8�8�8�8�=�/�8�8�8�v$�$�$�������L/�L/�L/�L/�L/�V�L/�L/�L/�`
��� '�T��t�d���&+������:?C�04�.�.�.�.�d�$�u���4�O�CH�O�O�O�O�O�dV/�V/�V/�V/�V/�&�V/�V/�V/�r���������
��
� �����
����
�� �9�!�)�)�)�R�8�8�M�K�	��(�(�7�7�h�n�n�&6�&6�7�7�7�
7�
7�����5�5�H�N�N�$4�$4�5�5�5�5�5�����
�������H�H�m�X�w��
6�7�7�=�=�?�?�����@�?�?��!�]��$�'9�9�
��]�*����.������3�2�0�0�6�6�^�^�	�������������������"��������������� �	���1�1�1�$;�;�;�;�;��;�;�;�>	 �	 �	 �	 �	 �:��	 �	 �	 �	�	�	�	�	�j�	�	�	� � � � � �
�D� � � �,"�"�"�"�"��"�"�"�$�c�(�m�m���G��g�g�h�&7��>�>�?�?�	�N+�N+�N+�N+�N+�T�N+�N+�N+�b(�(�(�(�(����(�(�(�V
�
�
�
�
�6�
�
�
��d�f�f��$�$�$�$v)�v)�v)�v)�v)�E�v)�v)�v)�r
�u�u�����CG��K�*/�K�K�K�K�K�\���8	�	�	�	�	��	�	�	�	�D�����D�����	�
�
�	��	�&�&�&�S�S�S�S�l�����4����$�'��EF�EF�EF�EF�EF�T�EF�EF�EF�P
	�
	�
	�
	�
	�N�J��
	�
	�
	� ���0!�!�!�!�!�!�!�!�!�!s�%D-�-D8�7D8

Zerion Mini Shell 1.0