OwlCyberSecurity - MANAGER
Edit File: mock.cpython-38.pyc
U ����e5d����������������������@���s���d�Z�dZddlZddlZddlZddlZddlZddlZddlZddl m Z mZmZ�ddl mZ�ddlmZmZ�dd��ee�D��Zd ZeZd d��Zdd ��Zdd��Zdd��Zdd��Zdd��Zd�dd�Zdd��Zdd��Zdd��Z dd ��Z!d�d!d"�Z"d#d$��Z#d%d&��Z$d'd(��Z%G�d)d*��d*e&�Z'G�d+d,��d,e&�Z(e(��Z)e)j*Z*e)j+Z,e)j-Z.d-d.d/d0d1d2d3d4hZ/d5d6��Z0G�d7d8��d8e1�Z2d9d:��Z3G�d;d<��d<e&�Z4G�d=d>��d>e&�Z5G�d?d@��d@e5�Z6dAdB��Z7G�dCdD��dDe5�Z8G�dEdF��dFe8e6�Z9dGdH��Z:dIdJ��Z;G�dKdL��dLe&�Z<dMdN��Z=e*dddddfdOdP�Z>d�dQdR�Z?e*dddddfdSdT�Z@G�dUdV��dVe&�ZAdWdX��ZBdYdZ��ZCe>e@_&eAe@_De?e@_EeCe@_Fd[e@_Gd\ZHd]ZId^�Jd_d`��eI�K��D���ZLd^�Jdad`��eI�K��D���ZMdbdcdddedfdgdhdidjdkdldmdndodpdqdrdshZNdtdu��ZOdvd��d^�JeHeIeLeMg��K��D��ZPdwdxdyhZQdzhZReQeRB�ZSePeNB�ZTeTeSB�ZUd{d|d}d~dd�d�d�hZVd�d���d�d���d�d���d�d���d��ZWeXeXeXeXd�dddd�d�d d�dd�� ZYd�d���ZZd�d���Z[d�d���Z\d�d���Z]eZe[e\e]d��Z^d�d���Z_G�d�d���d�e5�Z`G�d�d���d�e`e6�ZaG�d�d���d�e`�ZbG�d�d���d�e`e9�ZcG�d�d���d�e5�ZdG�d�d���d�e5�ZeG�d�d���d�eeebe9�ZfG�d�d���d�e&�Zgeg��Zhd�d���ZiG�d�d���d�ej�Zkekdd��Zld�d�d��Zmd�d���ZnG�d�d���d�e&�Zoepem�epehjq�fZrdasd�d���Ztd�d�d��ZuG�d�d���d�e9�Zvd�d���ZwG�d�d���d��ZxdS�)�)�Mock� MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec� AsyncMock� FILTER_DIR�NonCallableMock�NonCallableMagicMock� mock_open�PropertyMock�sealz1.0�����N)�CodeType� ModuleType� MethodType)� safe_repr)�wraps�partialc�����������������C���s���h�|�]}|��d��s|�qS���_�� startswith)�.0�name��r����%/usr/lib64/python3.8/unittest/mock.py� <setcomp>(���s����� �r���Tc�����������������C���s>���t�|��rt|�t�sdS�t|�d�r*t|�d�}�t�|��p<t�|��S�)NF�__func__) �_is_instance_mock� isinstancer ����hasattr�getattr�asyncio�iscoroutinefunction�inspectZisawaitable��objr���r���r���� _is_async_obj0���s ���� r*���c�����������������C���s���t�|�dd��rt�|��S�dS�d�S�)N�__code__F)r$���r%���r&�����funcr���r���r����_is_async_func8���s���� r.���c�����������������C���s���t�t|��t�S��N)� issubclass�typer���r(���r���r���r���r!���?���s����r!���c�����������������C���s���t�|�t�pt�|�t�ot|�t�S�r/���)r"���� BaseExceptionr1���r0���r(���r���r���r���� _is_exceptionE���s���� �r3���c�����������������C���s"���t�|�t�rt|�d�r|�jS�|�S�d�S��N�mock)r"���� FunctionTypesr#���r5���r(���r���r���r���� _extract_mockL���s����r7���c�����������������C���s����t�|�t�r|s|�j}�d}n,t�|�t�sFz |�j}�W�n�tk rD���Y�dS�X�|rVt|�d�}n|�}z|�t�|�fW�S��t k r����Y�dS�X�dS�)z� Given an arbitrary, possibly callable object, try to create a suitable signature object. Return a (reduced func, signature) tuple, or None. TN) r"���r1����__init__r6����__call__�AttributeErrorr���r'���� signature� ValueError)r-���Zas_instanceZeat_selfZsig_funcr���r���r����_get_signature_objectU���s���� r=���Fc��������������������sN���t�|�||�����d�krd�S���\}�����fdd�}t|�|��|t|�_��t|�_d�S�)Nc�������������������s�����j�||��d�S�r/�����bind��self�args�kwargs��sigr���r����checksigw���s����z"_check_signature.<locals>.checksig)r=����_copy_func_detailsr1����_mock_check_sig� __signature__)r-���r5���� skipfirst�instancerF���r���rD���r����_check_signaturer���s���� rL���c�������������� ���C���s:���dD�]0}zt�||t|�|���W�q�tk r2���Y�qX�qd�S�)N)�__name__�__doc__�__text_signature__� __module__�__defaults__�__kwdefaults__)�setattrr$���r:���)r-����funcopy� attributer���r���r���rG���~���s ����rG���c�����������������C���s@���t�|�t�rdS�t�|�tttf�r(t|�j�S�t|�dd��d�k r<dS�dS�)NTr9���F)r"���r1����staticmethod�classmethodr���� _callabler ���r$���r(���r���r���r���rX�������s���� rX���c�����������������C���s���t�|��ttfkS�r/���)r1����list�tupler(���r���r���r����_is_list����s����r[���c�����������������C���sF���t�|�t�st|�dd�dk S�|�f|�j�D�]}|j�d�dk r&�dS�q&dS�)ztGiven an object, return True if the object is callable. For classes, return True if instances would be callable.r9���NTF)r"���r1���r$����__mro__�__dict__�get)r)����baser���r���r����_instance_callable����s���� r`���c��������������������s����t�|t�}t|||�}|d�kr"|�S�|\}����fdd�}t||��|j}|���sRd}||�d�}d|�} t| |��||�} t| |�����| S�)Nc���������������������s�����j�|�|��d�S�r/���r>����rB���rC���rD���r���r���rF�������s����z _set_signature.<locals>.checksigrT���)Z _checksig_r5���zYdef %s(*args, **kwargs): _checksig_(*args, **kwargs) return mock(*args, **kwargs))r"���r1���r=���rG���rM����isidentifier�exec�_setup_func)r5����originalrK���rJ����resultr-���rF���r����context�srcrT���r���rD���r����_set_signature����s$���� � ri���c��������������������s�������_��fdd�}�fdd�}�fdd�}�fdd�}�fd d �}�fdd�}�fd d�} ���fdd�} d��_d��_d���_t����_t����_t����_�j��_�j ��_ �j ��_ |��_|��_|��_ | ��_| ��_|��_|��_|��_|��_���_d�S�)Nc���������������������s�����j�|�|�S�r/���)�assert_called_withra����r5���r���r���rj�������s����z'_setup_func.<locals>.assert_called_withc���������������������s�����j�|�|�S�r/���)� assert_calledra���rk���r���r���rl�������s����z"_setup_func.<locals>.assert_calledc���������������������s�����j�|�|�S�r/���)�assert_not_calledra���rk���r���r���rm�������s����z&_setup_func.<locals>.assert_not_calledc���������������������s�����j�|�|�S�r/���)�assert_called_oncera���rk���r���r���rn�������s����z'_setup_func.<locals>.assert_called_oncec���������������������s�����j�|�|�S�r/���)�assert_called_once_withra���rk���r���r���ro�������s����z,_setup_func.<locals>.assert_called_once_withc���������������������s�����j�|�|�S�r/���)�assert_has_callsra���rk���r���r���rp�������s����z%_setup_func.<locals>.assert_has_callsc���������������������s�����j�|�|�S�r/���)�assert_any_callra���rk���r���r���rq�������s����z$_setup_func.<locals>.assert_any_callc���������������������s:���t�����_t�����_�������j}�t|��r6|��k r6|�����d�S�r/���)� _CallList�method_calls� mock_calls� reset_mock�return_valuer!���)�ret�rT���r5���r���r���ru�������s����z_setup_func.<locals>.reset_mockFr���)r5����called� call_count� call_argsrr����call_args_listrs���rt���rv����side_effect�_mock_childrenrj���ro���rp���rq���ru���rl���rm���rn���rI����_mock_delegate)rT���r5���rE���rj���rl���rm���rn���ro���rp���rq���ru���r���rx���r���rd�������s8����rd���c��������������������sJ���t�jj��_d��_d���_t����_��fdd�}dD�]}t��|t||���q.d�S�)Nr���c�������������������s���t���j|��||�S�r/���)r$���r5���)�attrrB���rC���rk���r���r����wrapper����s����z"_setup_async_mock.<locals>.wrapper)�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited) r%���� coroutines� _is_coroutine�await_count� await_argsrr����await_args_listrS���r���)r5���r����rU���r���rk���r����_setup_async_mock����s���� r����c�����������������C���s���d|�dd���|�kS�)N�__%s__�������r����r���r���r���r���� _is_magic��s����r����c�������������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) �_SentinelObjectz!A unique, named, sentinel object.c�����������������C���s ���||�_�d�S�r/���r�����rA���r���r���r���r���r8�����s����z_SentinelObject.__init__c�����������������C���s ���d|�j��S��Nzsentinel.%sr�����rA���r���r���r����__repr__��s����z_SentinelObject.__repr__c�����������������C���s ���d|�j��S�r����r����r����r���r���r���� __reduce__��s����z_SentinelObject.__reduce__N)rM���rP����__qualname__rN���r8���r����r����r���r���r���r���r������s���r����c�������������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) � _SentinelzAAccess attributes to return a named object, usable as a sentinel.c�����������������C���s ���i�|�_�d�S�r/���)� _sentinelsr����r���r���r���r8���#��s����z_Sentinel.__init__c�����������������C���s���|dkrt��|�j�|t|��S�)N� __bases__)r:���r����� setdefaultr����r����r���r���r����__getattr__&��s����z_Sentinel.__getattr__c�����������������C���s���dS�)Nr���r���r����r���r���r���r����,��s����z_Sentinel.__reduce__N)rM���rP���r����rN���r8���r����r����r���r���r���r���r����!��s���r����rv����_mock_return_valuer}����_mock_side_effect�_mock_parent�_mock_new_parent� _mock_name�_mock_new_namec�����������������C���s8���t��|���d|��}|�|fdd�}|�|fdd�}t||�S�)NZ_mock_c�����������������S���s"���|�j�}|d�krt|�|�S�t||�S�r/���)r���r$���)rA���r���� _the_namerE���r���r���r����_getA��s���� z"_delegating_property.<locals>._getc�����������������S���s*���|�j�}|d�kr||�j|<�nt|||��d�S�r/���)r���r]���rS���)rA����valuer���r����rE���r���r���r����_setF��s����z"_delegating_property.<locals>._set)�_allowed_names�add�property)r���r����r����r����r���r���r����_delegating_property>��s ���� r����c�������������������@���s���e�Zd�Zdd��Zdd��ZdS�)rr���c�����������������C���sl���t�|t�st�|�|�S�t|�}t|��}||kr2dS�td||�d��D�]"}|�|||���}||krD�dS�qDdS�)NFr�������T)r"���rY����__contains__�len�range)rA���r����Z len_valueZlen_self�iZsub_listr���r���r���r����S��s���� z_CallList.__contains__c�����������������C���s���t��t|���S�r/���)�pprintZpformatrY���r����r���r���r���r����a��s����z_CallList.__repr__N)rM���rP���r����r����r����r���r���r���r���rr���Q��s���rr���c�����������������C���s|���t�|�}t|�sdS�|js4|js4|jd�k s4|jd�k r8dS�|�}|d�k rX||krPdS�|j}q<|rh|�|_||_|rx|�|_||_dS�)NFT)r7���r!���r����r����r����r����)�parentr����r����new_name�_parentr���r���r����_check_and_set_parente��s*������r����c�������������������@���s���e�Zd�Zdd��Zdd��ZdS�)� _MockIterc�����������������C���s���t�|�|�_d�S�r/���)�iterr)���)rA���r)���r���r���r���r8������s����z_MockIter.__init__c�����������������C���s ���t�|�j�S�r/���)�nextr)���r����r���r���r����__next__���s����z_MockIter.__next__N)rM���rP���r����r8���r����r���r���r���r���r�������s���r����c�������������������@���s���e�Zd�ZeZdZdd��ZdS�)�BaseNc����������������O���s���d�S�r/���r���r@���r���r���r���r8������s����z Base.__init__)rM���rP���r����r���r����r����r8���r���r���r���r���r�������s���r����c�������������������@���sd��e�Zd�ZdZdd��ZdLdd�Zd d ��ZdMdd�ZdNd d�Zdd��Z dd��Z dZee e e�Z edd���Zed�Zed�Zed�Zed�Zed�Zdd��Zdd��Zeee�ZdOddd�d d!�Zd"d#��Zd$d%��Zd&d'��Zd(d)��Zd*d+��Zd,d-��Zd.d/��Zd0d1��Z dPd3d4�Z!d5d6��Z"d7d8��Z#d9d:��Z$d;d<��Z%d=d>��Z&d?d@��Z'dAdB��Z(dQdCdD�Z)dEdF��Z*dGdH��Z+dRdJdK�Z,dS�)Sr���z A non-callable version of `Mock`c���������� ������O���s����|�f}t�|�t�s^t�tj�}|j|�f|�|�j}dd��|���D��}|r^t ||d���r^t |�f}t|�j|d|�j i�}tt|���|�}|S�)Nc�����������������S���s���g�|�]}|��d��r|�qS���specr����r����argr���r���r���� <listcomp>���s��� �z+NonCallableMock.__new__.<locals>.<listcomp>r���rN���)r0���r ���r'���r;���r���r8���Zbind_partialZ arguments�keysr*����AsyncMockMixinr1���rM���rN����_safe_super�__new__) �clsrB����kw�basesrE���Z bound_argsZspec_arg�newrK���r���r���r���r�������s���� �zNonCallableMock.__new__N��Fc�����������������K���s����|d�kr|}|�j�} || d<�|| d<�|| d<�|| d<�d| d<�|d�k rJ|}d}| d�krZ|d�k } |��||| | ��i�| d<�|| d <�d�| d <�d| d<�d�| d<�d | d<�t��| d<�t��| d<�t��| d<�|| d<�|r�|�jf�|��tt|���||||||��d�S�)Nr����r����r����r����F�_mock_sealedTr~����_mock_wrapsr���Z_mock_calledZ_mock_call_argsr���Z_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrs����_mock_unsafe)r]����_mock_add_specrr����configure_mockr����r���r8���)rA���r����r���r����spec_setr�����_spec_state� _new_name�_new_parent�_spec_as_instance� _eat_selfZunsaferC���r]���r���r���r���r8������sD���� �����zNonCallableMock.__init__c�����������������C���s0���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����)r7���r����r����r����r����rS���)rA���r5���rU���Z inner_mockr���r���r����attach_mock���s����zNonCallableMock.attach_mockc�����������������C���s���|���||��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�����rA���r����r����r���r���r���� mock_add_spec���s����zNonCallableMock.mock_add_specc�����������������C���s����d�}d�}g�}t�|�D�] }t�t||d���r|�|��q|d�k r~t|�s~t|t�rV|}nt|�}t|||�} | ot| d�}t�|�}|�j } || d<�|| d<�|| d<�|| d<�|| d<�d�S�)Nr�����_spec_class� _spec_set�_spec_signature� _mock_methods�_spec_asyncs) �dirr%���r&���r$����appendr[���r"���r1���r=���r]���)rA���r����r����r����r����r����r����r����r�����resr]���r���r���r���r�������s,���� ��zNonCallableMock._mock_add_specc�����������������C���s8���|�j�}|�jd�k r|�jj}|tkr4|�j|�dd�}||�_|S�)N�()�r����r����)r����r���rv���r����_get_child_mock)rA���rw���r���r���r���Z__get_return_value��s���� ��z"NonCallableMock.__get_return_valuec�����������������C���s,���|�j�d�k r||�j�_n||�_t|�|d�d��d�S�)Nr����)r���rv���r����r����)rA���r����r���r���r���Z__set_return_value��s���� z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.c�����������������C���s���|�j�d�krt|��S�|�j�S�r/���)r����r1���r����r���r���r���� __class__!��s���� zNonCallableMock.__class__ry���rz���r{���r|���rt���c�����������������C���sN���|�j�}|d�kr|�jS�|j}|d�k rJt|�sJt|t�sJt|�sJt|�}||_|S�r/���)r���r����r}����callabler"���r����r3���)rA���� delegatedZsfr���r���r���Z__get_side_effect.��s������z!NonCallableMock.__get_side_effectc�����������������C���s(���t�|�}|�j}|d�kr||�_n||_d�S�r/���)� _try_iterr���r����r}���)rA���r����r����r���r���r���Z__set_side_effect9��s ����z!NonCallableMock.__set_side_effect)rv���r}���c����������������C���s����|dkrg�}t�|��|krdS�|�t�|����d|�_d|�_d|�_t��|�_t��|�_t��|�_|r^t |�_ |rhd|�_|�j� ��D�]"}t|t�sr|tkr�qr|�|��qr|�j }t|�r�||�k r�|�|��dS�)z-Restore the mock object to its initial state.NFr���)�idr����ry���r{���rz���rr���rt���r|���rs���r���r����r����r~����valuesr"���� _SpecState�_deletedru���r!���)rA���Zvisitedrv���r}����childrw���r���r���r���ru���D��s,����zNonCallableMock.reset_mockc����������������K���sX���t�|���dd��d�D�]>\}}|�d�}|���}|�}|D�]}t||�}q6t|||��qdS�)aZ��Set 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�����������������S���s���|�d���d�S�)Nr����.)�count)�entryr���r���r����<lambda>o�������z0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr����N)�sorted�items�split�popr$���rS���)rA���rC���r�����valrB����finalr)���r����r���r���r���r����b��s���� � zNonCallableMock.configure_mockc�����������������C���s����|dkrt�|��n:|�jd�k r<||�jks.|tkrLt�d|���nt|�rLt�|��|�jsd|�d�rdt�d��|�j�|�}|tkr�t�|��np|d�kr�d�}|�j d�k r�t |�j |�}|�j|�||||�d�}||�j|<�n.t|t �r�t|j|j|j|j|j�}||�j|<�|S�)N>���r����r����zMock object has no attribute %r)�assertZassretz1Attributes cannot start with 'assert' or 'assret')r����r���r���r����r����)r:���r�����_all_magicsr����r����r���r~���r^���r����r����r$���r����r"���r����r���r����r����rK���r����r���)rA���r���rf���r���r���r���r���r����x��sF���� ���� ���� zNonCallableMock.__getattr__c�����������������C���s����|�j�g}|�j}|�}d}|dgkr$d}|d�k rZ|}|�|j�|���d}|j�dkrRd}|j}q$tt|��}|jpnd}t|�dkr�|d�dkr�|d7�}||d<�d�|�S�)Nr����r����r����r5���r����)r����z().r���)r����r����r����rY����reversedr����r�����join)rA���Z _name_listr����Zlast�dotZ_firstr���r���r����_extract_mock_name���s(���� z"NonCallableMock._extract_mock_namec�����������������C���s^���|�����}d}|dkrd|�}d}|�jd�k rDd}|�jr8d}||�jj�}dt|��j||t|��f�S�)Nr����)r5���zmock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r����r����r����rM���r1���r����)rA���r���Zname_stringZspec_stringr���r���r���r�������s ���� �zNonCallableMock.__repr__c�����������������C���sv���t�st�|��S�|�jpg�}tt|���}t|�j�}dd��|�j� ��D��}dd��|D��}dd��|D��}t t||�|�|���S�)z8Filter the output of `dir(mock)` to only useful members.c�����������������S���s���g�|�]\}}|t�k r|�qS�r���)r����)r���Zm_nameZm_valuer���r���r���r�������s����z+NonCallableMock.__dir__.<locals>.<listcomp>c�����������������S���s���g�|�]}|��d��s|�qS�r���r����r����er���r���r���r�������s����� �c�����������������S���s"���g�|�]}|��d��rt|�r|�qS�r���)r���r����r���r���r���r���r�������s����� �)r ����object�__dir__r����r����r1���rY���r]���r~���r����r�����set)rA���ZextrasZ from_typeZ from_dictZfrom_child_mocksr���r���r���r�����s���� �zNonCallableMock.__dir__c��������������������sT��|t�krt��||�S��jrH�jd�k rH|�jkrH|�jkrHtd|���n�|tkrbd|�}t|��n�|tkr�jd�k r�|�jkr�td|���t |�s�t t��|t||���|�����fdd�}n(t �|d�|��t t��||��|�j|<�n,|dkr�|�_d�S�t �|||��r|�j|<��j�rFt�|��sF������d|���}td|�����t��||�S�)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.c���������������������s������f|��|�S�r/���r����rB���r�����re���rA���r���r���r�������r����z-NonCallableMock.__setattr__.<locals>.<lambda>r����r����zCannot set )r����r���__setattr__r����r����r]���r:����_unsupported_magicsr����r!���rS���r1����_get_methodr����r~���r����r����r#���r����)rA���r���r�����msg� mock_namer���r��r���r�����s<������ zNonCallableMock.__setattr__c�����������������C���s����|t�kr2|t|��jkr2tt|��|��||�jkr2d�S�|�j�|t�}||�jkr\tt|��� |��n|t krlt|��|tk r||�j|=�t |�j|<�d�S�r/���)r����r1���r]����delattrr~���r^����_missingr����r����__delattr__r����r:���)rA���r���r)���r���r���r���r����s���� zNonCallableMock.__delattr__c�����������������C���s���|�j�pd}t|||�S�r4���)r�����_format_call_signature�rA���rB���rC���r���r���r���r����_format_mock_call_signature��s���� z+NonCallableMock._format_mock_call_signaturer���c�����������������C���s.���d}|���||�}|�j}|�j�|��}||||f�S�)Nz.expected %s not found. Expected: %s Actual: %s)r��r{���)rA���rB���rC����action�message�expected_stringr{���Z actual_stringr���r���r����_format_mock_failure_message��s ���� z,NonCallableMock._format_mock_failure_messagec�����������������C���sj���|s |�j�S�d}|�dd��d�}|�j}|D�]:}|�|�}|dksJt|t�rP�qfq*t|�}|j}|j�}q*|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����r����r����)r�����replacer����r~���r^���r"���r����r7���)rA���r���rE����namesZchildrenr����r���r���r����_get_call_signature_from_name'��s���� z-NonCallableMock._get_call_signature_from_namec�������������� ���C���s����t�|t�r&t|�dkr&|��|d��}n|�j}|dk r�t|�dkrNd}|\}}n |\}}}z||j||�fW�S��tk r��}�z|�d��W�Y��S�d}~X�Y�q�X�n|S�dS�)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����r���Nr����)r"���rZ���r����r��r����r?���� TypeError�with_traceback)rA����_callrE���r���rB���rC���r��r���r���r���� _call_matcherH��s���� "zNonCallableMock._call_matcherc�����������������C���s0���|�j�dkr,d|�jpd|�j�|����f�}t|��dS�)z/assert that the mock was never called. r���z9Expected '%s' to not have been called. Called %s times.%sr5���N�rz���r�����_calls_repr�AssertionError�rA���r ��r���r���r���rm���b��s���� ��z!NonCallableMock.assert_not_calledc�����������������C���s$���|�j�dkr d|�jpd�}t|��dS�)z6assert that the mock was called at least once r���z"Expected '%s' to have been called.r5���N)rz���r����r��r ��r���r���r���rl���l��s ���� �zNonCallableMock.assert_calledc�����������������C���s0���|�j�dks,d|�jpd|�j�|����f�}t|��dS�)z3assert that the mock was called only once. r����z:Expected '%s' to have been called once. Called %s times.%sr5���Nr��r ��r���r���r���rn���t��s���� ��z"NonCallableMock.assert_called_oncec�������������������s�����j�dkr.������}d}d||f�}t|������fdd�}�����f�}���j��}||kr~t|t�rn|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.z0expected call not found. Expected: %s Actual: %sc���������������������s����������}�|�S�r/����r���r ���rB���rC���rA���r���r����_error_message���s����z:NonCallableMock.assert_called_with.<locals>._error_message)r{���r��r��r��r"���� Exception)rA���rB���rC����expected�actualZ error_messager$���causer���r#��r���rj���~��s���� �z"NonCallableMock.assert_called_withc����������������O���s8���|�j�dks,d|�jpd|�j�|����f�}t|��|�j||�S�)ziassert that the mock was called exactly once and that that call was with the specified arguments.r����z3Expected '%s' to be called once. Called %s times.%sr5���)rz���r����r��r��rj����rA���rB���rC���r ��r���r���r���ro������s���� ��z'NonCallableMock.assert_called_once_withc����������� ��� ������s����fdd�|D��}t�dd��|D��d�}t��fdd���jD���}|s�||kr�|dkrXd}nd�d d��|D���}t|��d t|�����jdd��d �����|�dS�t|�}g�}|D�]2}z|�|��W�q��t k r����|� |��Y�q�X�q�|�rtd��jp�dt|�|f��|�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��������������������s���g�|�]}����|��qS�r����r���r����cr����r���r���r�������s�����z4NonCallableMock.assert_has_calls.<locals>.<listcomp>c�����������������s���s���|�]}t�|t�r|V��qd�S�r/����r"���r%��r���r���r���r���� <genexpr>���s����� �z3NonCallableMock.assert_has_calls.<locals>.<genexpr>Nc�����������������3���s���|�]}����|�V��qd�S�r/���r*��r+��r����r���r���r.�����s�����zCalls not found.z+Error processing expected calls. Errors: {}c�����������������S���s���g�|�]}t�|t�r|nd��qS�r/���r-��r���r���r���r���r�������s����� Expected: ZActual)�prefixr����z@%r does not contain all of %r in its call list, found %r insteadr5���) r����rr���rt����formatr��r���rstriprY����remover<���r����r����rZ���) rA����calls� any_orderr&��r(��Z all_calls�problem� not_found�kallr���r����r���rp������sH���� ��"�������z NonCallableMock.assert_has_callsc�������������������sZ�������||f�}��fdd���jD��}||krVt|t�r8|nd}���||�}td|��|�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.c��������������������s���g�|�]}����|��qS�r���r*��r+��r����r���r���r�������s�����z3NonCallableMock.assert_any_call.<locals>.<listcomp>Nz%s call not found)r��r|���r"���r%��r��r���rA���rB���rC���r&��r'��r(��r��r���r����r���rq������s������zNonCallableMock.assert_any_callc����������������K���s����|��d�}||�jd�kr"tf�|�S�t|��}t|t�rB|tkrBt}nbt|t�rp|tksd|�j rj||�j krjt}q�t}n4t|t �s�t|t�r�t}q�t|t�r�t }n |jd�}|�jr�d|kr�d|d��nd}|����|�}t|��|f�|�S�)aP��Create 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����r����r����r���r����r����)r^���r]���r ���r1���r0���r����_async_method_magicsr�����_all_sync_magicsr����� CallableMixinr���r���r���r\���r����r����r:���)rA���r����r�����_type�klassrU���r��r���r���r���r�������s2���� �� zNonCallableMock._get_child_mock�Callsc�����������������C���s"���|�j�s dS�d|��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����)rt���r���)rA���r0��r���r���r���r����s����zNonCallableMock._calls_repr)NNNNNNr����NFNF)F)FF)N)r���)F)r?��)-rM���rP���r����rN���r����r8���r����r����r����Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr����rv���r����r����ry���rz���r{���r|���rt���Z!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr}���ru���r����r����r����r����r��r��r��r��r��r��r��rm���rl���rn���rj���ro���rp���rq���r����r��r���r���r���r���r������sp����������������������� - ��� � '' ! -'r���c�����������������C���sL���|�d�kr|�S�t�|��r|�S�t|��r$|�S�z t|��W�S��tk rF���|��Y�S�X�d�S�r/���)r3���rX���r����r��r(���r���r���r���r������s���� r����c���������������� ���@���sR���e�Zd�Zddedddddddf dd�Zdd��Zdd��Zd d ��Zdd��Zd d��Z dS�)r<��Nr����c�������������� ���K���s6���||�j�d<�tt|��j||||||| | f|��||�_d�S�)Nr����)r]���r����r<��r8���r}���)rA���r����r}���rv���r���r���r����r����r����r����r����rC���r���r���r���r8���#��s���� ��������zCallableMixin.__init__c����������������O���s���d�S�r/���r���r@���r���r���r���rH���/��s����zCallableMixin._mock_check_sigc����������������O���s$���|�j�||��|�j||��|�j||�S�r/���)rH����_increment_mock_call� _mock_callr@���r���r���r���r9���4��s����zCallableMixin.__call__c����������������O���s���|�j�||�S�r/���)�_execute_mock_callr@���r���r���r���rB��<��s����zCallableMixin._mock_callc����������������O���s���d|�_�|��jd7��_t||fdd�}||�_|�j�|��|�jd�k }|�j}|�j}|dk}|�j �td||f���|�j }|d�k r�|r�|j�t|||f���|jd�k }|r�|jd�|�}t|||f�} |j �| ��|jr�|r�d} nd} |jdk}|j| �|�}|j }qpd�S�)NTr������twor����r����r����)ry���rz����_Callr{���r|���r����r����r����r����rt���r����rs���)rA���rB���rC���r��Zdo_method_callsZmethod_call_nameZmock_call_nameZ is_a_callr����Zthis_mock_callr����r���r���r���rA��?��s4���� z"CallableMixin._increment_mock_callc����������������O���s|���|�j�}|d�k rPt|�r|�n(t|�s:t|�}t|�rD|�n |||�}|tk rP|S�|�jtk r`|�jS�|�jd�k rv|�j||�S�|�jS�r/���)r}���r3���rX���r����r���r����rv���r����)rA���rB���rC����effectrf���r���r���r���rC��m��s ���� z CallableMixin._execute_mock_call) rM���rP���r����r���r8���rH���r9���rB��rA��rC��r���r���r���r���r<��!��s��������� .r<��c�������������������@���s���e�Zd�ZdZdS�)r���a� �� 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. * `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. N�rM���rP���r����rN���r���r���r���r���r������s���r���c�����������������C���s8���zt�|�|�W�S��tk r2���t|��t�|�|��Y�S�X�d�S�r/���)r$���r:���� __import__)�thing�comp�import_pathr���r���r����_dot_lookup���s ����rM��c�����������������C���sB���|���d�}|�d�}t|�}|D�]}|d|�7�}t|||�}q |S�)Nr����r���z.%s)r����r����rI��rM��)�targetZ componentsrL��rJ��rK��r���r���r���� _importer���s���� rO��c�������������������@���sz���e�Zd�ZdZg�Zdd��Zdd��Zdd��Zdd ��Ze j d d���Zdd ��Zdd��Z dd��Zdd��Zdd��Zdd��Zdd��ZdS�)�_patchNc ����������� ������C���sn���|d�k r(|t�k rtd��|d�k r(td��||�_||�_||�_||�_||�_||�_d|�_||�_ ||�_ | |�_g�|�_d�S�)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF) r���r<����getterrU���r�����new_callabler�����createZ has_localr�����autospecrC����additional_patchers) rA���rQ��rU���r����r����rS��r����rT��rR��rC���r���r���r���r8������s(������z_patch.__init__c�������������� ���C���sH���t�|�j|�j|�j|�j|�j|�j|�j|�j|�j � }|�j |_ dd��|�jD��|_|S�)Nc�����������������S���s���g�|�]}|�����qS�r���)�copy)r����pr���r���r���r�������s����z_patch.copy.<locals>.<listcomp>)rP��rQ��rU���r����r����rS��r����rT��rR��rC����attribute_namerU��)rA����patcherr���r���r���rV�����s ������������z_patch.copyc�����������������C���s2���t�|t�r|��|�S�t�|�r(|��|�S�|��|�S�r/���)r"���r1����decorate_classr'���r&����decorate_async_callable�decorate_callable�rA���r-���r���r���r���r9������s ���� z_patch.__call__c�����������������C���sN���t�|�D�]@}|�tj�sqt||�}t|d�s0q|����}t||||���q|S��Nr9���)r����r���r����TEST_PREFIXr$���r#���rV��rS���)rA���r>��r����� attr_valuerY��r���r���r���rZ����s���� z_patch.decorate_classc�������������� ���c���sr���g�}t�����\}|jD�]8}|�|�}|jd�k r8|�|��q|jtkr|�|��q|t |�7�}||fV��W�5�Q�R�X�d�S�r/���) � contextlib� ExitStack� patchings� enter_contextrX���updater����r���r����rZ���)rA����patchedrB����keywargs� extra_args� exit_stack�patchingr����r���r���r����decoration_helper��s���� z_patch.decoration_helperc��������������������s>���t���d�r��j������S�t�������fdd����g�_�S�)Nrc��c��������������� ������s4�������|�|��\}}��||�W��5�Q�R���S�Q�R�X�d�S�r/����rk���rB���rg��ZnewargsZnewkeywargs�r-���rf��rA���r���r���rf��(��s�����z)_patch.decorate_callable.<locals>.patched�r#���rc��r����r���r]��r���rn��r���r\��"��s���� z_patch.decorate_callablec��������������������s>���t���d�r��j������S�t�������fdd����g�_�S�)Nrc��c��������������� �������s:�������|�|��"\}}��||�I�d�H�W��5�Q�R���S�Q�R�X�d�S�r/���rl��rm��rn��r���r���rf��9��s�����z/_patch.decorate_async_callable.<locals>.patchedro��r]��r���rn��r���r[��3��s���� z_patch.decorate_async_callablec�������������� ���C���s����|�����}|�j}t}d}z|j|�}W�n$�ttfk rH���t||t�}Y�nX�d}|tkrft|t �rfd|�_ |�j s�|tkr�td||f���||fS�)NFTz!%s does not have the attribute %r)rQ��rU���r���r]���r:����KeyErrorr$���� _builtinsr"���r���rS��)rA���rN��r���re����localr���r���r����get_originalD��s ���� �z_patch.get_originalc�����������������C���s���|�j�|�j|�j��}}}|�j|�j�}}|�j}|����|�_|dkr@d}|dkrLd}|dkrXd}|dk rp|dk rptd��|dk s�|dk r�|dkr�td��|�� ��\}}|t k�r||dk�r|d} |dkr�|}|dkr�|}d}n&|dk r�|dkr�|}d}n|dkr�|}|dk �s|dk �r.|t k�rtd��t|t��r.d} |dk�rHt |��rHt} nt} i�}|dk �r`|} n^|dk �st|dk �r�|}|dk �r�|}t|��r�d|k} n t|��} t |��r�t} n | �r�t} |dk �r�||d <�|dk �r�||d <�t| t��rt| t��r|�j�r|�j|d<�|�|��| f�|�}| �r�t|��r�|}|dk �rB|}t|��sZt|��sZt} |�d��| f�|dd �|��|_nl|dk �r�|t k �r�td��|t k�r�td��t|�}|dk�r�|}t|f||�jd�|��}n|�r�td��|}||�_||�_t� ��|�_!zrt"|�j|�j|��|�j#dk �rpi�}|�j�t k�r:|||�j#<�|�j$D�](}|�j!�%|�}|j�t k�r@|�|���q@|W�S�|W�S����|�j&t'�(�����s���Y�nX�dS�)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=Truer9���r����r����r���r����r����zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r�����_namez.Can't pass kwargs to a mock we aren't creating))r����r����r����rT��rC���rR��rQ��rN��r��rs��r���r"���r1���r*���r ���r���r[���r����r���r0���r���rU���re��r!���r`���r����rv����boolr���� temp_original�is_localra��rb���_exit_stackrS���rX��rU��rd���__exit__�sys�exc_info)rA���r����r����r����rT��rC���rR��re���rr��Zinherit�Klass�_kwargsZ this_specZnot_callableZnew_attrrh��rj��r����r���r���r���� __enter__\��s����� � �� � � � �� z_patch.__enter__c�����������������G���s����|�j�r$|�jtk r$t|�j|�j|�j��n>t|�j|�j��|�jsbt|�j|�j�rP|�jdkrbt|�j|�j|�j��|�`|�`�|�`|�j }|�` |j |��S�)zUndo the patch.)rN���rP���rQ����__annotations__rR���)rw��rv��r���rS���rN��rU���r��rS��r#���rx��ry��)rA���r{��ri��r���r���r���ry�����s�����z_patch.__exit__c�����������������C���s���|�����}|�j�|���|S�)z-Activate a patch, returning any created mock.)r~���_active_patchesr����)rA���rf���r���r���r����start���s����z_patch.startc�����������������C���s6���z|�j��|���W�n�tk r&���Y�dS�X�|��ddd�S�)zStop an active patch.N)r���r3��r<���ry��r����r���r���r����stop���s ����z_patch.stop)rM���rP���r����rX��r���r8���rV��r9���rZ��ra���contextmanagerrk��r\��r[��rs��r~��ry��r���r���r���r���r���r���rP�����s ��� �rP��c�������������� ������sP���z����dd�\��}W�n&�ttfk r:���td��f���Y�nX���fdd�}||fS�)Nr����r����z.Need a valid target to patch. You supplied: %rc����������������������s���t����S�r/����rO��r����rN��r���r���r������r����z_get_target.<locals>.<lambda>)�rsplitr��r<���)rN��rU���rQ��r���r���r����_get_target ��s�����r���c����������� ��� ������s>���t����tkrt���d�����fdd�} 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����������������������s�����S�r/���r���r���r���r���r���r����*��r����z_patch_object.<locals>.<lambda>)r1����strr��rP��) rN��rU���r����r����rS��r����rT��rR��rC���rQ��r���r���r���� _patch_object��s �������������r���c����������� ���������s����t����tkr��fdd�}n��fdd�}|s2td��t|����}|d�\} } t|| | |||||i�� }| |_|dd��D�]2\} } t|| | |||||i�� }| |_|j�|��qt|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����������������������s���t����S�r/���r���r���r���r���r���r����H��r����z!_patch_multiple.<locals>.<lambda>c����������������������s�����S�r/���r���r���r���r���r���r����J��r����z=Must supply at least one keyword argument with patch.multipler���r����N) r1���r���r<���rY���r����rP��rX��rU��r����) rN��r����rS��r����rT��rR��rC���rQ��r����rU���r����rY��Zthis_patcherr���r���r����_patch_multiple1��sH���������������������r���c����������� ��� ���K���s$���t�|��\}} t|| |||||||� S�)a7�� `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` takes arbitrary keyword arguments. These will be passed to the `Mock` (or `new_callable`) on construction. `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are available for alternate use-cases. )r���rP��) rN��r����r����rS��r����rT��rR��rC���rQ��rU���r���r���r���r���b��s����F��������r���c�������������������@���sR���e�Zd�ZdZddd�Zdd��Zdd ��Zd d��Zdd ��Zdd��Z dd��Z eZe 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�����������������K���s,���||�_�t|�|�_|�j�|��||�_d�|�_d�S�r/���)�in_dict�dictr����re���clear� _original)rA���r���r����r���rC���r���r���r���r8������s ���� z_patch_dict.__init__c��������������������s.���t���t�r�����S�t������fdd��}|S�)Nc���������������������s&���������z��|�|�W��S������X�d�S�r/���)r���� _unpatch_dictr����frA���r���r����_inner���s����z$_patch_dict.__call__.<locals>._inner)r"���r1���rZ��r���)rA���r���r���r���r���r���r9������s ���� z_patch_dict.__call__c�����������������C���sX���t�|�D�]J}t||�}|�tj�rt|d�rt|�j|�j|�j �}||�}t |||��q|S�r^��)r����r$���r���r���r_��r#���r���r���r����r���rS���)rA���r>��r����r`��Z decoratorZ decoratedr���r���r���rZ�����s���� �z_patch_dict.decorate_classc�����������������C���s���|������|�jS�)zPatch the dict.)r���r���r����r���r���r���r~�����s����z_patch_dict.__enter__c�����������������C���s����|�j�}t|�jt�rt|�j�|�_|�j}|�j}z|���}W�n.�tk rd���i�}|D�]}||�||<�qNY�nX�||�_|rxt |��z|� |��W�n*�tk r����|D�]}||�||<�q�Y�nX�d�S�r/���)r����r"���r���r���rO��r���rV��r:���r����_clear_dictre��)rA���r����r���r���re���r����r���r���r���r������s&����z_patch_dict._patch_dictc�����������������C���sR���|�j�}|�j}t|��z|�|��W�n*�tk rL���|D�]}||�||<�q6Y�nX�d�S�r/���)r���r���r���re��r:���)rA���r���re���r����r���r���r���r�����s����z_patch_dict._unpatch_dictc�����������������G���s���|������dS�)zUnpatch the dict.F)r���)rA���rB���r���r���r���ry����s����z_patch_dict.__exit__N)r���F) rM���rP���r����rN���r8���r9���rZ��r~��r���r���ry��r���r���r���r���r���r���r������s��� r���c�����������������C���s>���z|������W�n,�tk r8���t|��}|D�] }|�|=�q(Y�nX�d�S�r/���)r���r:���rY���)r���r����r����r���r���r���r���&��s����r���c������������������C���s���t�tj�D�]}�|�����q dS�)z7Stop all active patches. LIFO to unroll nested patches.N)r����rP��r���r���)r���r���r���r����_patch_stopall/��s����r���Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index round trunc floor ceil bool next fspath aiter zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� c�����������������c���s���|�]}d�|�V��qdS�)zi%sNr����r����nr���r���r���r.��N��s�����r.��c�����������������c���s���|�]}d�|�V��qdS�)zr%sNr���r���r���r���r���r.��O��s������__get__�__set__� __delete__�__reversed__�__missing__r����� __reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__� __getformat__Z __setformat__r����r���__subclasses__� __format__�__getnewargs_ex__c��������������������s�����fdd�}|�|_�|S�)z:Turns a callable object (like a mock) into a real functionc�������������������s�����|�f|�|�S�r/���r����rA���rB���r����r,���r���r����method`��s����z_get_method.<locals>.method)rM���)r���r-���r���r���r,���r���r ��^��s����r ��c�����������������C���s���h�|�]}d�|��qS�)r����r���)r���r���r���r���r���r���f��s����� __aenter__� __aexit__� __anext__� __aiter__r����r��r8���r�����__prepare__�__instancecheck__�__subclasscheck__�__del__c�����������������C���s ���t��|��S�r/���)r���__hash__r����r���r���r���r����|��r����r����c�����������������C���s ���t��|��S�r/���)r���__str__r����r���r���r���r����}��r����c�����������������C���s ���t��|��S�r/���)r��� __sizeof__r����r���r���r���r����~��r����c�����������������C���s"���t�|��j��d|������dt|�����S�)N�/)r1���rM���r����r����r����r���r���r���r������r����)r���r���r���� __fspath__r����y���������������?g�������?) �__lt__�__gt__�__le__�__ge__�__int__r�����__len__ry���__complex__� __float__�__bool__� __index__r���c��������������������s�����fdd�}|S�)Nc��������������������s$�����j�j}|tk r|S���|�kr dS�tS��NT)�__eq__r����r����NotImplemented)�other�ret_valr����r���r���r������s����z_get_eq.<locals>.__eq__r���)rA���r���r���r����r����_get_eq���s����r���c��������������������s�����fdd�}|S�)Nc��������������������s �����j�jtk rtS���|�krdS�tS��NF)�__ne__r����r���r���)r���r����r���r���r������s ����z_get_ne.<locals>.__ne__r���)rA���r���r���r����r����_get_ne���s����r���c��������������������s�����fdd�}|S�)Nc���������������������s �����j�j}�|�tkrtg��S�t|��S�r/���)�__iter__r����r���r�����r���r����r���r���r������s����z_get_iter.<locals>.__iter__r���)rA���r���r���r����r���� _get_iter���s����r���c��������������������s�����fdd�}|S�)Nc���������������������s(�����j�j}�|�tkrttg���S�tt|���S�r/���)r���r����r����_AsyncIteratorr����r���r����r���r���r������s����z"_get_async_iter.<locals>.__aiter__r���)rA���r���r���r����r����_get_async_iter���s����r���)r���r���r���r���c�����������������C���sb���t��|t�}|tk r||_d�S�t�|�}|d�k rB||��}||_d�S�t�|�}|d�k r^||��|_d�S�r/���)�_return_valuesr^���r���rv����_calculate_return_value�_side_effect_methodsr}���)r5���r���r���ZfixedZreturn_calculatorrv���Z side_effectorr���r���r����_set_return_value���s���� r���c�������������������@���s���e�Zd�Zdd��Zdd��ZdS�)� MagicMixinc����������������O���s&���|������tt|��j||��|������d�S�r/���)�_mock_set_magicsr����r���r8���r���r���r���r���r8������s����zMagicMixin.__init__c�����������������C���s����t�tB�}|}t|�dd��d�k rX|�|�j�}t��}||�}|D�]}|t|��jkr:t|�|��q:|tt|��j��}t|��}|D�]}t ||t ||����qvd�S�)Nr����)�_magicsr:��r$����intersectionr����r��r1���r]���r��rS���� MagicProxy)rA���Zorig_magicsZthese_magicsZ remove_magicsr����r=��r���r���r���r������s����zMagicMixin._mock_set_magicsN)rM���rP���r����r8���r���r���r���r���r���r������s���r���c�������������������@���s���e�Zd�ZdZddd�ZdS�)r���z-A version of `MagicMock` that isn't callable.Fc�����������������C���s���|���||��|�����dS�r�����r����r���r����r���r���r���r�������s����z"NonCallableMagicMock.mock_add_specN)F�rM���rP���r����rN���r����r���r���r���r���r������s���r���c�������������������@���s���e�Zd�Zdd��ZdS�)�AsyncMagicMixinc����������������O���s&���|������tt|��j||��|������d�S�r/���)r���r����r���r8���r���r���r���r���r8������s����zAsyncMagicMixin.__init__N�rM���rP���r����r8���r���r���r���r���r������s���r���c�������������������@���s���e�Zd�ZdZddd�ZdS�)r���a��� 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�����������������C���s���|���||��|�����dS�r����r���r����r���r���r���r������s����zMagicMock.mock_add_specN)Fr���r���r���r���r���r�����s��� r���c�������������������@���s&���e�Zd�Zdd��Zdd��Zddd�ZdS�) r���c�����������������C���s���||�_�||�_d�S�r/����r���r����)rA���r���r����r���r���r���r8�����s����zMagicProxy.__init__c�����������������C���s8���|�j�}|�j}|j|||d�}t|||��t|||��|S�)N)r���r����r����)r���r����r����rS���r���)rA���r����r�����mr���r���r����create_mock��s�����zMagicProxy.create_mockNc�����������������C���s���|�����S�r/���)r���)rA���r)���r=��r���r���r���r���(��s����zMagicProxy.__get__)N)rM���rP���r����r8���r���r���r���r���r���r���r�����s��� r���c�����������������������s����e�Zd�Zed�Zed�Zed�Z��fdd�Zdd��Zdd ��Z d d��Z dd ��Zdd��Zdd��Z ddd�Zdd��Z��fdd�Z���ZS�)r����r����r����r����c�������������������s\���t���j||��tjj|�jd<�d|�jd<�d�|�jd<�t��|�jd<�ttd�}t j |_||�jd<�d�S�)Nr����r���Z_mock_await_countZ_mock_await_argsZ_mock_await_args_list�r����r+���)�superr8���r%���r����r����r]���rr���r���r���r'���ZCO_COROUTINE�co_flags)rA���rB���rC���� code_mock�r����r���r���r8���1��s���� zAsyncMockMixin.__init__c��������������������s��t�||fdd�}|��jd7��_||�_|�j�|��|�j}|d�k r�t|�rL|�nbt|�s�zt|�}W�n�t k rx���t �Y�nX�t|�r�|�n&t�|�r�|||�I�d�H�}n |||�}|t k r�|S�|�jt k r�|�jS�|�jd�k r�t�|�j�r�|�j||�I�d�H�S�|�j||�S�|�jS�)NTrD��r����)rF��r����r����r����r����r}���r3���rX���r����� StopIteration�StopAsyncIterationr%���r&���r���r����rv���r����)rA���rB���rC���r��rG��rf���r���r���r���rC��A��s6���� z!AsyncMockMixin._execute_mock_callc�����������������C���s(���|�j�dkr$d|�jpd��d�}t|��dS�)zA Assert that the mock was awaited at least once. r���� Expected r5���z to have been awaited.N�r����r����r��r ��r���r���r���r����i��s���� zAsyncMockMixin.assert_awaitedc�����������������C���s0���|�j�dks,d|�jpd��d|�j���d�}t|��dS�)z@ Assert that the mock was awaited exactly once. r����r���r5����$ to have been awaited once. Awaited � times.Nr���r ��r���r���r���r����q��s���� z"AsyncMockMixin.assert_awaited_oncec�������������������sz����j�dkr&������}td|��d�������fdd�}�����f�}���j��}||krvt|t�rf|nd}t|���|�dS�)zN Assert that the last await was with the specified arguments. NzExpected await: z Not awaitedc���������������������s����j����dd�}�|�S�)N�await)r��r!��r"��r#��r���r���r$�����s����z:AsyncMockMixin.assert_awaited_with.<locals>._error_message)r����r��r��r��r"���r%��)rA���rB���rC���r&��r$��r'��r(��r���r#��r���r����z��s���� z"AsyncMockMixin.assert_awaited_withc����������������O���s8���|�j�dks,d|�jpd��d|�j���d�}t|��|�j||�S�)zi Assert that the mock was awaited exactly once and with the specified arguments. r����r���r5���r���r���)r����r����r��r����r)��r���r���r���r�������s���� z'AsyncMockMixin.assert_awaited_once_withc�������������������sZ�������||f�}��fdd���jD��}||krVt|t�r8|nd}���||�}td|��|�dS�)zU Assert the mock has ever been awaited with the specified arguments. c��������������������s���g�|�]}����|��qS�r���r*��r+��r����r���r���r�������s�����z3AsyncMockMixin.assert_any_await.<locals>.<listcomp>Nz%s await not found)r��r����r"���r%��r��r��r9��r���r����r���r�������s������zAsyncMockMixin.assert_any_awaitFc����������� ��� ������s������fdd�|D��}t�dd��|D��d�}t��fdd���jD���}|s�||kr�|dkrXd}nd�d d��|D���}t|��d t|���d��j����|�dS�t|�}g�}|D�]2}z|�|��W�q��tk r����|�|��Y�q�X�q�|r�tdt |�f��|�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��������������������s���g�|�]}����|��qS�r���r*��r+��r����r���r���r�������s�����z4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>c�����������������s���s���|�]}t�|t�r|V��qd�S�r/���r-��r���r���r���r���r.�����s����� �z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>Nc�����������������3���s���|�]}����|�V��qd�S�r/���r*��r+��r����r���r���r.�����s�����zAwaits not found.z,Error processing expected awaits. Errors: {}c�����������������S���s���g�|�]}t�|t�r|nd��qS�r/���r-��r���r���r���r���r�������s����r/��z Actual: z%r not all found in await list) r����rr���r����r1��r��rY���r3��r<���r����rZ���) rA���r4��r5��r&��r(��Z all_awaitsr6��r7��r8��r���r����r���r�������s>����������z AsyncMockMixin.assert_has_awaitsc�����������������C���s0���|�j�dkr,d|�jpd��d|�j���d�}t|��dS�)z9 Assert that the mock was never awaited. r���r���r5���z# to not have been awaited. Awaited r���Nr���r ��r���r���r���r�������s���� z!AsyncMockMixin.assert_not_awaitedc�������������������s&���t���j||��d|�_d|�_t��|�_dS�)z0 See :func:`.Mock.reset_mock()` r���N)r���ru���r����r����rr���r����r@���r���r���r���ru������s����zAsyncMockMixin.reset_mock)F)rM���rP���r����r����r����r����r����r8���rC��r����r����r����r����r����r����r����ru���� __classcell__r���r���r���r���r����,��s���( , r����c�������������������@���s���e�Zd�ZdZdS�)r ���aa�� 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() >>> asyncio.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. NrH��r���r���r���r���r ������s���r ���c�������������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) �_ANYz2A helper object that compares equal to everything.c�����������������C���s���dS�r���r����rA���r���r���r���r���r��� ��s����z_ANY.__eq__c�����������������C���s���dS�r���r���r���r���r���r���r��� ��s����z_ANY.__ne__c�����������������C���s���dS�)Nz<ANY>r���r����r���r���r���r���� ��s����z _ANY.__repr__N)rM���rP���r����rN���r���r���r����r���r���r���r���r��� ��s���r���c�����������������C���s`���d|��}d}d��dd��|D���}d��dd��|���D���}|r@|}|rX|rP|d7�}||7�}||�S�)Nz%s(%%s)r����z, c�����������������S���s���g�|�]}t�|��qS�r���)�reprr����r���r���r���r����! ��s�����z*_format_call_signature.<locals>.<listcomp>c�����������������S���s���g�|�]\}}d�||f��qS�)z%s=%rr���)r���r����r����r���r���r���r����" ��s����)r����r����)r���rB���rC���r��Zformatted_argsZargs_stringZ kwargs_stringr���r���r���r�� ��s���� �r��c�������������������@���s����e�Zd�ZdZd!dd�Zd"d d �Zdd��ZejZd d��Z dd��Z dd��Zdd��Zdd��Z dd��Zedd���Zedd���Zdd��Zdd ��ZdS�)#rF��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���r����NFTc�����������������C���s����d}i�}t�|�}|dkr$|\}}}nr|dkrd|\} } t| t�rX| }t| t�rR| }qb| }q�| | �}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�t�|�||f�S�t�|�|||f�S�)Nr�������r����r����)r����r"���r���rZ���r����)r����r����r���r����rE��� from_kallrB���rC����_len�first�secondr���r���r���r����C ��s.���� z _Call.__new__c�����������������C���s���||�_�||�_||�_d�S�r/���)r����r�����_mock_from_kall)rA���r����r���r����rE��r���r���r���r���r8���c ��s����z_Call.__init__c�����������������C���sh��|t�krdS�zt|�}W�n�tk r.���Y�dS�X�d}t|��dkrJ|�\}}n |�\}}}t|�dd��r|t|dd��r||�j|jkr|dS�d}|dkr�di��}}n�|dkr�|\}}}n�|d kr�|\} t| t�r�| }i�}n"t| t�r�| }di��}}nd}| }nV|dk�r@|\} }t| t��r4| }t|t��r(|i��}}n d|�}}n | |�}}ndS�|�rX||k�rXdS�||f||fkS�) NTFr����r����r����r���r���r���r����)r���r����r��r$���r����r"���rZ���r���)rA���r���Z len_otherZ self_nameZ self_argsZself_kwargsZ other_nameZ other_argsZother_kwargsr����r���r���r���r���r���r���j ��sR���� � z_Call.__eq__c����������������O���s<���|�j�d�krtd||fdd�S�|�j�d�}t|�j�||f||�d�S�)Nr����r����r����r����r����rF��r��r���r���r���r9���� ��s���� z_Call.__call__c�����������������C���s2���|�j�d�krt|dd�S�d|�j�|f�}t||�dd�S�)NF)r���r���z%s.%s)r���r����r���r���)rA���r����r���r���r���r���r����� ��s���� z_Call.__getattr__c�����������������C���s���|t�jkrt�t��|�|�S�r/���)rZ���r]���r:����__getattribute__)rA���r����r���r���r���r���� ��s���� z_Call.__getattribute__c����������������O���s���|���d�||�S�)Nr�����r����r@���r���r���r���r����� ��s����z_Call.countc����������������O���s���|���d�||�S�)N�indexr���r@���r���r���r���r���� ��s����z_Call.indexc�����������������C���s(���t�|��dkr|�\}}n |�\}}}||fS�)Nr����)r����r��r���r���r����_get_call_arguments� ��s���� z_Call._get_call_argumentsc�����������������C���s���|�����d�S��Nr����r���r����r���r���r���rB���� ��s����z _Call.argsc�����������������C���s���|�����d�S�)Nr����r���r����r���r���r���rC���� ��s����z_Call.kwargsc�����������������C���s|���|�j�s&|�jpd}|�d�r"d|�}|S�t|��dkr@d}|�\}}n0|�\}}}|sTd}n|�d�shd|�}nd|�}t|||�S�)Nr���r����zcall%sr����zcall.%s)r���r����r���r����r��)rA���r���rB���rC���r���r���r���r����� ��s���� z_Call.__repr__c�����������������C���s4���g�}|�}|dk r(|j�r |�|��|j}qtt|��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.N)r���r����r����rr���r����)rA���ZvalsrJ��r���r���r���� call_list� ��s���� z_Call.call_list)r���r����NFT)r���NNFT)rM���rP���r����rN���r����r8���r���r��r���r9���r����r���r����r���r���r����rB���rC���r����r���r���r���r���r���rF��0 ��s*������ ��� 7 rF��)r���c�������������� ���K���sl��t�|��rt|��}�t|�t�}t|��}d|�i}|r8d|�i}n|�dkrDi�}|rT|rTd|d<�|�|��t} t�|��rri�}n8|r�|r�td��t } n"t |��s�t} n|r�|r�t|��s�t} |� d|�}|} |dkr�d} | f�||| |d �|��}t|�t��rt||��}|�rt|��nt|�|||��|dk �r,|�s,||j|<�|�rV|�sVd |k�rVt|�|dd|d�|_t|��D��]}t|��rr�q^zt|�|�} W�n�tk �r����Y��q^Y�nX�d| i}|�r�d| i}t| t��s�t| ||||�}||j|<�np|}t|�t��r�|j}t|�||�}||d <�t�| ��rt }nt}|f�||||d�|��}||j|<�t| ||d��t|t��r^t|||���q^|S�)aI��Create 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` also takes arbitrary keyword arguments that are passed to the constructor of the created mock.r����r����NTr����zJInstance can not be True when create_autospec is mocking an async functionr���r����)r����r����r����r���rv���r����)rK���rt��r����r����)r����r���r����r����)rJ���)r[���r1���r"���r.���re��r���r'���Zisdatadescriptor�RuntimeErrorr ���rX���r���r`���r����r6���ri���r����rL���r~���r���rv���r����r����r$���r:���r����r5���� _must_skipr%���r&���rS���)r����r����rK���r����rt��rC����is_typeZ is_async_funcr}��r|��r����r5���r����re���r����r����rJ���Zchild_klassr���r���r���r���� ��s����� �� �� �� r���c�����������������C���sx���t�|�t�s$|t|�di��krdS�|�j}�|�jD�]H}|j�|t�}|tkrFq*t�|tt f�rZ�dS�t�|t �rl|��S��dS�q*|S�)z[ Return whether we should skip the first argument on spec's `entry` attribute. r]���F)r"���r1���r$���r����r\���r]���r^���r���rV���rW���r6���)r����r����r���r>��rf���r���r���r���r���w ��s���� r���c�������������������@���s���e�Zd�Zddd�ZdS�)r����FNc�����������������C���s(���||�_�||�_||�_||�_||�_||�_d�S�r/���)r�����idsr����r����rK���r���)rA���r����r����r����r���r���rK���r���r���r���r8���� ��s����z_SpecState.__init__)FNNNFr���r���r���r���r���r����� ��s ����������r����c�����������������C���s"���t�|�t�rt�|��S�t�|��S�d�S�r/���)r"����bytes�io�BytesIO�StringIO)� read_datar���r���r���� _to_stream� ��s���� r��r����c��������������������s&��t���}|dg���fdd�}��fdd�}���fdd����fdd �����fd d�}tdkr�ddl}ttt|j���tt|j����a|�dkr�t d t d�}�t td����j_d�j _d�j_d�j_d�j_|�j_����d<��d��j_|�j_���j_|�j_����fdd�}||�_�|�_|�S�)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���������������������s$����j�jd�k r�j�jS���d�j�|�|�S�r���)� readlinesrv���ra�����_state�handler���r����_readlines_side_effect� ��s����z)mock_open.<locals>._readlines_side_effectc���������������������s$����j�jd�k r�j�jS���d�j�|�|�S�r���)�readrv���ra���r��r���r����_read_side_effect� ��s����z$mock_open.<locals>._read_side_effectc������������������?���s$�������E�d�H���d�j�|�|�V��qd�S�r���)�readlinera���)�_iter_side_effectr��r���r����_readline_side_effect� ��s����z(mock_open.<locals>._readline_side_effectc������������������3���s0����j�jd�k r�j�jV��q��d�D�] }�|�V��q d�S�r���)r��rv���)�liner��r���r���r ��� ��s����z$mock_open.<locals>._iter_side_effectc����������������������s ����j�jd�k r�j�jS�t��d��S�r���)r��rv���r����r���r��r���r����_next_side_effect� ��s����z$mock_open.<locals>._next_side_effectr����open)r���r����r����r����c���������������������s6���t����d<��jj�d�kr2�����d<��d��j_tS�)Nr���r����)r��r��r}���r���ra���)r��r��r��r��r���r���� reset_data� ��s ���� zmock_open.<locals>.reset_data)r��� file_spec�_iorY���r��r����� TextIOWrapper�unionr��r���r��r~��rv����writer ��r��r��r}���r���r����)r5���r��Z _read_datar ��r��r��r��r��r���)r ��r��r��r��r��r���r ���� ��s8����" r ���c�������������������@���s*���e�Zd�ZdZdd��Zd dd�Zdd��ZdS�) r���aW�� 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����������������K���s ���t�f�|�S�r/���)r���)rA���rC���r���r���r���r������s����zPropertyMock._get_child_mockNc�����������������C���s���|���S�r/���r���)rA���r)���Zobj_typer���r���r���r�����s����zPropertyMock.__get__c�����������������C���s���|�|��d�S�r/���r���)rA���r)���r����r���r���r���r��� ��s����zPropertyMock.__set__)N)rM���rP���r����rN���r����r���r���r���r���r���r���r���� ��s��� r���c�������������� ���C���s^���d|�_�t|��D�]J}zt|�|�}W�n�tk r8���Y�qY�nX�t|t�sFq|j|�krt|��qdS�)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����r$���r:���r"���r���r����r���)r5���r����r���r���r���r���r�����s���� r���c�������������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) r���z8 Wraps an iterator in an asynchronous iterator. c�����������������C���s&���||�_�ttd�}tj|_||�jd<�d�S�)Nr���r+���)�iteratorr���r���r'���ZCO_ITERABLE_COROUTINEr���r]���)rA���r��r���r���r���r���r8���+��s���� z_AsyncIterator.__init__c�����������������C���s���|�S�r/���r���r����r���r���r���r���1��s����z_AsyncIterator.__aiter__c���������������������s*���zt�|�j�W�S��tk r ���Y�nX�t�d�S�r/���)r����r��r���r���r����r���r���r���r���4��s ����z_AsyncIterator.__anext__N)rM���rP���r����rN���r8���r���r���r���r���r���r���r���'��s���r���)F)F)NFNNN)FFNN)Nr����)y�__all__�__version__r%���ra��r���r'���r����rz���builtins�typesr���r���r���Z unittest.utilr���� functoolsr���r���r����rq��r ���r���r����r*���r.���r!���r3���r7���r=���rL���rG���rX���r[���r`���ri���rd���r����r����r��r����r����r���r����MISSINGr ��ZDELETEDr����r����r����rY���rr���r����r����r����r���r����r<��r���rM��rO��rP��r���r���r���r���r���r���r���r���ZmultipleZstopallr_��Z magic_methodsZnumericsr����r����Zinplace�rightZ _non_defaultsr ��r���r:��Z_sync_async_magicsZ _async_magicsr;��r����r��r���r���r���r���r���r���r���r���r���r���r���r���r���r���r����r ���r���r���r��rZ���rF��r���r���r���r����r1���r���r6���r��r��r ���r���r���r���r���r���r���r����<module>���s~�� 1����������� h4��<���� ����� 2����� Mw ���������������� � ������� � �8+�B ��� �� N