%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/unittest/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/unittest/__pycache__/mock.cpython-312.pyc

�

���f����dZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZddlmZGd�d	e�Zee�D�chc]}|j1d
�r�|��c}ZdZeZd�Zd
�Zd�Zd�Z d�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`Z0e/jbZ2e/jfZ4hd �Z5d!�Z6Gd"�d#e7�Z8d$�Z9Gd%�d&e,�Z:Gd'�d(e,�Z;Gd)�d*e;�Z<e=ee<�D�chc]$}|j1d+�r|j}d+���&c}�Z?Gd,�d-e7�Z@d.�ZAGd/�d0e;�ZBGd1�d2eBe<�ZCd3�ZDGd4�d5e,�ZEd6�ZFe0dddddfdd7�d8�ZG		dzd9�ZHe0dddddfdd7�d:�ZIGd;�d<e,�ZJd=�ZKd>�ZLeGeI_,eJeI_MeHeI_NeLeI_Od?eI_Pd@ZQdAZRdBj�dC�eRj��D��ZUdBj�dD�eRj��D��ZVhdE�ZWdF�ZXdBj�eQeReUeVg�j��D�chc]}dG|z��	c}ZYhdH�ZZdIhZ[eZe[zZ\eYeWzZ]e]e\zZ^hdJ�Z_dK�dL�dM�dN�dO�Z`eaeaeaeadPddddQdRddPddS�
ZbdT�ZcdU�ZddV�ZedW�ZfecedeeefdX�ZgdY�ZhGdZ�d[e;�ZiGd\�d]eie<�ZjGd^�d_ei�ZkGd`�daeieC�ZlGdb�dce;�Zm	ej�eej�d��Zpee�ZqGdd�dee;�ZsGdf�dgesekeC�ZtGdh�die,�Zueu�Zvdj�ZwGdk�dlex�Zyeyd�m�Zz		d{dd7�dn�Z{do�Z|Gdp�dqe,�Z}e~e{�e~evj��fZ�da�da�dr�Z�d|ds�Z�Gdt�dueC�Z�dv�Z�Gdw�dx�Z�ycc}wcc}wcc}w#er$rdZpY��wxYw)})�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��eZdZdZy)�InvalidSpecErrorz8Indicates that an invalid value was used as a mock spec.N��__name__�
__module__�__qualname__�__doc__���$/usr/lib/python3.12/unittest/mock.pyrr)s��Br"r�_Tc��t|�rt|t�syt|d�rt	|d�}t|�xst
j|�S)NF�__func__)�_is_instance_mock�
isinstancer
�hasattr�getattrr�inspect�isawaitable��objs r#�
_is_async_objr/5sG�����j��i�&@���s�J���c�:�&���s�#�?�w�':�':�3�'?�?r"c�4�t|dd�rt|�Sy)N�__code__F)r*r)�funcs r#�_is_async_funcr3=s���t�Z��&�"�4�(�(�r"c�4�tt|�t�S�N)�
issubclass�typerr-s r#r'r'Ds���d�3�i��1�1r"c�j�t|t�xs"t|t�xrt|t�Sr5)r(�
BaseExceptionr7r6r-s r#�
_is_exceptionr:Js-���3�
�&�	A��3���@�*�S�-�"@�r"c�V�t|t�rt|d�r|jS|S�N�mock)r(�
FunctionTypesr)r=r-s r#�
_extract_mockr?Qs%���#�}�%�'�#�v�*>��x�x���
r"c�v�t|t�r|s|j}d}nRt|ttf�rt|t�rd}|j
}nt|t�s
	|j}|r
t|d�}n|}	|tj|�fS#t$rYywxYw#t$rYywxYw)z�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    TN)
r(r7�__init__�classmethod�staticmethodr&r>�__call__�AttributeErrorrr+�	signature�
ValueError)r2�as_instance�eat_self�sig_funcs    r#�_get_signature_objectrKZs����$���k��}�}����	�D�;��5�	6��d�K�(��H��}�}��
��m�
,�	��=�=�D���4��&������W�&�&�x�0�0�0���	��	������s$�(B�B,�	B)�(B)�,	B8�7B8Fc���t|||����y�\}��fd�}t||�|t|�_�t|�_y)Nc�*���j|i|��yr5��bind)�self�args�kwargs�sigs   �r#�checksigz"_check_signature.<locals>.checksig���������$�!�&�!r")rK�_copy_func_detailsr7�_mock_check_sig�
__signature__)r2r=�	skipfirst�instancerTrSs     @r#�_check_signaturer[}sI���
��h�	�
:�C�
�{���I�D�#�"��t�X�&�!)�D��J��"�D��J�r"c	�`�dD]}	t||t||���y#t$rY�)wxYw)N)rr �__text_signature__r�__defaults__�__kwdefaults__)�setattrr*rE)r2�funcopy�	attributes   r#rVrV�s?����	�	��G�Y���i�(@�A����	��	�s�!�	-�-c��t|t�ryt|tttf�rt|j�St|dd��yy)NTrDF)r(r7rCrBr�	_callabler&r*r-s r#rdrd�sD���#�t����#��k�:�>�?�����&�&��s�J��%�1��r"c�0�t|�ttfvSr5)r7�list�tupler-s r#�_is_listrh�s����9��u�
�%�%r"c��t|t�st|dd�duS|f|jzD]}|jjd���yy)ztGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.rDNTF)r(r7r*�__mro__�__dict__�get)r.�bases  r#�_instance_callablern�s[���c�4� ��s�J��-�T�9�9������$����=�=���Z�(�4���r"c���t|t�}t|||�}|�|S|\}��fd�}t||�|j}|j�sd}||d�}d|z}	t
|	|�||}
t|
|��|
S)Nc�*���j|i|��yr5rN)rQrRrSs  �r#rTz _set_signature.<locals>.checksig�rUr"ra)�
_checksig_r=zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r(r7rKrVr�isidentifier�exec�_setup_func)r=�originalrZrY�resultr2rT�name�context�srcrarSs           @r#�_set_signaturerz�s����
�8�T�*�I�
"�8�X�y�
A�F�
�~����I�D�#�"��t�X�&����D�������%�t�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�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_y)Nc�(���j|i|��Sr5)�assert_called_with�rQrRr=s  �r#r}z'_setup_func.<locals>.assert_called_with�����&�t�&�&��7��7�7r"c�(���j|i|��Sr5)�
assert_calledr~s  �r#r�z"_setup_func.<locals>.assert_called�s���!�t�!�!�4�2�6�2�2r"c�(���j|i|��Sr5)�assert_not_calledr~s  �r#r�z&_setup_func.<locals>.assert_not_called�s���%�t�%�%�t�6�v�6�6r"c�(���j|i|��Sr5)�assert_called_oncer~s  �r#r�z'_setup_func.<locals>.assert_called_once�rr"c�(���j|i|��Sr5)�assert_called_once_withr~s  �r#r�z,_setup_func.<locals>.assert_called_once_with�s���+�t�+�+�T�<�V�<�<r"c�(���j|i|��Sr5)�assert_has_callsr~s  �r#r�z%_setup_func.<locals>.assert_has_calls�s���$�t�$�$�d�5�f�5�5r"c�(���j|i|��Sr5)�assert_any_callr~s  �r#r�z$_setup_func.<locals>.assert_any_call�s���#�t�#�#�T�4�V�4�4r"c���t��_t��_�j��j}t|�r|�ur|j�yyyr5)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer')�retrar=s ��r#r�z_setup_func.<locals>.reset_mock�sL���(�{���&�[��������"�"���S�!�#��+��N�N��+6�!r"Fr)r=�called�
call_count�	call_argsr��call_args_listr�r�r��side_effect�_mock_childrenr}r�r�r�r�r�r�r�rX�_mock_delegate)rar=rSr}r�r�r�r�r�r�r�s``         r#rtrt�s�����G�L�8�3�7�8�=�6�5���G�N��G���G��&�[�G��$�;�G��"��G���,�,�G���*�*�G��!�0�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||���y)Nrc�<��t�j|�|i|��Sr5)r*r=)�attrrQrRr=s   �r#�wrapperz"_setup_async_mock.<locals>.wrapper
s ���'�w�t�y�y�$�'��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_listr`r)r=r�rbs`  r#�_setup_async_mockr�s[��� �+�+�9�9�D���D���D�O�$�;�D��
9�,�>�	�	��i���)�!<�=�>r"c��d|ddz|k(S)N�__%s__����r!�rws r#�	_is_magicr�s���d�1�R�j� �D�(�(r"c�"�eZdZdZd�Zd�Zd�Zy)�_SentinelObjectz!A unique, named, sentinel object.c��||_yr5r��rPrws  r#rAz_SentinelObject.__init__"s	����	r"c� �d|jzS�Nzsentinel.%sr��rPs r#�__repr__z_SentinelObject.__repr__%����t�y�y�(�(r"c� �d|jzSr�r�r�s r#�
__reduce__z_SentinelObject.__reduce__(r�r"N)rrrr rAr�r�r!r"r#r�r� s��'��)�)r"r�c�"�eZdZdZd�Zd�Zd�Zy)�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.c��i|_yr5)�
_sentinelsr�s r#rAz_Sentinel.__init__.s	����r"c�b�|dk(rt�|jj|t|��S)N�	__bases__)rEr��
setdefaultr�r�s  r#�__getattr__z_Sentinel.__getattr__1s,���;�� � ����)�)�$���0E�F�Fr"c��y)Nrr!r�s r#r�z_Sentinel.__reduce__7s��r"N)rrrr rAr�r�r!r"r#r�r�,s��K��G�r"r�>�
_mock_namer��_mock_parentr��_mock_new_name�_mock_new_parent�_mock_side_effect�_mock_return_valuec�f�tj|�d|z}||fd�}||fd�}t||�S)N�_mock_c�N�|j}|�t||�St||�Sr5)r�r*)rPrw�	_the_namerSs    r#�_getz"_delegating_property.<locals>._getLs,���!�!���;��4��+�+��s�D�!�!r"c�Z�|j}|�||j|<yt|||�yr5)r�rkr`)rP�valuerwr�rSs     r#�_setz"_delegating_property.<locals>._setQs,���!�!���;�',�D�M�M�)�$��C��u�%r")�_allowed_names�add�property)rwr�r�r�s    r#�_delegating_propertyr�Is>�����t���4��I��	�"�
 $�y�&��D�$��r"c��eZdZd�Zd�Zy)r�c���t|t�stj||�St|�}t|�}||kDryt	d||z
dz�D]}||||z}||k(s�yy)NFr�T)r(rf�__contains__�len�range)rPr��	len_value�len_self�i�sub_lists      r#r�z_CallList.__contains__^s|���%��&��$�$�T�5�1�1���J�	��t�9���x����q�(�Y�.��2�3�	�A��A�a�	�k�*�H��5� ��	�r"c�>�tjt|��Sr5)�pprint�pformatrfr�s r#r�z_CallList.__repr__ls���~�~�d�4�j�)�)r"N)rrrr�r�r!r"r#r�r�\s���*r"r�c��t|�}t|�sy|js$|js|j�|j
�y|}|�||ury|j
}|��|r||_||_|r||_||_y)NFT)r?r'r�r�r�r�)�parentr�rw�new_name�_parents     r#�_check_and_set_parentr�ps����%� �E��U�#��	�	�	�U�1�1�	�	�	�	'�	�	�	�	+���G�
�
��e����*�*���
��!'���'����#������r"c��eZdZd�Zd�Zy)�	_MockIterc�$�t|�|_yr5)�iterr.)rPr.s  r#rAz_MockIter.__init__�s
����9��r"c�,�t|j�Sr5)�nextr.r�s r#�__next__z_MockIter.__next__�s���D�H�H�~�r"N)rrrrAr�r!r"r#r�r��s���r"r�c��eZdZeZdZd�Zy)�BaseNc��yr5r!�rPrQrRs   r#rAz
Base.__init__�s��r")rrrrr�r�rAr!r"r#r�r��s�� ����
r"r�c��eZdZdZe�Z			d*d�Z			d*d�Zd�Zd+d�Z			d,d�Z
d	�Zd
�ZdZ
eeee
�Zed��Zed
�Zed�Zed�Zed�Zed�Zd�Zd�Zeee�Zd-ddd�d�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d.d�Z#d�Z$d �Z%d!�Z&d"�Z'd#�Z(d$�Z)d%�Z*d+d&�Z+d'�Z,d(�Z-d/d)�Z.y)0rz A non-callable version of `Mock`NFc���|f}
t|t�s|xs|}|�t|�rt|f}
t|j|
d|j
i�}t
t|�j|�}|S)Nr )	r6�AsyncMockMixinr/r7rr �_safe_superr�__new__)�cls�specrrw�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_self�unsaferR�bases�spec_arg�newrZs                 r#r�zNonCallableMock.__new__�sm������#�~�.��'�4�H��#�
�h�(?�'��-���3�<�<���C�K�K�(@�A�����4�<�<�S�A���r"c��|�|}|j}
||
d<||
d<||
d<||
d<d|
d<|�|}d}|
�|du}
|j|||	|
�i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t�|
d<t�|
d<t�|
d<||
d<|r|jdi|��t	t
|�j
||||||�y)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!)rk�_mock_add_specr��configure_mockr�rrA)rPr�rrwr�r�r�r�r�rrrrRrks              r#rAzNonCallableMock.__init__�s*��
�� �K��=�=��#)��� �!%����%.��!�"�'2��#�$�#(��� ����D��H����d�*�I����D�(�,=�y�I�%'��!�"�"'����%)��!�"�#(��� �&*��"�#�'(��#�$�+4�;��'�(�'0�{��#�$�#,�;��� �#)��� ���D���)�&�)��O�T�*�3�3��%��x���	
r"c�l�t|�}d|_d|_d|_d|_t|||�y)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.N�)r?r�r�r�r�r`)rPr=rb�
inner_mocks    r#�attach_mockzNonCallableMock.attach_mock�s:��
#�4�(�
�"&�
��&*�
�#� "�
��$(�
�!���i��&r"c�(�|j||�y�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�rPr�r�s   r#�
mock_add_speczNonCallableMock.mock_add_spec�s��	
���D�(�+r"c��t|�rtd|�d���d}d}g}|�{t|�spt|t�r|}nt	|�}t|||�}|xr|d}t
|�}	|	D]*}
tt||
d��s�|j|
��,|	}|j}||d<||d<||d<||d<||d<y)	Nz#Cannot spec a Mock object. [object=�]r��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)r'rrhr(r7rK�dirrr*�appendrk)rPr�r�rrrrr�res�	spec_listr�rks            r#rzNonCallableMock._mock_add_spec�s����T�"�"�%H���PQ�#R�S�S���������H�T�N��$��%�"��"�4�j��'��(9�9�F�C�!�n�c�!�f�O��D�	�I�!�
.��&�w�t�T�4�'@�A� �'�'��-�
.��D��=�=��"-���� (����&5��"�#�$(���!�#/��� r"c��|j}|j�|jj}|tur&|j�|j|d��}||_|S)N�()�r�r�)r�r�r�rr�_get_child_mock)rPr�s  r#�__get_return_valuez"NonCallableMock.__get_return_valuese���%�%�����*��%�%�2�2�C��'�>�d�.�.�6��&�&� �D�'��C�!$�D���
r"c�j�|j�||j_y||_t||dd�y)Nr%)r�r�r�r�)rPr�s  r#�__set_return_valuez"NonCallableMock.__set_return_value*s2�����*�/4�D���,�&+�D�#�!�$��t�T�:r"z1The value to be returned when the mock is called.c�H�|j�t|�S|jSr5)rr7r�s r#�	__class__zNonCallableMock.__class__6s$�����#���:�����r"r�r�r�r�r�c���|j}|�|jS|j}|�8t|�s-t	|t
�st
|�st|�}||_|Sr5)r�r�r��callabler(r�r:)rP�	delegated�sfs   r#�__get_side_effectz!NonCallableMock.__get_side_effectCs\���'�'�	����)�)�)�
�
"�
"���N�8�B�<�"�2�y�1�-��:K��2��B�$&�I�!��	r"c�T�t|�}|j}|�||_y||_yr5)�	_try_iterr�r�r�)rPr�r/s   r#�__set_side_effectz!NonCallableMock.__set_side_effectNs-���%� ���'�'�	���%*�D�"�$)�I�!r"�r�r�c��|�g}t|�|vry|jt|��d|_d|_d|_t�|_t�|_t�|_|rt|_
|rd|_|jj�D]/}t|t�s|t ur�|j#|||���1|j}t%|�r||ur|j#|�yyy)z-Restore the mock object to its initial state.NFrr5)�idr!r�r�r�r�r�r�r�rr�r�r��valuesr(�
_SpecState�_deletedr�r')rP�visitedr�r��childr�s      r#r�zNonCallableMock.reset_mockYs����?��G�
�d�8�w������r�$�x� ����������#�+���'�k���%�K����&-�D�#��%)�D�"��(�(�/�/�1�	Z�E��%��,���0A�����W�<�[��Y�	Z�
�%�%���S�!�c��o��N�N�7�#�'6�!r"c���t|j�d���D]H\}}|jd�}|j�}|}|D]}t	||�}�t|||��Jy)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�*�|djd�S)Nr�.)�count)�entrys r#�<lambda>z0NonCallableMock.configure_mock.<locals>.<lambda>�s���q�����1D�r")�keyr?N)�sorted�items�split�popr*r`)rPrR�arg�valrQ�finalr.rAs        r#rzNonCallableMock.configure_mockwsq���v�|�|�~�$E�	F�
	%�H�C��
�9�9�S�>�D��H�H�J�E��C��
*���c�5�)��
*��C���$�
	%r"c
���|dvrt|��|j�$||jvs|tvr$td|z��t|�rt|��|jsD|jr||jvr*|jd�s|tvrt|�d|�d���tj5|jj|�}|turt|��|�Jd}|j�t|j|�}|j|||||��}||j|<nat|t �rQ	t#|j$|j&|j(|j*|j,�}||j|<ddd�|S#t.$r6|j0dxs|}t/d|�d	|�d
|�d|j$�d�	��wxYw#1swYSxYw)
N>rrzMock 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�rwrr�r�r��Cannot autospec attr �
 from target �, as it has already been mocked out. [target=�, attr=r)rEr�_all_magicsr�r�
startswith�_ATTRIB_DENY_LISTr�_lockr�rlr:rr*r'r(r9r	r�r�rZr�rwrrk)rPrwrvr�target_names     r#r�zNonCallableMock.__getattr__�s���4�4� ��&�&�
�
�
�
+��4�-�-�-���1D�$�%F��%M�N�N�
�t�_� ��&�&�� � �$�*<�*<��D�L^�L^�@^����O�P�TX�\m�Tm�$��h�'�'+�h�.K�M�N�N��
"�
"�	4��(�(�,�,�T�2�F���!�$�T�*�*������#�#�/�$�D�$4�$4�d�;�E��-�-��d�%�4� $�.���.4��#�#�D�)��F�J�/�
D�,����V�_�_�f�o�o��
�
�v�{�{��F�.4��#�#�D�)�;	4�>�
��(�D�"&�-�-��"=�"E��K�*�/��x�}�&�/�*#�#'�(�'�&�+�+���C�D�D�D��/	4�>�
�s&�6BG�AF�G�?G�G�G(c�|�|jg}|j}|}d}|dgk(rd}|�B|}|j|j|z�d}|jdk(rd}|j}|��Btt	|��}|j
xsd}t
|�dkDr|ddvr|dz
}||d<dj|�S)Nr?r%rr=r�)r%z().r)r�r�r!rf�reversedr�r��join)rP�
_name_listr��last�dot�_firsts      r#�_extract_mock_namez"NonCallableMock._extract_mock_name�s����)�)�*�
��'�'�������$����C��!��D����g�4�4�s�:�;��C��%�%��-����.�.�G��!��(�:�.�/�
����*�F���z�?�Q���!�}�M�1��#�
���
�1�
��w�w�z�"�"r"c��|j�}d}|dvrd|z}d}|j�)d}|jrd}||jjz}dt	|�j�|�|�dt|��d�S)	Nr)r=zmock.z name=%rz spec=%rz spec_set=%r�<z id='z'>)rarrrr7r7)rPrw�name_string�spec_strings    r#r�zNonCallableMock.__repr__�s����&�&�(�����(�(�$�t�+�K������'�$�K��~�~�,��%��(8�(8�(A�(A�A�K����J������t�H�	
�	
r"c��tstj|�S|jxsg}t	t|��}t
|j�}|jj�D��cgc]\}}|tur|��}}}|D�cgc]}|jd�r�|��}}|D�cgc] }|jd�rt|�r|��"}}tt||z|z|z��Scc}}wcc}wcc}w)z8Filter the output of `dir(mock)` to only useful members.r$)r�object�__dir__rr r7rfrkr�rEr:rVr�rD�set)rP�extras�	from_type�	from_dict�m_name�m_value�from_child_mocks�es        r#rhzNonCallableMock.__dir__�s�����>�>�$�'�'��#�#�)�r����T�
�O�	�����'�	�*.�*=�*=�*C�*C�*E�(�&�v�w��h�&�
�(��(�!*�C�1����c�1B�Q�C�	�C� )�#�1����c�1B��q�\��#�	�#��c�&�9�,�y�8�;K�K�L�M�M��(��D��#s�2C2�
C8�$C8�.%C=c� ���|tvrtj�||�S�jr6�j�*|�jvr|�j
vrt
d|z��|tvrd|z}t
|��|tvr��j�|�jvrt
d|z��t|�s)tt��|t||��|���fd�}n^t�|d|�tt��||�|�j|<n*|dk(r|�_yt�|||�r|�j|<�j r/t#�|�s#�j%��d|��}t
d|����tj�||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.c�����g|��i|��Sr5r!)rQ�kwrurPs  ��r#rBz-NonCallableMock.__setattr__.<locals>.<lambda>s���H�T�,G�D�,G�B�,G�r"r,r?zCannot set )r�rg�__setattr__rrrkrE�_unsupported_magicsrUr'r`r7�_get_methodr�r�rrr)ra)rPrwr��msg�	mock_namerus`    @r#rtzNonCallableMock.__setattr__�s�����>�!��%�%�d�D�%�8�8��n�n��!3�!3�!?���*�*�*���
�
�%� �!D�t�!K�L�L�
�(�
(�B�T�I�C� ��%�%�
�[�
 ��!�!�-�$�d�>P�>P�2P�$�%H�4�%O�P�P�$�U�+���T�
�D�+�d�E�*B�C� ��G��&�d�E�4��>���T�
�D�%�0�,1��#�#�D�)�
�[�
 �$�D���$�T�5�$��=�,1��#�#�D�)����W�T�4�%8��2�2�4�5�Q�t�f�=�I� �;�y�k�!:�;�;��!�!�$��e�4�4r"c��|tvr;|t|�jvr$tt|�|�||jvry|jj|t�}||jvr tt|�j|�n|turt|��|tur
|j|=t|j|<yr5)rUr7rk�delattrr�rl�_missingr�r�__delattr__r:rE)rPrwr.s   r#r|zNonCallableMock.__delattr__&s����;��4�4��:�+>�+>�#>��D��J��%��4�=�=�(���!�!�%�%�d�H�5���4�=�=� ����.�:�:�4�@�
�H�_� ��&�&��h���#�#�D�)�$,����D�!r"c�<�|jxsd}t|||�Sr<)r��_format_call_signature�rPrQrRrws    r#�_format_mock_call_signaturez+NonCallableMock._format_mock_call_signature8s�����(�&��%�d�D�&�9�9r"c�p�d}|j||�}|j}|j|�}||||fzS)Nz0expected %s not found.
Expected: %s
  Actual: %s)r�r�)rPrQrR�action�message�expected_stringr��
actual_strings        r#�_format_mock_failure_messagez,NonCallableMock._format_mock_failure_message=sF��F���:�:�4��H���N�N�	�8��8�8�)�D�
��&�/�=�A�A�Ar"c� �|s|jSd}|jdd�jd�}|j}|D]K}|j	|�}|�t|t�r|St|�}|j}|j}�M|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%rr?)r�replacerFr�rlr(r9r?)rPrwrS�names�childrenr<s      r#�_get_call_signature_from_namez-NonCallableMock._get_call_signature_from_nameEs�����'�'�'������T�2�&�,�,�S�1���&�&���
	,�D��L�L��&�E��}�
�5�*� =���
�	&�e�,�� �/�/���+�+��
	,��
r"c�v�t|t�r#t|�dkDr|j|d�}n|j}|�Pt|�dk(rd}|\}}n|\}}}	|j
|i|��}t
||j|j�S|S#t$r}|jd�cYd}~Sd}~wwxYw)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(rgr�r�rrOrrQrR�	TypeError�with_traceback)rP�_callrSrwrQrR�
bound_callrps        r#�
_call_matcherzNonCallableMock._call_matcherfs����e�U�#��E�
�Q���4�4�U�1�X�>�C��&�&�C��?��5�z�Q����$���f�%*�"��d�F�
.�%�S�X�X�t�6�v�6�
��D�*�/�/�:�3D�3D�E�E��L���
.��'�'��-�-��
.�s�2B�	B8�B3�-B8�3B8c��|jdk7r<d|jxsd�d|j�d|j���}t|��y)z/assert that the mock was never called.
        r�
Expected 'r=z"' to not have been called. Called � times.N�r�r��_calls_repr�AssertionError�rPrws  r#r�z!NonCallableMock.assert_not_called�sK���?�?�a���o�o�/��/��o�o��&�&�(�*�C�!��%�%� r"c�^�|jdk(rd|jxsdz}t|��y)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.r=N)r�r�r�r�s  r#r�zNonCallableMock.assert_called�s6���?�?�a��7��O�O�-�v�/�C� ��%�%� r"c��|jdk(s<d|jxsd�d|j�d|j���}t|��y)z3assert that the mock was called only once.
        r�r�r=z#' to have been called once. Called r�Nr�r�s  r#r�z"NonCallableMock.assert_called_once�sK�����!�#��o�o�/��/��o�o��&�&�(�*�C�!��%�%�$r"c�D�����j�'�j���}d}d|�d|��}t|�����fd�}�jt	��fd���}�j�j�}||k7r%t|t�r|nd}t|��|�y)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�,���j���}|Sr5�r��rwrQrRrPs ���r#�_error_messagez:NonCallableMock.assert_called_with.<locals>._error_message�s����3�3�D�&�A�C��Jr"T��two)r�r�r�r��_Callr(�	Exception)rPrQrR�expected�actual�
error_messager��causes```     r#r}z"NonCallableMock.assert_called_with�s����
�>�>�!��7�7��f�E�H�"�F���)�M� ��/�/�	��%�%�e�T�6�N��&E�F���#�#�D�N�N�3���X�� *�8�Y� ?�H�T�E� ��!1�2��=�r"c��|jdk(s<d|jxsd�d|j�d|j���}t|��|j|i|��S)ziassert that the mock was called exactly once and that that call was
        with the specified arguments.r�r�r=z' to be called once. Called r�)r�r�r�r�r}�rPrQrRrws    r#r�z'NonCallableMock.assert_called_once_with�s^�����!�#��o�o�/��/��o�o��&�&�(�*�C�!��%�%�&�t�&�&��7��7�7r"c	���|D�cgc]}�j|���}}td�|D�d�}t�fd��jD��}|sv||vrq|�d}n1dj	|D�cgc]}t|t�r|nd��c}�}t|�dt|���jd��jd	����|�yt|�}g}	|D]}
	|j|
��|	r,t�jxsd
�dt|	��d|�d
��|�ycc}wcc}w#t$r|	j|
�Y�lwxYw)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`.c3�BK�|]}t|t�s�|���y�wr5�r(r���.0rps  r#�	<genexpr>z3NonCallableMock.assert_has_calls.<locals>.<genexpr>������F�A�Z��9�-E�a�F����Nc3�@�K�|]}�j|����y�wr5�r��r��crPs  �r#r�z3NonCallableMock.assert_has_calls.<locals>.<genexpr>�s�����M��d�0�0��3�M���zCalls not found.z+Error processing expected calls.
Errors: {}�
Expected: z  Actual)�prefixr?r=z does not contain all of z in its call list, found z instead)r�r�r�r��formatr(r�r�r��rstriprf�removerGr!r�rg)rP�calls�	any_orderr�r�r��	all_calls�problemrp�	not_found�kalls`          r#r�z NonCallableMock.assert_has_calls�s}���49�9�a�D�&�&�q�)�9��9��F��F��M���M�T�_�_�M�M�	���y�(��=�0�G� ,�-3�V�-5�$7�()�*4�A�y�)A�A�t�$K�$7�.8��%��i� !�!*�5�!1� 2��'�'�z�'�:�A�A�#�F�G�I���	�

���O�	��	��	'�D�
'�� � ��&�	'�
� �&*�o�o�&?��&?�&+�I�&6�	�C���	
���7:��$7���
'�� � ��&�
'�s�D�+D#�D(�(E�Ec�"�|jt||fd���}t|t�r|nd}|jD�cgc]}|j|���}}|s
|t|�vr!|j
||�}td|z�|�ycc}w)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�Nz%s call not found)r�r�r(r�r��_AnyComparerr�r��rPrQrRr�r�r�r�r�s        r#r�zNonCallableMock.assert_any_call�s����%�%�e�T�6�N��&E�F��&�x��;����15�1D�1D�E�A�$�$�$�Q�'�E��E��H�L��$8�8�"�>�>�t�V�L�O� �#�o�5���
�9��F��Bc�J�|jr,d|vrd|d��nd}|j�|z}t|��|jd�}||jdvrtdi|��St
|�}t|t�r|tvrt
}n�t|t�r0|tvs|jr||jvrt}nTt
}nMt|t�s.t|t�rt}n&t|t�rt }n|j"d}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).rwr?r%r�rr�r!)rrarErlrkr
r7r6r�_async_method_magicsr��_all_sync_magicsr�
CallableMixinr
rrrj)rPrsrbrxr��_type�klasss       r#r'zNonCallableMock._get_child_mock�s�����,2�b�L�!�B�v�J�<�(�d�I��/�/�1�I�=�I� ��+�+��F�F�;�'�	���
�
�n�5�5��?�r�?�"��T�
���e�Y�'�I�9M�,M��E�
��~�
.��-�-��&�&�9��8J�8J�+J�!��!���E�=�1��%�!5�6�!���E�?�3����M�M�!�$�E��{�r�{�r"c�T�|jsyd|�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: r?)r�r)rPr�s  r#r�zNonCallableMock._calls_repr"s-�������F�8�2�i����8�9��;�;r")NNNNNNrNFNF�F)FFr5)r)�Calls)/rrrr rrXr�rArrr�"_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�rr�rar�rhrtr|r�r�r�r�r�r�r�r}r�r�r�r'r�r!r"r#rr�sM��*�
�G�E�=A�EI�<A��(>B�EI�<A�*
�Z'�,�@E�!&�0�B
�;�M���.�0B�.�0�L�� �� �
"�(�
+�F�%�l�3�J�$�[�1�I�)�*:�;�N�%�l�3�J�	�*��,�.?�@�K�$�u�%�$�<%�,-�`#�6
�*N�$$5�N-�$:�
B��B�6&�&�&�>�,	8�*�Z
� #�L
<r"r�assert_c��eZdZdZd�Zy)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]H}t|�t|�k(sJ�tt||�D��cgc]
\}}||k(��c}}�s�Hyycc}}w)NTF)r��all�zip)rP�itemr�r�r�s     r#r�z_AnyComparer.__contains__<sd���	�E��t�9��E�
�*�*�*��(+�D�%�(8��$�H�f��F�"����
	���s�AN)rrrr r�r!r"r#r�r�7s���r"r�c�x�|�|St|�r|St|�r|S	t|�S#t$r|cYSwxYwr5)r:rdr�r�r-s r#r3r3GsJ��
�{��
��S���
���~��
���C�y������
��s�
+�9�9c
�F�eZdZddedddddddf
d�Zd�Zd�Zd�Zd�Zd�Z	y)	r�Nrc
��||jd<tt|�j|||||||	|
fi|��||_y)Nr�)rkr�r�rAr�)rPr�r�r�rrwr�r�r�r�r�rRs            r#rAzCallableMixin.__init__XsN��/;��
�
�*�+�1��M�4�(�1�1��%��x����K�	
�39�	
�
'��r"c��yr5r!r�s   r#rWzCallableMixin._mock_check_sigds��r"c�n�|j|i|��|j|i|��|j|i|��Sr5)rW�_increment_mock_call�
_mock_callr�s   r#rDzCallableMixin.__call__isD��	����d�-�f�-�!��!�!�4�2�6�2��t����/��/�/r"c�&�|j|i|��Sr5)�_execute_mock_callr�s   r#r�zCallableMixin._mock_callqs��&�t�&�&��7��7�7r"c���d|_|xjdz
c_t||fd��}||_|jj|�|jdu}|j}|j}|dk(}|jjtd||f��|j}|��|rI|jjt|||f��|jdu}|r|jdz|z}t|||f�}	|jj|	�|jr(|rd}
nd}
|jdk(}|j|
z|z}|j}|���yy)NTr�r�r%rr?)r�r�r�r�r�r!r�r�r�r�r�r�)rPrQrRr��do_method_calls�method_call_name�mock_call_name�	is_a_callr��this_mock_callr_s           r#r�z"CallableMixin._increment_mock_calltso��������1���
�t�V�n�$�/��������"�"�5�)��+�+�4�7���?�?���,�,��"�d�*�	������u�b�$��%7�8�9��+�+���%���(�(�/�/��7G��v�6V�0W�X�"-�":�":�$�"F��"�'2�'=�'=��'C�FV�'V�$�#�N�D�&�#A�B�N��"�"�)�)�.�9��)�)���C��C�'�6�6�$�>�	�!,�!;�!;�c�!A�N�!R��&�6�6�K�-�%r"c��|j}|�Bt|�r|�t|�st|�}t|�r
|�||i|��}|tur|S|j
tur|jS|jr(|jjtur|jS|j�|j|i|��S|jSr5)	r�r:rdr�rr�r�r�r)rPrQrR�effectrvs     r#r�z CallableMixin._execute_mock_call�s����!�!�����V�$����v�&��f��� ��(� �L���0��0���W�$��
��"�"�'�1��$�$�$����4�#6�#6�#C�#C�7�#R��$�$�$����'�#�4�#�#�T�4�V�4�4�� � � r")
rrrrrArWrDr�r�r�r!r"r#r�r�Vs8�� �d���$��d�!�R�T�	'�
�
0�8�,7�\!r"r�c��eZdZdZy)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��7r"rc�:�d}|D]}||vs�t|�d���y)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��s6��2�E�����?�"���(�O�P��
�r"c��eZdZdZgZdd�d�Zd�Zd�Zd�Ze	jd��Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zy)�_patchNF�rc
�p�|� |turtd��|�td��|
st|	�t|�rt	d|�d|�d���t|�rt	d|�d|�d���||_||_||_||_||_	||_
d|_||_||_
|	|_g|_y)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=rz? as the spec_set target has already been mocked out. [spec_set=F)rrGr�r'r�getterrbr�new_callabler��create�	has_localr��autospecrR�additional_patchers)rPr�rbrr�r�r�r�r�rRrs           r#rAz_patch.__init__s����#��'�!� �B����#� �G����!�&�)��T�"�"�#�I�=�16�6:�X�Q�@�A�
A��X�&�"�#�I�=�1A�AI��A�O�P�
P����"������(�����	������� ��
� ��
����#%�� r"c�f�t|j|j|j|j|j
|j|j|j|j�	}|j|_
|jD�cgc]}|j���c}|_|Scc}wr5)
r�r�rbrr�r�r�r�r�rR�attribute_namer��copy)rP�patcher�ps   r#rz_patch.copy1s�����K�K�������4�9�9��K�K�����M�M�4�,�,�d�k�k�
��
"&�!4�!4���"�6�6�'
��A�F�F�H�'
��#����'
s�
B.c��t|t�r|j|�Stj|�r|j|�S|j
|�Sr5�r(r7�decorate_classr+r�decorate_async_callable�decorate_callable)rPr2s  r#rDz_patch.__call__>sM���d�D�!��&�&�t�,�,��&�&�t�,��/�/��5�5��%�%�d�+�+r"c���t|�D]^}|jtj�s�#t	||�}t|d�s�<|j
�}t||||���`|S�NrD)r rVr�TEST_PREFIXr*r)rr`)rPr�r��
attr_valuers     r#rz_patch.decorate_classFsf����J�		6�D��?�?�5�#4�#4�5�� ���-�J��:�z�2���i�i�k�G��E�4���!4�5�		6��r"c#�RK�g}tj�5}|jD]U}|j|�}|j�|j|��2|jtus�E|j|��W|t|�z
}||f��ddd�y#1swYyxYw�wr5)
�
contextlib�	ExitStack�	patchings�
enter_contextr�updaterrr!rg)rP�patchedrQ�keywargs�
extra_args�
exit_stack�patchingrHs        r#�decoration_helperz_patch.decoration_helperTs������
�
�
!�
!�
#�		#�z�#�-�-�
+�� �.�.�x�8���*�*�6��O�O�C�(��\�\�W�,��%�%�c�*�
+�
�E�*�%�%�D���"�"�		#�		#�		#�s#�B'�AB�+'B�	B'�B$� B'c�����t�d�r�jj���St�����fd����g�_�S)Nrc�l���j�||�5\}}�|i|��cddd�S#1swYyxYwr5�r�rQr�newargs�newkeywargsr2rrPs    ���r#rz)_patch.decorate_callable.<locals>.patchedisB����'�'��(,�(0�2�
5�5K�g�{��W�4��4�
5�
5�
5�s�*�3�r)rr!r�rPr2rs``@r#r	z_patch.decorate_callablecsK����4��%��N�N�!�!�$�'��K�	�t��	5�
�	5�"�F����r"c�����t�d�r�jj���St�����fd����g�_�S)Nrc���K��j�||�5\}}�|i|���d{���cddd�S7�
#1swYyxYw�wr5rrs    ���r#rz/_patch.decorate_async_callable.<locals>.patchedzsS������'�'��(,�(0�2�
;�5K�g�{�!�7�:�k�:�:�
;�
;�;��
;�
;�s#�A�6�4�6�
A�6�?�Ar r!s``@r#rz_patch.decorate_async_callabletsK����4��%��N�N�!�!�$�'��K�	�t��	;�
�	;�"�F����r"c�H�|j�}|j}t}d}	|j|}d}|tvrt|t�rd|_
|js|turt	|�d|����||fS#tt
f$rt
||t�}Y�iwxYw)NFTz does not have the attribute )r�rbrrkrE�KeyErrorr*�	_builtinsr(rr�)rP�targetrwru�locals     r#�get_originalz_patch.get_original�s���������~�~������	����t�,�H��E��9���F�J�!?��D�K��{�{�x�7�2� �7=�t�D��
��������)�	6��v�t�W�5�H�	6�s�A>�> B!� B!c��|j|j|j}}}|j|j}}|j
}|j
�|_|durd}|durd}|durd}|�
|�td��|�|�|dvrtd��|j�\}}|tu�rd|��ad}	|dur|}|dur|}d}n|�	|dur|}d}n|dur|}|�|�%|turtd��t|t�rd}	|�t|�rt}
nt}
i}|�|}
n@|�|�<|}|�|}t!|�rd|v}
nt#|�}
t|�rt}
n|
rt$}
|�||d	<|�||d
<t|
t�r+t'|
t(�r|j*r|j*|d<|j-|�|
di|��}|	�rFt/|��r:|}|�|}t!|�st1|�st$}
|j3d�|
d|dd
�|��|_n�|��|turtd��|turtd��t7|�}|dur|}t/|j�r)t9d|j*�d|j�d|�d���t/|�rMt;|jd|j�}t9d|j*�d|�d|j�d|�d�	��t=|f||j*d�|��}n
|rtd��|}||_||_ tCjD�|_#	tI|j|j*|�|jJ�ui}|jtur|||jJ<|jLD]A}|jFjO|�}|jtus�1|j-|��C|S|S#|jPtSjT��s�YyxYw)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=TruerDr�r�rwr%r&zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=TruerQz: as the patch target has already been mocked out. [target=rTrrrRrS)r��_namez.Can't pass kwargs to a mock we aren't creatingr!)+rr�r�r�rRr�r�r'r�r)rr(r7r/r
rrhr.r
r6rrbrr'rnrGr��boolrr*r	�
temp_original�is_localrr�_exit_stackr`rr�r�__exit__�sys�exc_info)rPrr�r�r�rRr�rur(�inherit�Klass�_kwargs�	this_spec�not_callablerY�new_attrrrrHs                   r#�	__enter__z_patch.__enter__�so��"�h�h��	�	�4�=�=�8�T���=�=�$�+�+�&���(�(���k�k�m����5�=��D��u���H��u���H���� 4��=�>�>�
�
��!5��L�(��T�U�U��+�+�-���%��'�>�h�.��G��t�|����t�#�'�H��D��!��t�#�#�H��D��T�!�#����8�#7��w�&�#�$G�H�H��h��-�"�G��|�
�h� 7�!��!���G��'�$���!�X�%9� �	��'� (�I��I�&�#-�Y�#>�L�'/�	�':�#:�L� ��+�%�E�!�0�E���"&�����#�&.��
�#��5�$�'��5�/�2�t�~�~�"&�.�.�����N�N�6�"��"�'�"�C��,�S�1�!�	��'� (�I� ��+�&�y�1�0�E����F�#�#(�$4�S�D�$4�+2�$4�� �
�
!��'�!��(����7�"�� G�H�H��H�~�H��4��#�� ����-�&�+�D�N�N�+=�>�#�{�{�o�W�X�L��C�D�D�!��*�%�d�k�k�:�t�{�{�K��&�+�D�N�N�+=�]�"�o�&�#�{�{�o�W�X�L��C�D�D�
"�(�B�X�(,���B�:@�B�C�
��L�M�M���%�����
�%�/�/�1���	��D�K�K�����:��"�"�.��
��8�8�w�&�7:�J�t�2�2�3� $� 8� 8�/�H��*�*�8�8��B�C��|�|�w�.�"�)�)�#�.�/�"�!��J��	� �4�=�=�#�,�,�.�1��2�s�2BO�?O�O�$O<c���|jr>|jtur,t|j|j
|j�n�t
|j|j
�|jsYt|j|j
�r|j
dvr+t|j|j
|j�|`|`|`|j}|`	|j|�S)zUndo the patch.)r rr^�__annotations__r_)r.r-rr`r'rbrzr�r)r/r0)rPr2rs   r#r0z_patch.__exit__/s����=�=�T�/�/�w�>��D�K�K�����1C�1C�D��D�K�K����0��;�;�����T�^�^�(L����+=�=�����T�^�^�T�5G�5G�H����M��K��%�%�
���"�z�"�"�H�-�-r"c�\�|j�}|jj|�|S�z-Activate a patch, returning any created mock.)r9�_active_patchesr!�rPrvs  r#�startz_patch.startDs'�����!�����#�#�D�)��
r"c�~�	|jj|�|jddd�S#t$rYywxYw�zStop an active patch.N)r>r�rGr0r�s r#�stopz_patch.stopKsD��	�� � �'�'��-�
�}�}�T�4��.�.��	�	��	�s�0�	<�<)rrrrr>rArrDrr�contextmanagerrr	rr)r9r0r@rCr!r"r#r�r�sg���N��O�AF�"&�J
�,�����#��#��"�"�0P�d.�*�/r"r�c��	|jdd�\}}t	t
j|�|fS#tttf$rtd|����wxYw)Nr?r�z,Need a valid target to patch. You supplied: )�rsplitr�rGrEr�pkgutil�resolve_name)r'rbs  r#�_get_targetrIWsj��G�"�M�M�#�q�1���	��7�'�'��0�)�;�;��
�z�>�2�G��:�6�*�E�G�	G�G�s	�3�#Ar�c�v��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����Sr5r!�r's�r#rBz_patch_object.<locals>.<lambda>vs���V�r"r�)r7�strr�r�)r'rbrr�r�r�r�r�rrRr�s`          r#�
_patch_objectrN`sS���$�F�|�s����j�K�L�
�	
��F���	�3��f��(�L�&���r"c�~��t��turttj��}n�fd�}|std��t
|j��}|d\}	}
t||	|
|||||i�	}|	|_	|ddD]:\}	}
t||	|
|||||i�	}|	|_	|jj|��<|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����Sr5r!rLs�r#rBz!_patch_multiple.<locals>.<lambda>�s����r"z=Must supply at least one keyword argument with patch.multiplerr�N)r7rMrrGrHrGrfrEr�rr�r!)
r'r�r�r�r�r�rRr�rErbrr�this_patchers
`            r#�_patch_multiplerR}s����,�F�|�s����-�-�v�6������K�
�	
�
����� �E��1�X�N�I�s���	�3��f�h��,���G�'�G�����)�9��	�3���I�s�D�&�(��l�B�
��'0��#��#�#�*�*�<�8�
9��Nr"c�H�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�)rIr�)r'rr�r�r�r�r�rrRr�rbs           r#rr�s7��V$�F�+��F�I���	�3��f��(�L�&���r"c�T�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�_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.
    c��||_t|�|_|jj|�||_d|_yr5)�in_dict�dictr8r�clear�	_original)rPrWr8rYrRs     r#rAz_patch_dict.__init__s4������6�l��������6�"���
���r"c��t|t�r|j|�Stj|�r|j|�S|j
|�Sr5r)rP�fs  r#rDz_patch_dict.__call__&sM���a����&�&�q�)�)��&�&�q�)��/�/��2�2��%�%�a�(�(r"c�2���t����fd��}|S)Nc����j�	�|i|���j�S#�j�wxYwr5�rU�
_unpatch_dict�rQrsr\rPs  ��r#�_innerz-_patch_dict.decorate_callable.<locals>._inner/s8�������
%��$�~�"�~��"�"�$���"�"�$�s�+�=�r�rPr\rbs`` r#r	z_patch_dict.decorate_callable.� ���	�q��	%�
�	%��
r"c�2���t����fd��}|S)Nc���K��j�	�|i|���d{����j�S7�#�j�wxYw�wr5r_ras  ��r#rbz3_patch_dict.decorate_async_callable.<locals>._inner;sD���������
%���^��^�+��"�"�$�,���"�"�$�s%�A�7�5�7�A�7�A	�	Arcrds`` r#rz#_patch_dict.decorate_async_callable:rer"c��t|�D]{}t||�}|jtj�s�/t|d�s�<t
|j|j|j�}||�}t|||��}|Sr)r r*rVrrr)rUrWr8rYr`)rPr�r�r
�	decorator�	decorateds      r#rz_patch_dict.decorate_classFst����J�	0�D� ���-�J����� 1� 1�2���Z�0�'����d�k�k�4�:�:�N�	�%�j�1�	���t�Y�/�
	0��r"c�:�|j�|jS)zPatch the dict.)rUrWr�s r#r9z_patch_dict.__enter__Qs�������|�|�r"c��|j}t|jt�r$t	j
|j�|_|j}|j}	|j�}||_	|rt|�	|j|�y#t$ri}|D]
}||||<�Y�CwxYw#t$r|D]
}||||<�YywxYwr5)r8r(rWrMrGrHrYrrErZ�_clear_dictr)rPr8rWrYrurCs      r#rUz_patch_dict._patch_dictWs��������d�l�l�C�(�"�/�/����=�D�L��,�,���
�
��	-��|�|�~�H�"������ �	+��N�N�6�"���	-��H��
-�� '�����
�
-�		-���	+��
+��%�c�{����
+�	+�s$�$B�	B;�B8�7B8�;C�Cc��|j}|j}t|�	|j|�y#t$r|D]
}||||<�YywxYwr5)rWrZrmrrE)rPrWrurCs    r#r`z_patch_dict._unpatch_dictssX���,�,���>�>���G��	-��N�N�8�$���	-��
-��'��}����
-�	-�s�7�A�Ac�<�|j�|j�y)zUnpatch the dict.F)rZr`)rPrQs  r#r0z_patch_dict.__exit__�s���>�>�%���� �r"c�d�|j�}tjj|�|Sr=)r9r�r>r!r?s  r#r@z_patch_dict.start�s'�����!�����%�%�d�+��
r"c��	tjj|�|j	ddd�S#t$rYywxYwrB)r�r>r�rGr0r�s r#rCz_patch_dict.stop�sD��	��"�"�)�)�$�/�
�}�}�T�4��.�.��	�	��	�s�4�	A�AN)r!F)rrrr rArDr	rrr9rUr`r0r@rCr!r"r#rUrUs>���8�)�	�	���+�8
-���/r"rUc�n�	|j�y#t$rt|�}|D]}||=�YywxYwr5)rYrErf)rW�keysrCs   r#rmrm�s>����
�
������G�}���	�C����	��s��4�4c�`�ttj�D]}|j��y)z7Stop all active patches. LIFO to unroll nested patches.N)r[r�r>rC)rs r#�_patch_stopallru�s%���&�0�0�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|z���y�w)zi%sNr!�r��ns  r#r�r��s����7��5�1�9�7���c#�&K�|]	}d|z���y�w)zr%sNr!rys  r#r�r��s����5�q����5�r{>rh�__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|��i|��Sr5r!)rPrQrsr2s   �r#�methodz_get_method.<locals>.method�s����D�&�4�&�2�&�&r")r)rwr2r�s ` r#rvrv�s���'��F�O��Mr"r�>�	__aexit__�	__anext__�
__aenter__�	__aiter__>�__del__r�rAr��__prepare__rt�__instancecheck__�__subclasscheck__c�,�tj|�Sr5)rg�__hash__r�s r#rBrB�s��V�_�_�T�2�r"c�,�tj|�Sr5)rg�__str__r�s r#rBrB�s��F�N�N�4�0�r"c�,�tj|�Sr5)rg�
__sizeof__r�s r#rBrB�s��v�0�0��6�r"c�j�t|�j�d|j��dt|���S)N�/)r7rrar7r�s r#rBrB�s5��$�t�*�"5�"5�!6�a��8O�8O�8Q�7R�RS�TV�W[�T\�S]�^�r")r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__r0�__complex__�	__float__�__bool__�	__index__r�c����fd�}|S)Nc�Z���jj}|tur|S�|urytS�NT)�__eq__r�r�NotImplemented)�other�ret_valrPs  �r#r�z_get_eq.<locals>.__eq__s/����+�+�0�0���'�!��N��5�=���r"r!)rPr�s` r#�_get_eqr�s�����Mr"c����fd�}|S)Nc�^���jjturtS�|urytS�NF)�__ne__r�rr�)r�rPs �r#r�z_get_ne.<locals>.__ne__s*����;�;�)�)��8��N��5�=���r"r!)rPr�s` r#�_get_ner�s�����Mr"c����fd�}|S)Nc�l���jj}|turtg�St|�Sr5)�__iter__r�rr��r�rPs �r#r�z_get_iter.<locals>.__iter__s/����-�-�2�2���g����8�O��G�}�r"r!)rPr�s` r#�	_get_iterr�s�����Or"c����fd�}|S)Nc����jj}|turtt	g��Stt	|��Sr5)r�r�r�_AsyncIteratorr�r�s �r#r�z"_get_async_iter.<locals>.__aiter__$s8����.�.�3�3���g��!�$�r�(�+�+��d�7�m�,�,r"r!)rPr�s` r#�_get_async_iterr�#s���-�
�r")r�r�r�r�c���tj|t�}|tur||_ytj|�}|�||�}||_yt
j|�}|�||�|_yyr5)�_return_valuesrlrr��_calculate_return_value�_side_effect_methodsr�)r=r�rw�fixed�return_calculatorr��
side_effectors       r#�_set_return_valuer�4s{�����t�W�-�E��G��#����/�3�3�D�9���$�(��.��*����(�,�,�T�2�M�� �*�4�0���!r"c��eZdZd�Zd�Zy)�
MagicMixinc��|j�tt|�j|i|��|j�yr5)�_mock_set_magicsr�r�rA)rPrQrss   r#rAzMagicMixin.__init__Gs6������.��J��%�.�.��;��;����r"c	�z�ttz}|}t|dd��U|j|j�}t�}||z
}|D]&}|t
|�jvs�t||��(|tt
|�j�z
}t
|�}|D]}t||t||���y)Nr)�_magicsr�r*�intersectionrrir7rkrzr`�
MagicProxy)rP�orig_magics�these_magics�
remove_magicsrAr�s      r#r�zMagicMixin._mock_set_magicsMs���� 4�4��"���4��$�/�;�&�3�3�D�4F�4F�G�L��E�M�'�,�6�M�&�
)���D��J�/�/�/��D�%�(�
)�$�c�$�t�*�*=�*=�&>�>���T�
��!�	;�E��E�5�*�U�D�"9�:�	;r"N)rrrrAr�r!r"r#r�r�Fs�� �;r"r�c��eZdZdZdd�Zy)r
z-A version of `MagicMock` that isn't callable.c�H�|j||�|j�yr�rr�rs   r#rz"NonCallableMagicMock.mock_add_specg� ��	
���D�(�+����r"Nr��rrrr rr!r"r#r
r
es
��7� r"r
c��eZdZy)�AsyncMagicMixinN)rrrr!r"r#r�r�qs��r"r�c��eZdZdZdd�Zy)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`.
    c�H�|j||�|j�yrr�rs   r#rzMagicMock.mock_add_spec�r�r"Nr�r�r!r"r#rrus��	� r"rc� �eZdZd�Zd�Zdd�Zy)r�c� �||_||_yr5�rwr�)rPrwr�s   r#rAzMagicProxy.__init__�s����	���r"c��|j}|j}|j|||��}t|||�t	|||�|S)N)rwr�r�)rwr�r'r`r�)rPrAr��ms    r#�create_mockzMagicProxy.create_mock�sM���	�	�������"�"���/5�
#�
7�����q�!��&�!�U�+��r"Nc�"�|j�Sr5)r�)rPr.r�s   r#r}zMagicProxy.__get__�s�����!�!r"r5)rrrrAr�r}r!r"r#r�r��s����"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|j
d<d|j
d<d|j
d<t
�|j
d<tr7tt��}t|j
d<t|j
d<ntt��}tjtjztjz|_d|_d	|_d|_d|_||j
d
<d|j
d<t)�|j
d
<i|j
d<d|j
d<y)Nr�r�_mock_await_count�_mock_await_args�_mock_await_args_list�r�rr)rQrRr1r
rr^r_r;)�superrAr�r�r�rkr��	_CODE_SIGr�_CODE_ATTRSrr+�CO_COROUTINE�
CO_VARARGS�CO_VARKEYWORDS�co_flags�co_argcount�co_varnames�co_posonlyargcount�co_kwonlyargcountrg)rPrQrR�	code_mockr,s    �r#rAzAsyncMockMixin.__init__�s6��������$�)�&�)�*1�);�);�)I�)I��
�
�o�&�-.��
�
�)�*�,0��
�
�(�)�1:���
�
�-�.��'��=�I�08�I���}�-�4=�I���0�1�'��:�I�� � �� � �
!��$�$�
%�	��
!"�	�� 2�	��'(�	�$�&'�	�#�$-��
�
�j�!�$/��
�
�j�!�(-���
�
�n�%�*,��
�
�&�'�+/��
�
�'�(r"c��K�t||fd��}|xjdz
c_||_|jj	|�|j
}|�_t
|�r|�t|�s	t|�}t
|�r&|�t|�r||i|���d{���}n||i|��}|tur|S|jtur|jS|j�At|j�r|j|i|���d{���S|j|i|��S|jS#t$rt�wxYw7��7�7�w)NTr�r�)r�r�r�r�r!r�r:rdr��
StopIteration�StopAsyncIterationrrr�r�r)rPrQrRr�r�rvs      r#r�z!AsyncMockMixin._execute_mock_call�sT�����t�V�n�$�/�����A���������#�#�E�*��!�!�����V�$����v�&�-�!�&�\�F�
!��(� �L�$�V�,�%�t�6�v�6�6����0��0���W�$��
��"�"�'�1��$�$�$����'�"�4�#3�#3�4�-�T�-�-�t�>�v�>�>�>�#�4�#�#�T�4�V�4�4�� � � ��-%�-�-�,�-��7��?�s=�A-E�0D-�;#E�E�A+E�
E�"E�-D=�=E�Ec�`�|jdk(rd|jxsd�d�}t|��y)zA
        Assert that the mock was awaited at least once.
        r�	Expected r=z to have been awaited.N�r�r�r�r�s  r#r�zAsyncMockMixin.assert_awaited�s;�����q� ��d�o�o�7��8�8N�O�C� ��%�%�!r"c�z�|jdk(s,d|jxsd�d|j�d�}t|��y)z@
        Assert that the mock was awaited exactly once.
        r�r�r=�$ to have been awaited once. Awaited r�Nr�r�s  r#r�z"AsyncMockMixin.assert_awaited_once�sM�����1�$��t���8�&�9�:�#�/�/�0��9�C� ��%�%�%r"c�8�����j�!�j���}td|�d������fd�}�jt	��fd���}�j�j�}||k7r%t|t�r|nd}t|��|�y)zN
        Assert that the last await was with the specified arguments.
        NzExpected await: z
Not awaitedc�0���j��d��}|S)N�await)r�r�r�s ���r#r�z:AsyncMockMixin.assert_awaited_with.<locals>._error_message	s����3�3�D�&��3�Q�C��Jr"Tr�)r�r�r�r�r�r(r�)rPrQrRr�r�r�r�s```    r#r�z"AsyncMockMixin.assert_awaited_with	s�����?�?�"��7�7��f�E�H� �#3�H�:�]�!K�L�L�	��%�%�e�T�6�N��&E�F���#�#�D�O�O�4���X�� *�8�Y� ?�H�T�E� ��!1�2��=�r"c��|jdk(s,d|jxsd�d|j�d�}t|��|j|i|��S)zi
        Assert that the mock was awaited exactly once and with the specified
        arguments.
        r�r�r=r�r�)r�r�r�r�r�s    r#r�z'AsyncMockMixin.assert_awaited_once_with	s`��
���1�$��t���8�&�9�:�#�/�/�0��9�C� ��%�%�'�t�'�'��8��8�8r"c�"�|jt||fd���}t|t�r|nd}|jD�cgc]}|j|���}}|s
|t|�vr!|j
||�}td|z�|�ycc}w)zU
        Assert the mock has ever been awaited with the specified arguments.
        Tr�Nz%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�F��&�x��;����15�1E�1E�F�A�$�$�$�Q�'�F��F��H�L��$8�8�"�>�>�t�V�L�O� �$��6���
�9��Gr�c	�@��|D�cgc]}�j|���}}td�|D�d�}t�fd��jD��}|sb||vr]|�d}n1dj	|D�cgc]}t|t�r|nd��c}�}t|�dt|��d�j���|�yt|�}g}	|D]}
	|j|
��|	rtt|	��d��|�ycc}wcc}w#t$r|	j|
�Y�XwxYw)	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`.
        c3�BK�|]}t|t�s�|���y�wr5r�r�s  r#r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>:	r�r�Nc3�@�K�|]}�j|����y�wr5r�r�s  �r#r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>;	s�����S��t�1�1�!�4�S�r�zAwaits not found.z,Error processing expected awaits.
Errors: {}r�z	
Actual: z not all found in await list)
r�r�r�r�r�r(r�r�rfr�rGr!rg)rPr�r�r�r�r��
all_awaitsr�rpr�r�s`          r#r�z AsyncMockMixin.assert_has_awaits-	s[���49�9�a�D�&�&�q�)�9��9��F��F��M���S�d�>R�>R�S�S�
���z�)��=�1�G� ,�-3�V�-5�$7�()�*4�A�y�)A�A�t�$K�$7�.8��%��i� !�!*�5�!1� 2�3�#�3�3�4�6���	�

��*�%�
��	��	'�D�
'��!�!�$�'�	'�
� �49�)�4D�F���
���7:��$7���
'�� � ��&�
'�s�C6�+C;�D�D�Dc�z�|jdk7r,d|jxsd�d|j�d�}t|��y)z9
        Assert that the mock was never awaited.
        rr�r=z# to not have been awaited. Awaited r�Nr�r�s  r#r�z!AsyncMockMixin.assert_not_awaitedY	sM�����q� ��t���8�&�9�:�#�/�/�0��9�C� ��%�%�!r"c�t��t�j|i|��d|_d|_t	�|_y)z0
        See :func:`.Mock.reset_mock()`
        rN)r�r�r�r�r�r�)rPrQrRr,s   �r#r�zAsyncMockMixin.reset_mockb	s5���	�����D�+�F�+�������(�{��r"r�)rrrr�r�r�r�rAr�r�r�r�r�r�r�r�r��
__classcell__)r,s@r#r�r��s\���&�}�5�K�%�l�3�J�*�+<�=�O�0�B&!�P&�&�>�$	9��*�X&�+�+r"r�c��eZdZdZy)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
l	s��'r"r
c�"�eZdZdZd�Zd�Zd�Zy)�_ANYz2A helper object that compares equal to everything.c��yr�r!�rPr�s  r#r�z_ANY.__eq__�	s��r"c��yr�r!rs  r#r�z_ANY.__ne__�	s��r"c��y)Nz<ANY>r!r�s r#r�z
_ANY.__repr__�	s��r"N)rrrr r�r�r�r!r"r#r
r
�	s��8���r"r
c	��d|z}d}dj|D�cgc]
}t|���c}�}dj|j�D��cgc]\}}|�d|����c}}�}	|r|}|	r|r|dz
}||	z
}||zScc}wcc}}w)Nz%s(%%s)rz, �=)r\�reprrE)
rwrQrRr��formatted_argsrH�args_stringrCr��
kwargs_strings
          r#r~r~�	s����$��G��N��)�)�$�7�3�T�#�Y�7�8�K��I�I�17�����#-�3��3�����M��$�����d�"�N��-�'���^�#�#��8��s�A>�B
c��eZdZdZ		dd�Z		dd�Zd�ZejZd�Z	d�Z
d�Zd	�Ze
d
��Ze
d��Zd�Zd
�Zy)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.
    Nc�n�d}i}t|�}|dk(r|\}}}nh|dk(r2|\}	}
t|	t�r|	}t|
t�r|
}n9|
}n6|	|
}}n1|dk(r,|\}t|t�r|}nt|t�r|}n|}|rtj	|||f�Stj	||||f�S)Nr!�r�r�)r�r(rMrgr�)r�r�rwr�r��	from_kallrQrR�_len�first�seconds           r#r�z
_Call.__new__�	s��������5�z���1�9�!&��D�$��
�Q�Y�!�M�E�6��%��%����f�e�,�!�D�#�F�$�f�f��
�Q�Y��F�E��%��%����E�5�)�������=�=��t�V�n�5�5��}�}�S�4��v�"6�7�7r"c�.�||_||_||_yr5)r�r��_mock_from_kall)rPr�rwr�r�rs      r#rAz_Call.__init__�	s�����"���(��r"c�"�	t|�}d}t|�dk(r|\}}n|\}}}t|dd�r't|dd�r|j|jk7ryd}|dk(rdi}}n�|dk(r|\}}}nv|dk(r5|\}	t|	t�r|	}i}nXt|	t�r|	}di}}nAd}|	}n<|dk(r6|\}
}t|
t�r|
}t|t�r|i}}nd|}}n|
|}}ny|r||k7ry||f||fk(S#t$r	tcYSwxYw)	Nrr�r�Frr!rr�)r�r�r�r*r�r(rgrM)rPr��	len_other�	self_name�	self_args�self_kwargs�
other_name�
other_args�other_kwargsr�rrs            r#r�z_Call.__eq__�	sV��	"��E�
�I��	��t�9��>�%)�"�I�{�04�-�I�y�+��D�.�$�/�G�E�>�SW�4X��%�%��);�);�;���
���>�')�2��J�
�!�^�38�0�J�
�L�
�!�^��F�E��%��'�"�
�!���E�3�'�"�
�+-�r�L�
��
�$��
�!�^�!�M�E�6��%��%�"�
��f�e�,�/5�r��J�/1�6��J�+0�&�L�
����y�0���L�)�i��-E�E�E��_�	"�!�!�	"�s�C<�<D�
Dc��|j�td||fd��S|jdz}t|j||f||��S)Nrr%r�r��r�r�rs    r#rDz_Call.__call__+
sH���?�?�"��"�d�F�+�$�7�7�����%���d�o�o�t�V�4�4��M�Mr"c�r�|j�
t|d��S|j�d|��}t||d��S)NF)rwrr?)rwr�rr')rPr�rws   r#r�z_Call.__getattr__3
s6���?�?�"��d�e�4�4��/�/�4�0���$�t�u�=�=r"c�^�|tjvrt�tj||�Sr5)rgrkrE�__getattribute__)rPr�s  r#r*z_Call.__getattribute__:
s'���5�>�>�!� � ��%�%�d�D�1�1r"c�D�t|�dk(r	|\}}||fS|\}}}||fS)Nr�)r�rs    r#�_get_call_argumentsz_Call._get_call_arguments@
s:���t�9��>��L�D�&��V�|��"&��D�$���V�|�r"c�(�|j�dS�Nr�r,r�s r#rQz
_Call.argsH
����'�'�)�!�,�,r"c�(�|j�dS)Nr�r/r�s r#rRz_Call.kwargsL
r0r"c��|js(|jxsd}|jd�rd|z}|St|�dk(rd}|\}}n'|\}}}|sd}n|jd�sd|z}nd|z}t	|||�S)Nrr%zcall%sr�zcall.%s)rr�rVr�r~)rPrwrQrRs    r#r�z_Call.__repr__P
s����#�#��?�?�,�f�D����t�$��$����K��t�9��>��D��L�D�&�!%��D�$������_�_�T�*� �4�'���$���%�d�D�&�9�9r"c��g}|}|�,|jr|j|�|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.)rr!r�r�r[)rP�vals�things   r#�	call_listz_Call.call_liste
sM���������$�$����E�"��&�&�E�����$��(�(r")r!rNFT)r!NNFT)rrrr r�rAr�rgr�rDr�r*r,r�rQrRr�r6r!r"r#r�r��	s|���$:?��8�@>C��)�2F�j�]�]�F�N�>�2���-��-��-��-�:�*
)r"r�)rc	�^�t|�rt|�}t|t�}t|�rt	d|�d���t|�}d|i}	|rd|i}	n|�i}	|	r|rd|	d<|st
|�|	j|�t}
tj|�ri}	n=|r|rtd��t}
n't|�st}
n|r|rt|�st}
|	j!d|�}|}|�d	}|
d||||d
�|	��}t|t"�rt%||�}|rt'|�nt)||||�|�|s||j*|<|j-d�}
|r|sd|vrt/||dd
||
��|_t3|�D�]}t5|�r�	t7||�}d|i}|
rt;|
|�r|j|��|rd|i}t|t"�st=|||||�}||j*|<n~|}t|t"�r|j>}tA|||�}||d<tC|�rt}nt}|d||||d�|��}||j*|<|�|_t)|||��t|t"�s��tE|||���|S#t8$rY��$wxYw)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=rr�r�TrzJInstance can not be True when create_autospec is mocking an async functionrwr)r�r�r�rwrr�r%)rZr+r�rrcr)r�rwr�r�)rYr!)#rhr7r(r'rr3r�rrr+�isdatadescriptorr�r
rdr
rnrGr>rzr�r[r�rlr	r�r r�r*rEr)r9r=�
_must_skiprr`)r�r�rZr�r+rrR�is_type�
is_async_funcr5r4r�r=�wrappedrArurr�rY�child_klasss                    r#r	r	u
s���.��~��D�z����t�$�G�����"*�*.��� 4�5�	5�"�4�(�M��t�n�G���t�$��	
�����8�'+��#�$���f�%��N�N�6���E�����%���	��� >�?�
?���
�t�_�$��	�X�&8��&>�$���K�K���&�E��I����	��(��W�	��(�&�(�D��$�
�&��d�D�)����d�#���t�W�h�7���8�(,����u�%��j�j��!�G��x�N�&�$@�+�D�(�T�26��29�;����T��4&���U���	��t�U�+�H��(�#���w�w��.��M�M��M�)�� �(�+�F��(�M�2��X�x��u�h�G�C�),�D����&��F��$�
�.�����"�4���8�I�"+�F�;��"�8�,�'��'���(�V�%�5�*0�(� &�(�C�*-�D����&�*�}�C���X�s�i�@��c�=�)��D�%��%�i4&�l�K��M�	��	�s�J�	J,�+J,c�,�t|t�s|t|di�vry|j}|jD]X}|j
j
|t�}|tur�,t|ttf�ryt|t�r|cSy|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    rkF)r(r7r*r,rjrkrlrrCrBr>)r�rAr:r�rvs     r#r9r9s���
�d�D�!��G�D�*�b�1�1���~�~����������#�#�E�7�3���W����f�|�[�9�:��
��
�
.��N����Nr"c��eZdZ		dd�Zy)r9Nc�X�||_||_||_||_||_||_yr5)r��idsr�r�rZrw)rPr�r�r�rwrArZs       r#rAz_SpecState.__init__&s,����	���� ��
���� ��
���	r")FNNNF)rrrrAr!r"r#r9r9$s
��48�/4�r"r9c�v�t|t�rtj|�Stj|�Sr5)r(�bytes�io�BytesIO�StringIO)�	read_datas r#�
_to_streamrH<s*���)�U�#��z�z�)�$�$��{�{�9�%�%r"c	�d���	�
��t��}|dg�
�
�fd�}�
�fd�}��
fd��	�
�fd���
�fd�}t�Vddl}tt	t|j��jt	t|j����at�+ddl}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����jj��jjS�dj|i|��Sr.)�	readlinesr��rQrR�_state�handles  ��r#�_readlines_side_effectz)mock_open.<locals>._readlines_side_effectRsC������(�(�4��#�#�0�0�0�"�v�a�y�"�"�D�3�F�3�3r"c����jj��jjS�dj|i|��Sr.)�readr�rLs  ��r#�_read_side_effectz$mock_open.<locals>._read_side_effectWs=����;�;�#�#�/��;�;�+�+�+��v�a�y�~�~�t�.�v�.�.r"c?�`�K���Ed{���	�dj|i|�����7��wr.)�readline)rQrR�_iter_side_effectrMs  ��r#�_readline_side_effectz(mock_open.<locals>._readline_side_effect\s<�����$�&�&�&��$�&��)�$�$�d�5�f�5�5��	'�s�.�,�.c3��K��jj�	�jj����dD]}|���y�wr.)rTr�)�linerMrNs ��r#rUz$mock_open.<locals>._iter_side_effectasG������?�?�'�'�3���o�o�2�2�2���1�I�	�D��J�	�s�AAc�x���jj��jjSt�d�Sr.)rTr�r�)rMrNs��r#�_next_side_effectz$mock_open.<locals>._next_side_effecths1����?�?�'�'�3��?�?�/�/�/��F�1�I��r"r�open)rwr�)r�r�c���t���d<�jj�dk(r���d<�d�j_tS)Nrr�)rHrTr�r)rQrRrVrMrNrGs  ����r#�
reset_datazmock_open.<locals>.reset_data�sH����y�)��q�	��?�?�&�&�&��)�3�-�/�F�1�I�*0��)�F�O�O�'��r")rH�	file_spec�_iorfrir �
TextIOWrapper�unionrE�	open_specr[rr9r��writerQrTrKr�r�r�)r=rG�
_read_datarOrRrZr_r]rUrVrMrNs `      @@@@r#rrCsW����I�&�J��$�
�F�4�
/�
6�
�������S��!2�!2�3�4�:�:�3�s�3�;�;�?O�;P�Q�R�	������S����]�+�,�	��|��f�9�5��
�I�
&�F�$*�F���!� $�F�L�L��#�F�K�K��#'�F�O�O� �$(�F���!�/�F�K�K��%�'�F�1�I�"(��)�F�O�O��#9�F��� �"3�F�O�O��"3�F�O�O���"�D���D���Kr"c�$�eZdZdZd�Zdd�Zd�Zy)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)rPrRs  r#r'zPropertyMock._get_child_mock�s���"�6�"�"r"Nc��|�Sr5r!)rPr.�obj_types   r#r}zPropertyMock.__get__�s	���v�
r"c��||�yr5r!)rPr.rIs   r#r~zPropertyMock.__set__�s	���S�	r"r5)rrrr r'r}r~r!r"r#rr�s���#��r"rc��d|_t|�D]d}	t||�}t	|t
�s�!t	|jj|�t�r�K|j|us�Zt|��fy#t$rY�swxYw)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)rr r*rEr(rr�rlr9r�r)r=r�r�s   r#rr�s����D���D�	�
��	���d�#�A��!�_�-���a�&�&�*�*�4�0�*�=������%���G�
���	��	�s�A;�;	B�Bc��eZdZdZd�Zd�Zy)r�z8
    Wraps an iterator in an asynchronous iterator.
    c�z�||_tt��}tj|_||jd<y)Nr�r1)�iteratorrrr+�CO_ITERABLE_COROUTINEr�rk)rPrmr�s   r#rAz_AsyncIterator.__init__�s/�� ��
�#�X�6�	�$�:�:�	��$-��
�
�j�!r"c��^K�	t|j�S#t$rYt�wxYw�wr5)r�rmr�r�r�s r#r�z_AsyncIterator.__anext__�s1����	���
�
�&�&���	�� � �	�s�-��-�	*�-�*�-N)rrrr rAr�r!r"r#r�r��s���.�!r"r�r�)NFNNN)FFNN)Nr)��__all__r�rrDr+r�r1�builtinsrGr�typesrrr�
unittest.utilr�	functoolsrr�	threadingrr�rr rVr&rr�r�r/r3r'r:r?rKr[rVrdrhrnrzrtr�r�rgr�r�rr�MISSINGr{�DELETEDr:r�r�rfr�r�r�r�r�	frozenset�removeprefixrWr�r3r�rr�r�rIrNrRrrUrmrurX�multiple�stopallr�
magic_methods�numericsr\rF�inplace�right�
_non_defaultsrvr�r��_sync_async_magics�
_async_magicsr�rUrur�r�r�r�r�r�r�r�r�r�r
r�rr�rFrAr�r�rGr�r
r
rr~rgr�rr	r9r9r7r�r>r^rbrHrrrr�)rwr�s00r#�<module>r�s����&��	��
�
���'�2�2�#�$��C�y�C�"�(�m�H�d�4�?�?�3�3G�T�H�	�
�
���@��2��� �F	#�
��&���6."�b>�6)�	)�f�	)�����;��
�
�
������������ �&*��*�(�6���
�6�
�S
<�d�S
<�n��O�$������y�!�	���i� ����
�4�
� �g!�D�g!�V8�=�/�8�z�L/�V�L/�`
<� '�T��t�d���&+��:?C�04�.�d�$�u���4�O�CH�O�dV/�&�V/�r�����
��
� �����
����
��"K�	��(�(�7�h�n�n�&6�7�
7�����5�H�N�N�$4�5�5���
���H�H�m�X�w��
6�7�=�=�?�� �H�v����@��!�]��$�'9�9�
��]�*����.����3�0�6�^�	�����������������"������� �	��1�$;��;�>	 �:��	 �	�j�	� �
�D� �,"��"�$�!��!�!�'�(�*;�*;�T�"B�C�I��h�-�K�
E+�T�E+�P(����(�V
�6�
��f��$�$v)�E�v)�r
�u���CG��P�*/�P�f�8	��	�	��������	�
�
�	��	�&�O�d�4��$�0!�!��e\
I��F ��R��N���I��s*�N;�3N;�0)O�&O�:+O
�
O�O

Zerion Mini Shell 1.0