AlkantarClanX12

Your IP : 3.135.208.189


Current Path : /proc/self/root/opt/alt/python311/lib64/python3.11/unittest/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python311/lib64/python3.11/unittest/__pycache__/mock.cpython-311.opt-1.pyc

�

c��fH���`�dZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZddlmZGd�d	e��Zd
�ee��D��ZdZeZd�Zd
�Zd�Zd�Zd�Z d�Z!dyd�Z"d�Z#d�Z$d�Z%d�Z&dyd�Z'd�Z(d�Z)d�Z*Gd�de+��Z,Gd�de+��Z-e-��Z.e.j/Z/e.j0Z1e.j2Z3hd �Z4d!�Z5Gd"�d#e6��Z7d$�Z8Gd%�d&e+��Z9Gd'�d(e+��Z:Gd)�d*e:��Z;ej<e;j=��Z>Gd+�d,e6��Z?d-�Z@Gd.�d/e:��ZAGd0�d1eAe;��ZBd2�ZCGd3�d4e+��ZDd5�ZEe/dddddfdd6�d7�ZF		dzd8�ZGe/dddddfdd6�d9�ZHGd:�d;e+��ZId<�ZJd=�ZKeFeH_+eIeH_LeGeH_MeKeH_Nd>eH_Od?ZPd@ZQdA�RdB�eQ�S��D����ZTdA�RdC�eQ�S��D����ZUhdD�ZVdE�ZWdF�dA�RePeQeTeUg���S��D��ZXhdG�ZYdHhZZeYeZzZ[eXeVzZ\e\e[zZ]hdI�Z^dJ�dK�dL�dM�dN�Z_e`e`e`e`dOddddPdQddOddR�
ZadS�ZbdT�ZcdU�ZddV�ZeebecedeedW�ZfdX�ZgGdY�dZe:��ZhGd[�d\ehe;��ZiGd]�d^eh��ZjGd_�d`eheB��ZkGda�dbe:��ZlGdc�dde:��ZmGde�dfemejeB��ZnGdg�dhe+��Zoeo��Zpdi�ZqGdj�dker��Zsesd�l��Zt		d{dd6�dm�Zudn�ZvGdo�dpe+��Zwexeu��exepjy��fZzda{da|dq�Z}d|ds�Z~Gdt�dueB��Zdv�Z�Gdw�dx��Z�dS)})�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�seal�N)�iscoroutinefunction)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partial)�RLockc��eZdZdZdS)�InvalidSpecErrorz8Indicates that an invalid value was used as a mock spec.N��__name__�
__module__�__qualname__�__doc__���4/opt/alt/python311/lib64/python3.11/unittest/mock.pyrr)s������B�B�B�Br"rc�<�h|]}|�d���|��S��_��
startswith)�.0�names  r#�	<setcomp>r+-s)��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_objr65sg�������j��i�&@�&@���u��s�J���'��c�:�&�&���s�#�#�?�w�':�3�'?�'?�?r"c�F�t|dd��rt|��SdS)N�__code__F)r1r)�funcs r#�_is_async_funcr:=s)���t�Z��&�&��"�4�(�(�(��ur"c�F�tt|��t��S�N)�
issubclass�typerr4s r#r.r.Ds���d�3�i�i��1�1�1r"c��t|t��p)t|t��ot|t��Sr<)r/�
BaseExceptionr>r=r4s r#�
_is_exceptionrAJs6���3�
�&�&�	A��3����@�*�S�-�"@�"@�r"c�^�t|t��rt|d��r|jS|S�N�mock)r/�
FunctionTypesr0rDr4s r#�
_extract_mockrFQs3���#�}�%�%��'�#�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)
r/r>�__init__�classmethod�staticmethodr-rE�__call__�AttributeErrorrr2�	signature�
ValueError)r9�as_instance�eat_self�sig_funcs    r#�_get_signature_objectrRZs����$�����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)�self�args�kwargs�sigs   �r#�checksigz"_check_signature.<locals>.checksig�� ������$�!�&�!�!�!�!�!r")rR�_copy_func_detailsr>�_mock_check_sig�
__signature__)r9rD�	skipfirst�instancer[rZs     @r#�_check_signaturerb}sr���
��h�	�
:�
:�C�
�{����I�D�#�"�"�"�"�"��t�X�&�&�&�!)�D��J�J��"�D��J�J���r"c	�p�dD]2}	t||t||�����##t$rY�/wxYwdS)N)rr �__text_signature__r�__defaults__�__kwdefaults__)�setattrr1rL)r9�funcopy�	attributes   r#r]r]�sa�����	�	��G�Y���i�(@�(@�A�A�A�A���	�	�	��D�	����
�s�&�
3�3c���t|t��rdSt|tttf��rt|j��St|dd���dSdS)NTrKF)r/r>rJrIr�	_callabler-r1r4s r#rkrk�s^���#�t�����t��#��k�:�>�?�?�'����&�&�&��s�J��%�%�1��t��5r"c�<�t|��ttfvSr<)r>�list�tupler4s r#�_is_listro�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.rKNTF)r/r>r1�__mro__�__dict__�get)r5�bases  r#�_instance_callableru�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<rU)rXrYrZs  �r#r[z _set_signature.<locals>.checksig�r\r"rh)�
_checksig_rDzYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r/r>rRr]r�isidentifier�exec�_setup_func)rD�originalrar`�resultr9r[r*�context�srcrhrZs           @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�������_�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�rXrYrDs  �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_valuer.)�retrhrDs ��r#r�z_setup_func.<locals>.reset_mock�so���(�{�{���&�[�[����������"���S�!�!�	�#��+�+��N�N������	�	�+�+r"Fr)rD�called�
call_count�	call_argsr��call_args_listr�r�r��side_effect�_mock_childrenr�r�r�r�r�r�r�r�r_�_mock_delegate)rhrDrZr�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<)r1rD)�attrrXrYrDs   �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_listrgr)rDr�ris`  r#�_setup_async_mockr�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�s���d�1�R�4�j� �D�(�(r"c�$�eZdZdZd�Zd�Zd�ZdS)�_SentinelObjectz!A unique, named, sentinel object.c��||_dSr<r��rWr*s  r#rHz_SentinelObject.__init__"s
����	�	�	r"c��d|jzS�Nzsentinel.%sr��rWs r#�__repr__z_SentinelObject.__repr__%����t�y�(�(r"c��d|jzSr�r�r�s r#�
__reduce__z_SentinelObject.__reduce__(r�r"N)rrrr rHr�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#rHz_Sentinel.__init__.s
������r"c�l�|dkrt�|j�|t|����S)N�	__bases__)rLr��
setdefaultr�r�s  r#�__getattr__z_Sentinel.__getattr__1s3���;��� � ���)�)�$���0E�0E�F�F�Fr"c��dS)Nrr!r�s r#r�z_Sentinel.__reduce__7s���zr"N)rrrr rHr�r�r!r"r#r�r�,sJ������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�r1)rWr*�	_the_namerZs    r#�_getz"_delegating_property.<locals>._getLs/���!���;��4��+�+�+��s�D�!�!�!r"c�R�|j}|�||j|<dSt|||��dSr<)r�rrrg)rW�valuer*r�rZs     r#�_setz"_delegating_property.<locals>._setQs9���!���;�',�D�M�)�$�$�$��C��u�%�%�%�%�%r")�_allowed_names�add�property)r*r�r�r�s    r#�_delegating_propertyr�Ise�����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)NFr�T)r/rm�__contains__�len�range)rWr��	len_value�len_self�i�sub_lists      r#r�z_CallList.__contains__^s����%��&�&�	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�pformatrmr�s r#r�z_CallList.__repr__ls���~�d�4�j�j�)�)�)r"N)rrrr�r�r!r"r#r�r�\s2���������*�*�*�*�*r"r�c���t|��}t|��sdS|js|js|j�|j�dS|}|�||urdS|j}|�|r||_||_|r||_||_dS)NFT)rFr.r�r�r�r�)�parentr�r*�new_name�_parents     r#�_check_and_set_parentr�ps����%� � �E��U�#�#���u�	�	��U�1��	�	�	'�	�	�	+��u��G�
�
��e����5��*���
��(�!'���'���� �#�������4r"c��eZdZd�Zd�ZdS)�	_MockIterc�.�t|��|_dSr<)�iterr5)rWr5s  r#rHz_MockIter.__init__�s����9�9����r"c�*�t|j��Sr<)�nextr5r�s r#�__next__z_MockIter.__next__�s���D�H�~�~�r"N)rrrrHr�r!r"r#r�r��s2�������������r"r�c��eZdZeZdZd�ZdS)�BaseNc��dSr<r!�rWrXrYs   r#rHz
Base.__init__�s���r")rrrrr�r�rHr!r"r#r�r��s/������ ����
�
�
�
�
r"r�c��eZdZdZe��Zd�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`c�z�|f}t|t��s]tj|g|�Ri|��j}|�d|�d����}|�t
|��r	t|f}t|j|d|j	i��}tt|���|��}|S)N�spec_set�specr )
r=�AsyncMockMixin�	_MOCK_SIG�bind_partial�	argumentsrsr6r>rr �_safe_superr�__new__)�clsrX�kw�bases�
bound_args�spec_arg�newras        r#rzNonCallableMock.__new__�s�������#�~�.�.�	.�"�/��A�d�A�A�A�b�A�A�K�J�!�~�~�j�*�.�.��2H�2H�I�I�H��#�
�h�(?�(?�#�'��-���3�<���C�K�(@�A�A�����4�4�<�<�S�A�A���r"N�Fc��|�|}|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!)rr�_mock_add_specr��configure_mockrrrH)rWr�rr*r�r��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_self�unsaferYrrs              r#rHzNonCallableMock.__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)rFr�r�r�r�rg)rWrDri�
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�rWr�r�s   r#�
mock_add_speczNonCallableMock.mock_add_spec�s ��	
���D�(�+�+�+�+�+r"c���t|��rtd|�d����d}d}g}t|��D]5}tt	||d����r|�|���6|�`t
|��sQt|t��r|}nt|��}t|||��}	|	o|	d}t|��}|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)r.r�dirrr1�appendror/r>rRrr)rWr�r�rrr&r(r*r��resrrs           r#rzNonCallableMock._mock_add_spec�s'���T�"�"�	T�"�#R��#R�#R�#R�S�S�S���������I�I�	*�	*�D�"�7�4��t�#<�#<�=�=�
*��#�#�D�)�)�)����H�T�N�N���$��%�%�
)�"���"�4�j�j��'��(9�9�F�F�C�!�n�c�!�f�O��t�9�9�D��=��"-���� (����&5��"�#�$(���!�#/��� � � r"c��|j}|j�|jj}|tur%|j�|�|d���}||_|S)N�()�rr)r�r�r�rr�_get_child_mock)rWr�s  r#�__get_return_valuez"NonCallableMock.__get_return_values]���%����*��%�2�C��'�>�>�d�.�6��&�&� �D�'���C�!$�D���
r"c�b�|j�||j_dS||_t||dd��dS)Nr/)r�r�r�r�)rWr�s  r#�__set_return_valuez"NonCallableMock.__set_return_value%s>����*�/4�D��,�,�,�&+�D�#�!�$��t�T�:�:�:�:�:r"z1The value to be returned when the mock is called.c�<�|j�t|��S|jSr<)r&r>r�s r#�	__class__zNonCallableMock.__class__1s ����#���:�:����r"r�r�r�r�r�c���|j}|�|jS|j}|�It|��s:t	|t
��s%t
|��st|��}||_|Sr<)r�r�r��callabler/r�rA)rW�	delegated�sfs   r#�__get_side_effectz!NonCallableMock.__get_side_effect>sj���'�	����)�)�
�
"���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�)rWr�r9s   r#�__set_side_effectz!NonCallableMock.__set_side_effectIs9���%� � ���'�	���%*�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.NFrr?)�idr,r�r�r�r�r�r�r�rr�r�r��valuesr/�
_SpecState�_deletedr�r.)rW�visitedr�r��childr�s      r#r�zNonCallableMock.reset_mockTs5���?��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")�keyrIN)�sorted�items�split�popr1rg)rWrY�arg�valrX�finalr5rKs        r#rzNonCallableMock.configure_mockrs����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|���|js:|jr	||jvr*|�d��rt|�d|�d����tj5|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%)rLr)�_all_magicsr�rr(r�_lockr�rsrDrr1r1r/rCr	r�r�rar�r*rrr)rWr*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�$��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+�+B
F:�9,E&�%F:�&;F!�!
F:�:F>�F>c�n�|jg}|j}|}d}|dgkrd}|�7|}|�|j|z��d}|jdkrd}|j}|�7tt	|����}|jpd}t
|��dkr|ddvr|dz
}||d<d�|��S)NrIr/rrDr�)r/z().r)r�r�r,rm�reversedr�r��join)rW�
_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)rDzmock.z name=%rz spec=%rz spec_set=%r�<z id='z'>)rir&r'rr>rA)rWr*�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!)rD)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#rrz+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�rts  r#rrz+NonCallableMock.__dir__.<locals>.<listcomp>�sE��#�#�#�1����c�1B�1B�#��q�\�\�#�Q�#�#�#r")r�object�__dir__r)r+r>rmrrr�rOrN�set)rW�extras�	from_type�	from_dict�from_child_mockss     r#rxzNonCallableMock.__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!)rXrr|rWs  ��r#rLz-NonCallableMock.__setattr__.<locals>.<lambda>s!���H�H�T�,G�D�,G�,G�,G�B�,G�,G�r"r6rIzCannot set )r�rw�__setattr__r'r)rrrL�_unsupported_magicsr_r.rgr>�_get_methodr�r�r&r
r0ri)rWr*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<)r_r>rr�delattrr�rs�_missingrr�__delattr__rDrL)rWr*r5s   r#r�zNonCallableMock.__delattr__!s����;���4�4��:�:�+>�#>�#>��D��J�J��%�%�%��4�=�(�(����!�%�%�d�H�5�5���4�=� � ����.�.�:�:�4�@�@�@�@�
�H�_�_� ��&�&�&��h����#�D�)�$,���D�!�!�!r"c�6�|jpd}t|||��SrC)r��_format_call_signature�rWrXrYr*s    r#�_format_mock_call_signaturez+NonCallableMock._format_mock_call_signature3s ����(�&��%�d�D�&�9�9�9r"rc�d�d}|�||��}|j}|j|�}||||fzS)Nz0expected %s not found.
Expected: %s
  Actual: %s)r�r�)rWrXrY�action�message�expected_stringr��
actual_strings        r#�_format_mock_failure_messagez,NonCallableMock._format_mock_failure_message8sD��F���:�:�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.
        Nr/rrI)r(�replacerPr�rsr/rCrF)rWr*rZ�names�childrenrFs      r#�_get_call_signature_from_namez-NonCallableMock._get_call_signature_from_name@s����	(��'�'������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)r/rnr�r�r(rVrrXrY�	TypeError�with_traceback)rW�_callrZr*rXrY�
bound_callrus        r#�
_call_matcherzNonCallableMock._call_matcheras����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 'rDz"' to not have been called. Called � times.N�r�r��_calls_repr�AssertionError�rWr�s  r#r�z!NonCallableMock.assert_not_called|s^���?�a�����o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%� �r"c�R�|jdkrd|jpdz}t|���dS)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.rDN)r�r�r�r�s  r#r�zNonCallableMock.assert_called�s;���?�a���7��O�-�v�/�C� ��%�%�%� �r"c��|jdks8d|jpd�d|j�d|�����}t|���dS)z3assert that the mock was called only once.
        r�r�rDz#' to have been called once. Called r�Nr�r�s  r#r�z"NonCallableMock.assert_called_once�s^����!�#�#�#��o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%�$�#r"c�t�����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: z
  Actual: c�4��������}|Sr<�r��r�rXrYrWs ���r#�_error_messagez:NonCallableMock.assert_called_with.<locals>._error_message�s����3�3�D�&�A�A�C��Jr"T��two)r�r�r�r��_Callr/�	Exception)rWrXrY�expected�actual�
error_messager��causes```     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.r�r�rDz' to be called once. Called r�)r�r�r�r�r��rWrXrYr�s    r#r�z'NonCallableMock.assert_called_once_with�sn����!�#�#�#��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)�crWs  �r#rrz4NonCallableMock.assert_has_calls.<locals>.<listcomp>��'���9�9�9�a�D�&�&�q�)�)�9�9�9r"c3�DK�|]}t|t���|V��dSr<�r/r�rts  r#�	<genexpr>z3NonCallableMock.assert_has_calls.<locals>.<genexpr>��1����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�rts  r#rrz4NonCallableMock.assert_has_calls.<locals>.<listcomp>��;��$7�$7�$7�()�*4�A�y�)A�)A�$K�A�A�t�$7�$7�$7r"�
Expected: z  Actual)�prefixrIrDz does not contain all of z in its call list, found z instead)
r�r�r��formatr�r��rstriprm�removerNr,r�rn)	rW�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��%��I�I�!*�5�!1�!1�I��'�'�z�'�:�:�A�A�#�F�F�I�I����	�

�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#rrz3NonCallableMock.assert_any_call.<locals>.<listcomp>�s'���E�E�E�A�$�$�$�Q�'�'�E�E�Er"z%s call not found)r�r�r/r�r��_AnyComparerr�r��rWrXrYr�r�r�r�s`      r#r�zNonCallableMock.assert_any_call�s�����%�%�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*rIr/rr*r�r!)r
rirLrsrrr
r>r=r�_async_method_magicsr��_all_sync_magicsr)�
CallableMixinr
rrrq)rWrrir�r�_type�klasss       r#r1zNonCallableMock._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: rI)r�r)rWr�s  r#r�zNonCallableMock._calls_reprs6����	��2�;�F�;�;�i���8�8�;�;�;�;r")NNNNNNrNFNF�F)FFr<)r)r�)/rrrr rr`rrHrr#r�"_NonCallableMock__get_return_value�"_NonCallableMock__set_return_value�"_NonCallableMock__return_value_docr�r�r6r�r�r�r�r�r��!_NonCallableMock__get_side_effect�!_NonCallableMock__set_side_effectr�r�rr�rir�rxr�r�r�r�r�r�r�r�r�r�r�r�r�r1r�r!r"r#rr�s�������*�*�
�E�G�G�E�
�
�
�">B�EI�<A�*
�*
�*
�*
�Z'�'�'�,�,�,�,�@E�!&�0�0�0�0�>
�
�
�;�;�;�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��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�|D],}td�t||��D����rdS�-dS)Nc� �g|]\}}||k��Sr!r!)r)r�r�s   r#rrz-_AnyComparer.__contains__.<locals>.<listcomp>5s1�����$�H�f��F�"���r"TF)�all�zip)rW�itemr�s   r#r�z_AnyComparer.__contains__2s^���	�	�E����(+�D�%�(8�(8������
��t�t�	
�
�ur"N)rrrr r�r!r"r#r�r�-s-������������r"r�c��|�|St|��r|St|��r|S	t|��S#t$r|cYSwxYwr<)rArkr�r�r4s r#r=r==sk��
�{��
��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�)rrrr�rHr�)rWr�r�r�rr*r�r�rrrrYs            r#rHzCallableMixin.__init__Nsa��/;��
�*�+�1��M�4�(�(�1��%��x����K�	
�	
�39�	
�	
�	
�
'����r"c��dSr<r!r�s   r#r^zCallableMixin._mock_check_sigZs���r"c�P�|j|i|��|j|i|��|j|i|��Sr<)r^�_increment_mock_call�
_mock_callr�s   r#rKzCallableMixin.__call___sK��	���d�-�f�-�-�-�!��!�4�2�6�2�2�2��t���/��/�/�/r"c��|j|i|��Sr<)�_execute_mock_callr�s   r#r�zCallableMixin._mock_callgs��&�t�&��7��7�7�7r"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)NTr�r�r/rrI)r�r�r�r�r�r,r�r�r�r�r�r�)rWrXrYr��do_method_calls�method_call_name�mock_call_name�	is_a_callr�this_mock_callrgs           r#r�z"CallableMixin._increment_mock_calljs���������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|jr|jjtur|jS|j�
|j|i|��S|jSr<)	r�rArkr�rr�r�r�r)rWrXrY�effectr}s     r#r�z CallableMixin._execute_mock_call�s����!�����V�$�$�
1����v�&�&�
1��f���� ��(�(�!� �L�!� ���0��0�0���W�$�$��
��"�'�1�1��$�$���	%�4�#6�#C�7�#R�#R��$�$���'�#�4�#�T�4�V�4�4�4�� � r")
rrrrrHr^rKr�r�r�r!r"r#r�r�Ls������� �d���$��d�!�R�T�	'�	'�	'�	'�
�
�
�
0�0�0�8�8�8�,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* will raise an
       AttributeError. 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������5�5�5�5r"rc�@�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)rrNrr.r�getterrir
�new_callabler��create�	has_localr��autospecrY�additional_patchers)rWrrir
r�rr�r
rrYrs           r#rHz_patch.__init__sV���#��'�!�!� �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#rrz_patch.copy.<locals>.<listcomp>,s-��'
�'
�'
��A�F�F�H�H�'
�'
�'
r")rrrir
r�rr�r
rrY�attribute_namer)rW�patchers  r#rz_patch.copy%sq����K�����4�9��K����M�4�,�d�k�
�
��
"&�!4���'
�'
�"�6�'
�'
�'
��#��r"c���t|t��r|�|��Stj|��r|�|��S|�|��Sr<�r/r>�decorate_classr2r�decorate_async_callable�decorate_callable)rWr9s  r#rKz_patch.__call__2sc���d�D�!�!�	-��&�&�t�,�,�,��&�t�,�,�	6��/�/��5�5�5��%�%�d�+�+�+r"c��t|��D]q}|�tj��s�"t	||��}t|d��s�C|���}t||||�����r|S�NrK)r+r(r�TEST_PREFIXr1r0rrg)rWr�r��
attr_valuers     r#rz_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�updater
rr,rn)rW�patchedrX�keywargs�
extra_args�
exit_stack�patchingrRs        r#�decoration_helperz_patch.decoration_helperHs�����
�
�
!�
#�
#�		#�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)Nrc�|�����||��5\}}�|i|��cddd��S#1swxYwYdSr<�r&�rXr"�newargs�newkeywargsr9r!rWs    ���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�r0rr,r�rWr9r!s``@r#rz_patch.decorate_callableWsv������4��%�%�	��N�!�!�$�'�'�'��K�	�t���	5�	5�	5�	5�	5�	5�
��	5�"�F����r"c�����t�d��r�j�����St������fd�����g�_�S)Nrc���K����||��5\}}�|i|���d{V��cddd��S#1swxYwYdSr<r)r*s    ���r#r!z/_patch.decorate_async_callable.<locals>.patchedns�������'�'��(,�(0�2�2�
;�5K�g�{�!�T�7�:�k�:�:�:�:�:�:�:�:�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;�
;�
;s
�9�=�=r-r.s``@r#rz_patch.decorate_async_callablehsv������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 )rrirrrrL�KeyErrorr1�	_builtinsr/rr)rW�targetr*r|�locals     r#�get_originalz_patch.get_originalys����������~������	���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=TruerKr�r�r*r/r0zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=Truer[z: as the patch target has already been mocked out. [target=r^r%rr\r])r��_namez.Can't pass kwargs to a mock we aren't creatingr!)+r
r�r�r
rYrrr4r�r6rr/r>r6r
rror8r
r=rrir r.rurQr��boolrr1r	�
temp_original�is_localrr�_exit_stackrgrrr�__exit__�sys�exc_info)rWr
r�r�r
rYrr|r5�inherit�Klass�_kwargs�	this_spec�not_callablera�new_attrr#r%rRs                   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 rre�__annotations__rf)r;r:rrgr4rir�rr0r<r=)rWr?r$s   r#r=z_patch.__exit__#s����=�		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.)rF�_active_patchesr,�rWr}s  r#�startz_patch.start8s-�����!�!����#�#�D�)�)�)��
r"c��	|j�|��n#t$rYdSwxYw|�ddd��S�zStop an active patch.N)rKr�rNr=r�s r#�stopz_patch.stop?s[��	�� �'�'��-�-�-�-���	�	�	��4�4�	�����}�}�T�4��.�.�.s��
+�+)rrrrrKrHrrKrr�contextmanagerr&rrr6rFr=rMrPr!r"r#rr�s��������N��O�AF�"&�"&�"&�"&�"&�J
�
�
�,�,�,������#�#���#����"���"���0P�P�P�d.�.�.�*���/�/�/�/�/r"rc���	|�dd��\}}n-#tttf$rtd|�����wxYwt	t
j|��|fS)NrIr�z,Need a valid target to patch. You supplied: )�rsplitr�rNrLr�pkgutil�resolve_name)r4ris  r#�_get_targetrVKs���G�"�M�M�#�q�1�1���	�	���z�>�2�G�G�G��E�6�E�E�G�G�	G�G�����7�'��0�0�)�;�;s	��*Arc���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!�r4s�r#rLz_patch_object.<locals>.<lambda>js���V�r"r)r>�strr�r)r4rir
r�rr�r
rrrYrs`          r#�
_patch_objectr[Tsn���$�F�|�|�s�����L�L�L�
�
�	
��^�^�^�F���	�3��f��(�L�&�����r"c���t���turttj���}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����Sr<r!rYs�r#rLz!_patch_multiple.<locals>.<lambda>�s����r"z=Must supply at least one keyword argument with patch.multiplerr�N)r>rZrrTrUrNrmrOrrrr,)
r4r�rr�r
rrYrrOrir
r�this_patchers
`            r#�_patch_multipler_qs
���,�F�|�|�s�����-�v�6�6���������
��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)rVr)r4r
r�rr�r
rrrYrris           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�dictrBr �clear�	_original)rWrdrBrfrYs     r#rHz_patch_dict.__init__s>������6�l�l�������6�"�"�"���
�����r"c���t|t��r|�|��Stj|��r|�|��S|�|��Sr<r)rW�fs  r#rKz_patch_dict.__call__sc���a����	*��&�&�q�)�)�)��&�q�)�)�	3��/�/��2�2�2��%�%�a�(�(�(r"c�@���t�����fd���}|S)Nc�������	�|i|������S#����wxYwr<�rb�
_unpatch_dict�rXrrirWs  ��r#�_innerz-_patch_dict.decorate_callable.<locals>._inner#sV���������
%��q�$�~�"�~�~��"�"�$�$�$�$���"�"�$�$�$�$���s	�3�A	�r�rWriros`` r#rz_patch_dict.decorate_callable"�9����	�q���	%�	%�	%�	%�	%�
��	%��
r"c�@���t�����fd���}|S)Nc���K�����	�|i|���d{V��	����S#����wxYwr<rlrns  ��r#roz3_patch_dict.decorate_async_callable.<locals>._inner/so�����������
%��Q��^��^�^�+�+�+�+�+�+�+��"�"�$�$�$�$���"�"�$�$�$�$���s	�
<�Arprqs`` r#rz#_patch_dict.decorate_async_callable.rrr"c� �t|��D]}}t||��}|�tj��rLt|d��r<t
|j|j|j	��}||��}t|||���~|Sr)r+r1r(rrr0rbrdrBrfrg)rWr�r�r�	decorator�	decorateds      r#rz_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.)rbrdr�s r#rFz_patch_dict.__enter__Es���������|�r"c��|j}t|jt��rt	j|j��|_|j}|j}	|���}n"#t$ri}|D]
}||||<�YnwxYw||_	|rt|��	|�|��dS#t$r|D]
}||||<�YdSwxYwr<)rBr/rdrZrTrUrfrrLrg�_clear_dictr )rWrBrdrfr|rMs      r#rbz_patch_dict._patch_dictKs!������d�l�C�(�(�	>�"�/���=�=�D�L��,���
��	-��|�|�~�~�H�H���	-�	-�	-��H��
-�
-�� '�����
�
�
-�
-�		-����"����	!��� � � �	+��N�N�6�"�"�"�"�"���	+�	+�	+��
+�
+��%�c�{�����
+�
+�
+�	+���s$�A$�$B�B�B6�6C�Cc��|j}|j}t|��	|�|��dS#t$r|D]
}||||<�YdSwxYwr<)rdrgrzr rL)rWrdr|rMs    r#rmz_patch_dict._unpatch_dictgs����,���>���G����	-��N�N�8�$�$�$�$�$���	-�	-�	-��
-�
-��'��}�����
-�
-�
-�	-���s�6�A�Ac�<�|j�|���dS)zUnpatch the dict.NF)rgrm)rWrXs  r#r=z_patch_dict.__exit__ts!���>�%���� � � ��ur"c�l�|���}tj�|��|SrJ)rFrrKr,rLs  r#rMz_patch_dict.start{s-�����!�!����%�%�d�+�+�+��
r"c��	tj�|��n#t$rYdSwxYw|�ddd��SrO)rrKr�rNr=r�s r#rPz_patch_dict.stop�s[��	��"�)�)�$�/�/�/�/���	�	�	��4�4�	�����}�}�T�4��.�.�.s�"�
0�0N)r!F)rrrr rHrKrrrrFrbrmr=rMrPr!r"r#rbrb�s���������8����)�)�)�	�	�	�	�	�	�������+�+�+�8
-�
-�
-�������/�/�/�/�/r"rbc��	|���dS#t$rt|��}|D]}||=�YdSwxYwr<)rfrLrm)rd�keysrMs   r#rzrz�se����
�
������������G�}�}���	�	�C�����	�	�	����s��!=�=c�f�ttj��D]}|����dS)z7Stop all active patches. LIFO to unroll nested patches.N)rcrrKrP)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 zDadd 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">rx�__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!)rWrXrr9s   �r#�methodz_get_method.<locals>.method�s#����t�D�&�4�&�&�&�2�&�&�&r")r)r*r9r�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__rrHr��__prepare__r��__instancecheck__�__subclasscheck__c�6�t�|��Sr<)rw�__hash__r�s r#rLrL�s��V�_�_�T�2�2�r"c�6�t�|��Sr<)rw�__str__r�s r#rLrL�s��F�N�N�4�0�0�r"c�6�t�|��Sr<)rw�
__sizeof__r�s r#rLrL�s��v�0�0��6�6�r"c�x�t|��j�d|����dt|����S)N�/)r>rrirAr�s r#rLrL�s;��$�t�*�*�"5�^�^��8O�8O�8Q�8Q�^�^�TV�W[�T\�T\�^�^�r")r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__r=�__complex__�	__float__�__bool__�	__index__r�c����fd�}|S)Nc�L���jj}|tur|S�|urdStS�NT)�__eq__r�r�NotImplemented)�other�ret_valrWs  �r#r�z_get_eq.<locals>.__eq__�s1����+�0���'�!�!��N��5�=�=��4��r"r!)rWr�s` r#�_get_eqr��s#���������Mr"c����fd�}|S)Nc�R���jjturtS�|urdStS�NF)�__ne__r�rr�)r�rWs �r#r�z_get_ne.<locals>.__ne__s,����;�)��8�8��N��5�=�=��5��r"r!)rWr�s` r#�_get_ner�s#���������Mr"c����fd�}|S)Nc�j���jj}|turtg��St|��Sr<)�__iter__r�rr��r�rWs �r#r�z_get_iter.<locals>.__iter__s1����-�2���g�����8�8�O��G�}�}�r"r!)rWr�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__s@����.�3���g���!�$�r�(�(�+�+�+��d�7�m�m�,�,�,r"r!)rWr�s` r#�_get_async_iterr�s$���-�-�-�-�-�
�r")r�r�r�r�c�&�t�|t��}|tur	||_dSt�|��}|�||��}||_dSt
�|��}|�||��|_dSdSr<)�_return_valuesrsrr��_calculate_return_value�_side_effect_methodsr�)rDr�r*�fixed�return_calculatorr��
side_effectors       r#�_set_return_valuer�(s������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_magicsrr�rH�rWrXrs   r#rHzMagicMixin.__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�r1�intersectionr)ryr>rrr�rg�
MagicProxy)rW�orig_magics�these_magics�
remove_magicsrKr�s      r#r�zMagicMixin._mock_set_magicsAs���� 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)rrrrHr�r!r"r#r�r�:s2������ � � �;�;�;�;�;r"r�c��eZdZdZdd�ZdS)r
z-A version of `MagicMock` that isn't callable.Fc�Z�|�||��|���dSr!�rr�r"s   r#r#z"NonCallableMagicMock.mock_add_spec[�2��	
���D�(�+�+�+��������r"Nr��rrrr r#r!r"r#r
r
Ys.������7�7� � � � � � r"r
c��eZdZd�ZdS)�AsyncMagicMixinc��|���tt|��j|i|��|���dSr<)r�rr�rHr�s   r#rHzAsyncMagicMixin.__init__fsN��������3��O�T�*�*�3�T�@�R�@�@�@��������r"N�rrrrHr!r"r#r�r�es#������ � � � � r"r�c��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_specvr�r"Nr�r�r!r"r#rrks2������	�	� � � � � � r"rc�"�eZdZd�Zd�Zdd�ZdS)r�c�"�||_||_dSr<�r*r�)rWr*r�s   r#rHzMagicProxy.__init__�s����	�����r"c��|j}|j}|�|||���}t|||��t	|||��|S)N)r*rr)r*r�r1rgr�)rWrKr��ms    r#�create_mockzMagicProxy.create_mock�sZ���	������"�"���/5�
#�
7�
7�����q�!�!�!��&�!�U�+�+�+��r"Nc�*�|���Sr<)r�)rWr5r�s   r#r�zMagicProxy.__get__�s�����!�!�!r"r<)rrrrHr�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)r�r�r�r�c����t��j|i|��tjj|jd<d|jd<d|jd<t
��|jd<tt���}tj
tjztjz|_
d|_d|_d|_d|_||jd<d	|jd
<t%��|jd<i|jd<d|jd
<dS)Nr�r�_mock_await_count�_mock_await_args�_mock_await_args_list�r�)rXrYr8r
rrerfrH)�superrHr�r�r�rrr�rrr2�CO_COROUTINE�
CO_VARARGS�CO_VARKEYWORDS�co_flags�co_argcount�co_varnames�co_posonlyargcount�co_kwonlyargcountrn)rWrXrY�	code_mockr6s    �r#rHzAsyncMockMixin.__init__�s���������$�)�&�)�)�)�*1�);�)I��
�o�&�-.��
�)�*�,0��
�(�)�1:����
�-�.�#�X�6�6�6�	�� �� �
!��$�
%�	��
!"�	�� 2�	��'(�	�$�&'�	�#�$-��
�j�!�$/��
�j�!�(-����
�n�%�*,��
�&�'�+/��
�'�(�(�(r"c��`K�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�r,r�rArkr��
StopIteration�StopAsyncIterationrrr�r�r)rWrXrYr�r�r}s      r#r�z!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�1B�Bc�T�|jdkrd|jpd�d�}t|���dS)zA
        Assert that the mock was awaited at least once.
        r�	Expected rDz to have been awaited.N�r�r�r�r�s  r#r�zAsyncMockMixin.assert_awaited�s?����q� � �O�d�o�7��O�O�O�C� ��%�%�%�!� r"c�d�|jdks$d|jpd�d|j�d�}t|���dS)z@
        Assert that the mock was awaited exactly once.
        r�rrD�$ to have been awaited once. Awaited r�Nrr�s  r#r�z"AsyncMockMixin.assert_awaited_once�sW����1�$�$�9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�%�$r"c�h�����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_message�s"����3�3�D�&��3�Q�Q�C��Jr"Tr�)r�r�r�r�r�r/r�)rWrXrYr�r�r�r�s```    r#r�z"AsyncMockMixin.assert_awaited_with�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�z�|jdks$d|jpd�d|j�d�}t|���|j|i|��S)zi
        Assert that the mock was awaited exactly once and with the specified
        arguments.
        r�rrDr	r�)r�r�r�r�r�s    r#r�z'AsyncMockMixin.assert_awaited_once_with�sg��
��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#rrz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>	s'���F�F�F�A�$�$�$�Q�'�'�F�F�Fr"z%s await not found)r�r�r/r�r�r�r�r�r�s`      r#r�zAsyncMockMixin.assert_any_await
	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�*���fd�|D��}td�|D��d��}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#rrz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>#	r�r"c3�DK�|]}t|t���|V��dSr<r�rts  r#r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>$	r�r"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�rts  r#rrz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>-	r�r"r�z	
Actual: z not all found in await list)
r�r�r�r�r�rmr�rNr,rn)	rWr�r�r�r��
all_awaitsr�r�r�s	`        r#r�z AsyncMockMixin.assert_has_awaits	s����:�9�9�9�5�9�9�9���F�F��F�F�F��M�M���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�6C�C.�-C.c�d�|jdkr$d|jpd�d|j�d�}t|���dS)z9
        Assert that the mock was never awaited.
        rrrDz# to not have been awaited. Awaited r�Nrr�s  r#r�z!AsyncMockMixin.assert_not_awaitedC	sW����q� � �9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�!� r"c�|��t��j|i|��d|_d|_t	��|_dS)z0
        See :func:`.Mock.reset_mock()`
        rN)r�r�r�r�r�r�)rWrXrYr6s   �r#r�zAsyncMockMixin.reset_mockL	sB���	�����D�+�F�+�+�+�������(�{�{����r"r�)rrrr�r�r�r�rHr�r�r�r�r�r�r�r�r��
__classcell__)r6s@r#r�r��s�������&�&�}�5�5�K�%�%�l�3�3�J�*�*�+<�=�=�O�0�0�0�0�0�8&!�&!�&!�P&�&�&�&�&�&�>�>�>�$	9�	9�	9����*�*�*�*�X&�&�&�+�+�+�+�+�+�+�+�+r"r�c��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
V	s������'�'�'�'r"r
c�$�eZdZdZd�Zd�Zd�ZdS)�_ANYz2A helper object that compares equal to everything.c��dSr�r!�rWr�s  r#r�z_ANY.__eq__�	s���tr"c��dSr�r!rs  r#r�z_ANY.__ne__�	s���ur"c��dS)Nz<ANY>r!r�s r#r�z
_ANY.__repr__�	s���wr"N)rrrr r�r�r�r!r"r#rr�	sG������8�8�����������r"rc���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)rRs  r#rrz*_format_call_signature.<locals>.<listcomp>�	s��7�7�7�3�T�#�Y�Y�7�7�7r"c�"�g|]\}}|�d|����
S)�=r!)r)rMr�s   r#rrz*_format_call_signature.<locals>.<listcomp>�	s4�����#-�3��3�3�3������r")rdrO)r*rXrYr��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�r/rZrnr)rr�r*r�r��	from_kallrXrY�_len�first�seconds           r#rz
_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)rWr�r*r�r�r+s      r#rHz_Call.__init__�	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!r*r�)r�r�r�r1r�r/rnrZ)rWr��	len_other�	self_name�	self_args�self_kwargs�
other_name�
other_args�other_kwargsr�r-r.s            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)Nrr/r�r��r�r�r�s    r#rKz_Call.__call__
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*r+rI)r*r�r+r:)rWr�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<)rnrrrL�__getattribute__)rWr�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#rXz
_Call.args2
����'�'�)�)�!�,�,r"c�6�|���dS)Nr�rBr�s r#rYz_Call.kwargs6
rCr"c��|js%|jpd}|�d��rd|z}|St|��dkrd}|\}}n+|\}}}|sd}n |�d��sd|z}nd|z}t	|||��S)Nrr/zcall%sr�zcall.%s)r0r�r(r�r�)rWr*rXrYs    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.)r0r,r�r�rc)rW�vals�things   r#�	call_listz_Call.call_listO
sW���������$�
#����E�"�"�"��&�E�����$���(�(�(r")r!rNFT)r!NNFT)rrrr rrHr�rwr�rKr�r=r?r�rXrYr�rIr!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�)r+c	�$�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"t%||��}|rt'|��nt)||||��|�|s
||j|<|�d��}
|r |sd
|vrt/||dd||
���|_t3|��D�];}t5|��r�	t7||��}n#t8$rY�1wxYwd|i}|
r&t;|
|��r|�|���|rd|i}t|t"��st=|||||��}||j|<n{|}t|t"��r|j}tA|||��}||d<tC|��rt}nt}|d||||d�|��}||j|<t)|||���t|t"��rtE|||����=|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*rr�r/)rar8r�rrpr)r�r*rr)r`r!)#ror>r/r.rr:rr rr2�isdatadescriptorr�r
rkr
rurQrEr�r�rbr�rsr	r�r+r�r1rLr0rCrD�
_must_skiprrg)r�r�rar�r8rrY�is_type�
is_async_funcrBrArrD�wrappedrKr|r
r�r`�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�D�)�)���	$��d�#�#�#����t�W�h�7�7�7���8��(,���u�%��j�j��!�!�G��;�x�;�N�&�$@�$@�+�D�(�T�26��29�;�;�;����T���3&�3&���U���	��	��t�U�+�+�H�H���	�	�	��H�	�����(�#���	*�w�w��.�.�	*��M�M��M�)�)�)��	,� �(�+�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���&��X�s�i�@�@�@�@��c�=�)�)�	&��D�%��%�%�%���Ks�'G8�8
H�Hc�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.
    rrF)r/r>r1r6rqrrrsrrJrIrE)r�rKrMr�r}s     r#rLrL�
s���
�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)rCFNc�Z�||_||_||_||_||_||_dSr<)r��idsr�r�rar*)rWr�r�r�r*rTras       r#rHz_SpecState.__init__s0����	���� ��
���� ��
���	�	�	r")FNNNFr�r!r"r#rCrC
s.������48�/4������r"rCc�|�t|t��rtj|��Stj|��Sr<)r/�bytes�io�BytesIO�StringIO)�	read_datas r#�
_to_streamr[%s4���)�U�#�#�&��z�)�$�$�$��{�9�%�%�%r"rc	�V���	�
��t���}|dg�
�
�fd�}�
�fd�}��
fd��	�
�fd���
�fd�}t�dddl}tt	t|j�����t	t|j��������at�2ddl}tt	t|j
������a	|�tdt�	��}tt�
�����j_
d�j_
d�j_
d�j_
d�j_
|�j_�	���
d<�
d�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|��SrA)�	readlinesr��rXrY�_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|��SrA)�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)rXrY�_iter_side_effectr`s  ��r#�_readline_side_effectz(mock_open.<locals>._readline_side_effectEsT�����$�$�&�&�&�&�&�&�&�&�&�	6�$�&��)�$�d�5�f�5�5�5�5�5�	6r"c3�b�K��jj�	�jjV���dD]}|V��dSrg)rhr�)�liner`ras ��r#riz$mock_open.<locals>._iter_side_effectJsU������?�'�3�
3��o�2�2�2�2�
3��1�I�	�	�D��J�J�J�J�	�	r"c�^���jj��jjSt�d��SrA)rhr�r�)r`ras��r#�_next_side_effectz$mock_open.<locals>._next_side_effectQs)����?�'�3��?�/�/��F�1�I���r"r�open)r*r�)r�r�c���t����d<�jj�dkr����d<�d�j_tS)Nrr�)r[rhr�r)rXrYrjr`rarZs  ����r#�
reset_datazmock_open.<locals>.reset_dataqsM����y�)�)��q�	��?�&�&��)�3�3�-�-�/�/�F�1�I�*0��)�F�O�'��r")r[�	file_spec�_iormryr+�
TextIOWrapper�unionrX�	open_specrorrFr��writerdrhr^r�r�r�)rDrZ�
_read_datarbrernrsrqrirjr`ras `      @@@@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����������"�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)rWrYs  r#r1zPropertyMock._get_child_mock�s���"�"�6�"�"�"r"Nc��|��Sr<r!)rWr5�obj_types   r#r�zPropertyMock.__get__�s
���t�v�v�
r"c��||��dSr<r!)rWr5rSs   r#r�zPropertyMock.__set__�s����S�	�	�	�	�	r"r<)rrrr r1r�r�r!r"r#rr~sP��������#�#�#���������r"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)r
r+r1rLr/rr�rsrCr�r)rDr�r�s   r#rr�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)Nr�r8)�iteratorrrr2�CO_ITERABLE_COROUTINEr�rr)rWr�rs   r#rHz_AsyncIterator.__init__�s6�� ��
�#�X�6�6�6�	�$�:�	��$-��
�j�!�!�!r"c��^K�	t|j��S#t$rYnwxYwt�r<)r�r�rrr�s r#r�z_AsyncIterator.__anext__�sA����	���
�&�&�&���	�	�	��D�	���� � s��
%�%N)rrrr rHr�r!r"r#r�r��s<��������.�.�.�!�!�!�!�!r"r�r�)NFNNN)FFNN)Nr)��__all__r�rrWr2r�r>�builtinsrTr�typesrrr�
unittest.utilr�	functoolsrr�	threadingrr�rr+r3rr�rr6r:r.rArFrRrbr]rkrorur�r{r�r�rwr�r�rr�MISSINGr��DELETEDrDr�r�rmr�r�r�r�rrMrHrr�r=r�rrrrVr[r_rrbrzr�re�multiple�stopallr�
magic_methods�numericsrdrP�inplace�right�
_non_defaultsr�r�r��_sync_async_magics�
_async_magicsr�r_r�r�r�r�r�r�r�r�r�r�r�r
r�rr�r�r
rrr�rnr�rr	rLrCr>r�rErrrvr[rrrr�r!r"r#�<module>r�s5
����&��������	�	�	�	�����
�
�
�
�
�
�
�
���������'�'�'�'�'�'�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	#�	#�	#�	#�
�
�
����&�&�&��������6."�."�."�b>�>�>�6)�)�)�	)�	)�	)�	)�	)�f�	)�	)�	)�����������9�;�;��
�
������������ � � �&*�*�*�*�*��*�*�*�(���6���������
�
�
�
�
�6�
�
�
�N
<�N
<�N
<�N
<�N
<�d�N
<�N
<�N
<�b
�G��o�6�7�7�	�
�
�
�
�
�4�
�
�
� ���g!�g!�g!�g!�g!�D�g!�g!�g!�V6�6�6�6�6�=�/�6�6�6�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���������
��
� �����
����
��"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� � � �,"�"�"�"�"��"�"�"�$@+�@+�@+�@+�@+�T�@+�@+�@+�F(�(�(�(�(����(�(�(�V
�
�
�
�
�6�
�
�
��d�f�f��$�$�$�$v)�v)�v)�v)�v)�E�v)�v)�v)�r
�u�u�����CG��O�*/�O�O�O�O�O�d���8	�	�	�	�	��	�	�	�	�D�����D�����	�
�
�	��	�&�&�&�O�O�O�O�d�����4����$���0!�!�!�!�!�!�!�!�!�!r"