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KO}ӽmSşذqsOy?\[,d@'73'j%kOe`1.g2"e =YIzS2|zŐƄa\U,dP;jhhhaxǶ?КZ՚.q SE+XrbOu%\GتX(H,N^~]JyEZQKceTQ]VGYqnah;y$cQahT&QPZ*iZ8UQQM.qo/T\7X"u?Mttl2Xq(IoW{R^ ux*SYJ! 4S.Jy~ BROS[V|žKNɛP(L6V^|cR7i7nZW1Fd@ Ara{詑|(T*dN]Ko?s=@ |_EvF]׍kR)eBJc" MUUbY6`~V޴dJKß&~'d3i WWWWWW
Current Directory: /usr/lib64/python3.6/unittest/__pycache__
Viewing File: /usr/lib64/python3.6/unittest/__pycache__/mock.cpython-36.pyc
3 \�7�@sFd�Zd ZddlZddlZddlZddlZddlmZddlm Z m Z dd�e e�D�Z e fZdejkrzddlZe ejjfZdZeZdd�Zdd�Zdd�Zd�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd�d'd(�Zd)d*�Zd+d,�Z Gd-d.�d.e!�Z"Gd/d0�d0e!�Z#e#�Z$e$j%Z%e$j&Z'e$j(Z)d1d2�Z*d3d4d5d6d7d8d9d:hZ+d;d<�Z,Gd=d>�d>e-�Z.d?d@�Z/GdAdB�dBe!�Z0GdCdD�dDe!�Z1GdEd �d e1�Z2dFdG�Z3GdHdI�dIe1�Z4GdJd�de4e2�Z5dKdL�Z6dMdN�Z7dOdP�Z8GdQdR�dRe!�Z9dSdT�Z:e%dddddfdUdV�Z;d�dWdX�Z<e%dddddfdYd�Z=GdZd[�d[e!�Z>d\d]�Z?d^d_�Z@e;e=_!e>e=_Ae<e=_Be@e=_Cd`e=_DdaZEdbZFdcjGddde�eFjH�D��ZIdcjGdfde�eFjH�D��ZJdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxhZKdydz�ZLd{d�dcjGeEeFeIeJg�jH�D�ZMeMeKBZNd|d}d~dd�d�d�d�hZOd�d��d�d��d�d��d��ZPeQeQeQeQd�dddd�d�dd�d�� ZRd�d��ZSd�d��ZTd�d��ZUeSeTeUd��ZVd�d��ZWGd�d��d�e!�ZXGd�d �d eXe2�ZYGd�d�deXe5�ZZGd�d��d�e!�Z[Gd�d��d�e!�Z\e\�Z]d�d��Z^Gd�d��d�e_�Z`e`dd��Zad�d�d�Zbd�d��Zcd�d��ZdGd�d��d�e!�Zeefeb�efe]jg�fZhefe]jgji�fZjdakd�d��Zld�d�d �ZmGd�d �d e5�ZndS)��Mock� MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec� FILTER_DIR�NonCallableMock�NonCallableMagicMock� mock_open� PropertyMockz1.0�N)� ModuleType)�wraps�partialcCsh|]}|jd�s|�qS)�_)� startswith)�.0�name�r�/usr/lib64/python3.6/mock.py� <setcomp>#sr�javaTcCstt|�t�S)N)� issubclass�typer )�objrrr�_is_instance_mock2srcCst|t�pt|t�ot|t�S)N)� isinstance�BaseExceptionsrr)rrrr� _is_exception8s r cCs�t|t�r6| r6y |j}Wntk r.dSXd}n*t|t�s`y |j}Wntk r^dSX|rpt|d�}n|}y|tj|�fSt k r�dSXdS)z� Given an arbitrary, possibly callable object, try to create a suitable signature object. Return a (reduced func, signature) tuple, or None. NT) rr�__init__�AttributeError� FunctionTypes�__call__r�inspectZ signature� ValueError)�funcZ as_instanceZeat_selfZsig_funcrrr�_get_signature_object?s$    r(FcsDt|||���dkrdS�\}��fdd�}t||�|t|�_dS)Ncs�j||�dS)N)�bind)� _mock_self�args�kwargs)�sigrr�checksigdsz"_check_signature.<locals>.checksig)r(�_copy_func_detailsr�_mock_check_sig)r'�mock� skipfirst�instancer.r)r-r�_check_signature_s   r4c#Cs�|j|_|j|_y |j|_Wntk r0YnXy |j|_Wntk rRYnXy |j|_Wntk rtYnXy |j|_Wntk r�YnXdS)N)�__name__�__doc__�__text_signature__r"� __module__� __defaults__�__kwdefaults__)r'�funcopyrrrr/js$    r/cCs&t|t�rdSt|dd�dk r"dSdS)NTr$F)rr�getattr)rrrr� _callable�s  r=cCst|�ttfkS)N)r�list�tuple)rrrr�_is_list�sr@cCsHt|t�st|dd�dk Sx(|f|jD]}|jjd�dk r(dSq(WdS)ztGiven an object, return True if the object is callable. For classes, return True if instances would be callable.r$NTF)rrr<�__mro__�__dict__�get)r�baserrr�_instance_callable�s  rEc s�t|�s dSt|t�}t|||�}|dkr.|S|\}��fdd�}t||�|j}|j�s^d}||d�}d|} t| |�||} t| |�| S)Ncs�j||�dS)N)r))r+r,)r-rrr.�sz _set_signature.<locals>.checksigr;)Z _checksig_r1zYdef %s(*args, **kwargs): _checksig_(*args, **kwargs) return mock(*args, **kwargs)) r=rrr(r/r5� isidentifier�exec� _setup_func) r1�originalr3r2�resultr'r.r�context�srcr;r)r-r�_set_signature�s$       rMc s���_t��sdS�fdd�}�fdd�}�fdd�}�fdd�}�fd d �}�fd d �}�fd d�}��fdd�} d�_d�_d�_t��_t��_t��_�j �_ �j �_ �j �_ |�_ |�_ |�_|�_| �_|�_|�_|�_��_dS)Ncs �j||�S)N)�assert_called_with)r+r,)r1rrrN�sz'_setup_func.<locals>.assert_called_withcs �j||�S)N)� assert_called)r+r,)r1rrrO�sz"_setup_func.<locals>.assert_calledcs �j||�S)N)�assert_not_called)r+r,)r1rrrP�sz&_setup_func.<locals>.assert_not_calledcs �j||�S)N)�assert_called_once)r+r,)r1rrrQ�sz'_setup_func.<locals>.assert_called_oncecs �j||�S)N)�assert_called_once_with)r+r,)r1rrrR�sz,_setup_func.<locals>.assert_called_once_withcs �j||�S)N)�assert_has_calls)r+r,)r1rrrS�sz%_setup_func.<locals>.assert_has_callscs �j||�S)N)�assert_any_call)r+r,)r1rrrT�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_�j��j}t|�r6|�k r6|j�dS)N)� _CallList� method_calls� mock_calls� reset_mock� return_valuer)�ret)r;r1rrrX�s z_setup_func.<locals>.reset_mockFr)r1r�called� call_count� call_argsrU�call_args_listrVrWrY� side_effect�_mock_childrenrNrRrSrTrXrOrPrQ�_mock_delegate) r;r1rNrOrPrQrRrSrTrXr)r;r1rrH�s:       rHcCsd|dd�|kS)Nz__%s__����r)rrrr� _is_magic�srdc@s eZdZdZdd�Zdd�ZdS)�_SentinelObjectz!A unique, named, sentinel object.cCs ||_dS)N)r)�selfrrrrr!�sz_SentinelObject.__init__cCs d|jS)Nz sentinel.%s)r)rfrrr�__repr__�sz_SentinelObject.__repr__N)r5r8� __qualname__r6r!rgrrrrre�srec@s eZdZdZdd�Zdd�ZdS)� _SentinelzAAccess attributes to return a named object, usable as a sentinel.cCs i|_dS)N)� _sentinels)rfrrrr!�sz_Sentinel.__init__cCs|dkr t�|jj|t|��S)N� __bases__)r"rj� setdefaultre)rfrrrr� __getattr__sz_Sentinel.__getattr__N)r5r8rhr6r!rmrrrrri�sricCs$t|�ttttfkr t|�|�S|S)N)r�dictr>r?�set)�valuerrr�_copys rqrY�_mock_return_valuer_�_mock_side_effect� _mock_parent�_mock_new_parent� _mock_name�_mock_new_namecCs8tj|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�S)N)rar<)rfr� _the_namer-rrr�_gets z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<n t|||�dS)N)rarB�setattr)rfrprrxr-rrr�_set$s z"_delegating_property.<locals>._set)�_allowed_names�add�property)rrxryr{rrr�_delegating_propertys  rc@seZdZdd�Zdd�ZdS)rUcCsnt|t�stj||�St|�}t|�}||kr2dSx6td||d�D] }||||�}||krFdSqFWdS)NFr�T)rr>� __contains__�len�range)rfrpZ len_valueZlen_self�iZsub_listrrrr�1s  z_CallList.__contains__cCstjt|��S)N)�pprintZpformatr>)rfrrrrg?sz_CallList.__repr__N)r5r8rhr�rgrrrrrU/srUcCsxt|�s dS|js,|js,|jdk s,|jdk r0dS|}x|dk rR||krJdS|j}q6W|rd||_||_|rt||_||_dS)NFT)rrvrwrtru)�parentrpr�new_name�_parentrrr�_check_and_set_parentCs$     r�c@s$eZdZdd�Zdd�Zdd�ZdS)� _MockItercCst|�|_dS)N)�iterr)rfrrrrr!]sz_MockIter.__init__cCs|S)Nr)rfrrr�__iter___sz_MockIter.__iter__cCs t|j�S)N)�nextr)rfrrr�__next__asz_MockIter.__next__N)r5r8rhr!r�r�rrrrr�\sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdS)Nr)rfr+r,rrrr!gsz Base.__init__)r5r8rhrrrrsr!rrrrr�dsr�c @sHeZdZdZdd�ZdDdd�Zd d �ZdEd d �ZdFd d�Zdd�Z dd�Z dZ e e e e �Z e dd��Zed�Zed�Zed�Zed�Zed�Zdd�Zdd�Ze ee�ZdGddd�d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z d2d3�Z!d4d5�Z"d6d7�Z#d8d9�Z$d:d;�Z%d<d=�Z&dHd>d?�Z'd@dA�Z(dBdC�Z)dS)Ir z A non-callable version of `Mock`cOs$t|j|fd|ji�}tj|�}|S)Nr6)rr5r6�object�__new__)�clsr+�kw�newr3rrrr�os zNonCallableMock.__new__N�Fc Ks�|dkr |}|j} || d<|| d<|| d<|| d<|dk rB|}d}| dkrR|dk } |j||| | �i| d<|| d<d| d<d | d <d| d <d | d <t�| d<t�| d<t�| d<| | d<| r�|jf| �tt|�j||||||�dS)NrtrvrwruTr`� _mock_wrapsraFZ _mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrV� _mock_unsafe)rB�_mock_add_specrU�configure_mock� _safe_superr r!)rf�specrr�spec_setr�� _spec_state� _new_name� _new_parent�_spec_as_instance� _eat_selfZunsafer,rBrrrr!xs8      zNonCallableMock.__init__cCs(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�)rtrurvrwrz)rfr1� attributerrr� attach_mock�s zNonCallableMock.attach_mockcCs|j||�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�)rfr�r�rrr� mock_add_spec�szNonCallableMock.mock_add_specc Cs|d}d}|dk rRt|� rRt|t�r*|}nt|�}t|||�}|oH|d}t|�}|j}||d<||d<||d<||d<dS)Nr�� _spec_class� _spec_set�_spec_signature� _mock_methods)r@rr� _get_classr(�dirrB) rfr�r�r�r�r�r��resrBrrrr��s  zNonCallableMock._mock_add_speccCs8|j}|jdk r|jj}|tkr4|j|dd�}||_|S)Nz())r�r�)rrrarYr�_get_child_mock)rfrZrrrZ__get_return_value�s  z"NonCallableMock.__get_return_valuecCs,|jdk r||j_n||_t||dd�dS)Nz())rarYrrr�)rfrprrrZ__set_return_value�s  z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|�S|jS)N)r�r)rfrrr� __class__�s zNonCallableMock.__class__r[r\r]r^rWcCsT|j}|dkr|jS|j}|dk rPt|� rPt|t� rPt|� rPt|�}||_|S)N)rarsr_�callablerr�r )rf� delegatedZsfrrrZ__get_side_effect�sz!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dS)N)� _try_iterrarsr_)rfrpr�rrrZ__set_side_effects z!NonCallableMock.__set_side_effect)rYr_cCs�|dkr g}t|�|krdS|jt|��d|_d|_d|_t�|_t�|_t�|_|r^t |_ |rhd|_ x0|j j �D]"}t|t�st|tkr�qt|j|�qtW|j }t|�r�||k r�|j|�dS)z-Restore the mock object to its initial state.NFr)�id�appendr[r]r\rUrWr^rVrrrrsr`�valuesr� _SpecState�_deletedrXr)rfZvisitedrYr_ZchildrZrrrrX s, zNonCallableMock.reset_mockcKs`xZt|j�dd�d�D]B\}}|jd�}|j�}|}x|D]}t||�}q:Wt|||�qWdS)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)cSs|djd�S)Nr�.)�count)�entryrrr�<lambda>8sz0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�N)�sorted�items�split�popr<rz)rfr,�arg�valr+�finalrr�rrrr�+s   zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk r<||jks.|tkrLtd|��nt|�rLt|��|jsd|jd�rdt|��|jj|�}|tkr�t|��np|dkr�d}|j dk r�t |j |�}|j |||||d�}||j|<n.t |t �r�t|j|j|j|j|j�}||j|<|S) Nr�r�zMock object has no attribute %r�assert�assret)r�rrr�r�>r�r�)r�r�)r"r�� _all_magicsrdr�rr`rCr�r�r<r�rr�rr�r�r3r�r)rfrrJrrrrrmAs6            zNonCallableMock.__getattr__c Cs"|jg}|j}|}d}|dgkr$d}t�}xT|dk r~|}|j|j|�d}|jdkrZd}|j}t|�|krnP|jt|��q,Wtt|��}|jp�d}t |�dkr�|dd kr�|d7}||d<dj |�}d}|dkr�d |}d} |j dk �rd } |j �r�d } | |j j } d t|�j || t|�fS)Nr��()r�r1r��().r�mock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�)r1r�)rwruror�r�r}r>�reversedrvr��joinr�r�r5r) rfZ _name_listr�Zlast�dot�seenZ_firstrZ name_stringZ spec_stringrrrrggsL           zNonCallableMock.__repr__cCshtstj|�S|jpg}tt|��}t|j�}dd�|D�}dd�|D�}tt |||t|j ���S)z8Filter the output of `dir(mock)` to only useful members.cSsg|]}|jd�s|�qS)r)r)r�errr� <listcomp>�sz+NonCallableMock.__dir__.<locals>.<listcomp>cSs$g|]}|jd� st|�r|�qS)r)rrd)rr�rrrr��s) r r��__dir__r�r�rr>rBr�ror`)rfZextrasZ from_typeZ from_dictrrrr��s    zNonCallableMock.__dir__cs"|tkrtj�||�S�jrH�jdk rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk r�|�jkr�td|��t |�s�t t ��|t ||��|���fdd�}n(t �|d|�t t ��||�|�j|<n.|dk�r�|�_dSt �|||��r|�j|<tj�||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��f|�|�S)Nr)r+r�)rIrfrrr��sz-NonCallableMock.__setattr__.<locals>.<lambda>r�)r|r�� __setattr__r�r�rBr"�_unsupported_magicsr�rrzr� _get_methodr�r`r�)rfrrp�msgr)rIrfrr��s2       zNonCallableMock.__setattr__cCs�|tkr2|t|�jkr2tt|�|�||jkr2dS||jkrHtj||�|jj|t�}|t krft |��|tk rv|j|=t |j|<dS)N) r�rrB�delattrr�� __delattr__r`rC�_missingr�r")rfrrrrrr��s   zNonCallableMock.__delattr__cCs|jpd}t|||�S)Nr1)rv�_format_call_signature)rfr+r,rrrr�_format_mock_call_signature�s z+NonCallableMock._format_mock_call_signaturecCsDd}|j||�}|j}t|�dkr.|dd�}|j|�}|||fS)Nz!Expected call: %s Actual call: %s�r�)r�r]r�)rfr+r,�message�expected_stringr]Z actual_stringrrr�_format_mock_failure_message�s    z,NonCallableMock._format_mock_failure_messagecCst|j}|dk rlt|�dkr(d}|\}}n |\}}}y||j||�fStk rh}z |jd�Sd}~XqpXn|SdS)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. Nrbr�)r�r�r)� TypeError�with_traceback)rf�_callr-rr+r,r�rrr� _call_matcher�s   zNonCallableMock._call_matchercCs.|}|jdkr*d|jpd|jf}t|��dS)z/assert that the mock was never called. rz7Expected '%s' to not have been called. Called %s times.r1N)r\rv�AssertionError)r*rfr�rrrrPs  z!NonCallableMock.assert_not_calledcCs(|}|jdkr$d|jpd}t|��dS)z6assert that the mock was called at least once rz"Expected '%s' to have been called.r1N)r\rvr�)r*rfr�rrrrO s   zNonCallableMock.assert_calledcCs.|}|jdks*d|jpd|jf}t|��dS)z3assert that the mock was called only once. r�z8Expected '%s' to have been called once. Called %s times.r1N)r\rvr�)r*rfr�rrrrQs  z"NonCallableMock.assert_called_oncecs||��jdkr(�j���}td|f�����fdd�}�j��f�}�j�j�}||krxt|t�rh|nd}t|��|�dS)z�assert that the mock was called with the specified arguments. Raises an AssertionError if the args and keyword args passed in are different to the last call to the mock.NzExpected call: %s Not calledcs�j���}|S)N)r�)r�)r+r,rfrr�_error_message's z:NonCallableMock.assert_called_with.<locals>._error_message)r]r�r�r�r� Exception)r*r+r,�expectedr��actual�causer)r+r,rfrrNs   z"NonCallableMock.assert_called_withcOs6|}|jdks*d|jpd|jf}t|��|j||�S)ziassert that the mock was called exactly once and that that call was with the specified arguments.r�z1Expected '%s' to be called once. Called %s times.r1)r\rvr�rN)r*r+r,rfr�rrrrR1s  z'NonCallableMock.assert_called_once_withc s��fdd�|D�}t|t�r |nd}t�fdd��jD��}|sd||kr`tdt|��jf�|�dSt|�}g}x:|D]2}y|j|�Wqvtk r�|j|�YqvXqvW|r�tdt |�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`.csg|]}�j|��qSr)r�)r�c)rfrrr�Fsz4NonCallableMock.assert_has_calls.<locals>.<listcomp>Nc3s|]}�j|�VqdS)N)r�)rr�)rfrr� <genexpr>Hsz3NonCallableMock.assert_has_calls.<locals>.<genexpr>z(Calls not found. Expected: %r Actual: %rz%r not all found in call list) rr�rUrWr�r>�remover&r�r?)rfZcallsZ any_orderr�r�Z all_callsZ not_foundZkallr)rfrrS<s*  z NonCallableMock.assert_has_callscsZ�j||f�}�fdd��jD�}||krVt|t�r8|nd}�j||�}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.csg|]}�j|��qSr)r�)rr�)rfrrr�fsz3NonCallableMock.assert_any_call.<locals>.<listcomp>Nz%s call not found)r�r^rr�r�r�)rfr+r,r�r�r�r�r)rfrrT_s zNonCallableMock.assert_any_callcKsFt|�}t|t�s2t|t�r"t}q<t|t�r<t}n |jd}|f|�S)aPCreate the child mocks for attributes and return value. By default child mocks will be the same type as the parent. Subclasses of Mock may want to override this to customize the way child mocks are made. For non-callable mocks the callable variant will be used (rather than any custom subclass).r�)rr� CallableMixinr rr rrA)rfr��_type�klassrrrr�os    zNonCallableMock._get_child_mock) NNNNNNr�NFNF)F)FF)N)F)*r5r8rhr6r�r!r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr~rYr�rr[r\r]r^rWZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr_rXr�rmrgr�r�r�r�r�r�rPrOrQrNrRrSrTr�rrrrr lsR  )      &2"     #c CsF|dkr |St|�r|St|�r$|Syt|�Stk r@|SXdS)N)r r=r�r�)rrrrr��sr�c @sBeZdZddedddddddf dd�Zdd�Zdd�Zd d �ZdS) r�Nr�c Ks6||jd<tt|�j||||||| | f| �||_dS)Nrr)rBr�r�r!r_) rfr�r_rYrrr�r�r�r�r�r,rrrr!�s    zCallableMixin.__init__cOsdS)Nr)rfr+r,rrrr0�szCallableMixin._mock_check_sigcOs|j||�|j||�S)N)r0� _mock_call)r*r+r,rrrr$�s zCallableMixin.__call__cOs�|}d|_|jd7_t||fdd�}||_|jj|�t�}|jdk }|j}|j }|dk} |j jtd||f��|j } x�| dk �r*|r�| j jt|||f��| jdk }|r�| jd|}t|||f�} | j j| �| j �r| r�d} nd} | j dk} | j | |}| j } t | �} | |k�rP|j| �q|W|j}|dk �r�t|��rL|�n,t|��snt|�}t|��rx|�n |||�}|tk �r�|S|jtk �r�|jS|jdk �r�|j||�S|jS)NTr�)�twoz()r�r�)r[r\�_Callr]r^r�rortrvrwrWrurVr�r}r_r r=r�rrrrYr�)r*r+r,rfr�r�Zdo_method_callsZmethod_call_nameZmock_call_nameZ is_a_callr�Zthis_mock_callr�Z_new_parent_idZeffectrJrrrr��s`                zCallableMixin._mock_call)r5r8rhrr!r0r$r�rrrrr��s  r�c@seZdZdZdS)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. * `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)r5r8rhr6rrrrr�s1c Cs2y t||�Stk r,t|�t||�SXdS)N)r<r"� __import__)�thing�comp� import_pathrrr� _dot_lookup1s  r�cCsF|jd�}|jd�}t|�}x$|D]}|d|7}t|||�}q"W|S)Nr�rz.%s)r�r�r�r�)�targetZ componentsr�r�r�rrr� _importer9s    r�cCs t|d�S)N�is_local)�hasattr)�patcherrrr� _is_startedDsr�c@sdeZdZdZgZdd�Zdd�Zdd�Zdd �Zd d �Z d d �Z dd�Z dd�Z dd�Z dd�ZdS)�_patchNc Csn|dk r(|tk rtd��|dk r(td��||_||_||_||_||_||_d|_||_ ||_ | |_ g|_ dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF) rr&�getterr�r�� new_callabler��createZ has_localr��autospecr,�additional_patchers) rfr�r�r�r�r�r�r�r�r,rrrr!Ns$z_patch.__init__c CsHt|j|j|j|j|j|j|j|j|j � }|j |_ dd�|j D�|_ |S)NcSsg|] }|j��qSr)�copy)r�prrrr�qsz_patch.copy.<locals>.<listcomp>) r�r�r�r�r�r�r�r�r�r,�attribute_namer�)rfr�rrrrisz _patch.copycCst|t�r|j|�S|j|�S)N)rr�decorate_class�decorate_callable)rfr'rrrr$vs  z_patch.__call__cCsRxLt|�D]@}|jtj�sq t||�}t|d�s2q |j�}t||||��q W|S)Nr$)r�rr� TEST_PREFIXr<r�rrz)rfr��attr� attr_valuer�rrrr|s   z_patch.decorate_classcs<t�d�r�jj|��St����fdd���|g�_�S)N� patchingscs�g}g}t�}z�ybxJ�jD]@}|j�}|j|�|jdk rF|j|�q|jtkr|j|�qW|t|�7}�||�S||kr�t|�r�|j|�t j �}�YnXWdxt |�D]}|j |�q�WXdS)N) r?r� __enter__r�r�updater�rr��sys�exc_infor��__exit__)r+Zkeywargs� extra_argsZentered_patchersr �patchingr�)r'�patchedrrr�s*         z)_patch.decorate_callable.<locals>.patched)r�rr�r)rfr'r)r'rrr�s   z_patch.decorate_callablec Cs�|j�}|j}t}d}y|j|}Wn$ttfk rHt||t�}YnXd}|tkrft|t �rfd|_ |j r�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r) r�r�rrBr"�KeyErrorr<� _builtinsrrr�)rfr�rrI�localrrr� get_original�sz_patch.get_originalcCs>|j|j|j}}}|j|j}}|j}|j�|_|dkr@d}|dkrLd}|dkrXd}|dk rp|dk rptd��|dk s�|dk r�|dkr�td��|j �\}}|t ko�|dk�rTd} |dkr�|}|dkr�|}d}n&|dk r�|dkr�|}d}n |dkr�|}|dk �s |dk �r,|t k�rtd��t |t ��r,d} t } i} |dk �rD|} nN|dk �sX|dk �r�|} |dk �rj|} t| ��r~d| k} n t| � } | �r�t} |dk �r�|| d<|dk �r�|| d <t | t ��r�t| t��r�|j�r�|j| d <| j|�| f| �}| �r�t|��r�|} |dk �r|} t| � �r2t| � �r2t} | jd �| f|d d �| ��|_nl|dk �r�|t k �rptd ��|t k�r�td��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t|j|j|�|jdk �r:i}|jt k�r|||j<x.|jD]$}|j �}|jt k�r|j|��qW|S|S)zPerform the patch.FNzCan't specify spec and autospecTz6Can't provide explicit spec_set *and* spec or autospecz!Can't use 'spec' with create=Truer$r�r�rz())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)TN)!r�r�r�r�r,r�r�r�r�rrrrrr@r�r rr r�r rrEr�rY�boolr� temp_originalr�rzrr�r )rfr�r�r�r�r,r�rIrZinherit�Klass�_kwargsZ this_specZ not_callableZnew_attrrrr�rrrr �s�                              z_patch.__enter__cGs�t|�std��|jr4|jtk r4t|j|j|j�nBt|j|j�|j rvt |j|j� sd|jdkrvt|j|j|j�|`|`|`x$t |j �D]}t|�r�|j |�q�WdS) zUndo the patch.z stop called on unstarted patcherr6r8r9�__annotations__r:N)r6r8r9rr:)r�� RuntimeErrorr�rrrzr�r�r�r�r�r�r�r )rfr r�rrrr Hs z_patch.__exit__cCs|j�}|jj|�|S)z-Activate a patch, returning any created mock.)r �_active_patchesr�)rfrJrrr�start`s z _patch.startc Cs.y|jj|�Wntk r$YnX|j�S)zStop an active patch.)rr�r&r )rfrrr�stopgs z _patch.stop)r5r8rhrrr!rr$rrrr r rrrrrrr�Is (~r�c sPy�jdd�\�}Wn&ttfk r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��S)N)r�r)r�rrr�ysz_get_target.<locals>.<lambda>)�rsplitr�r&)r�r�r�r)r�r� _get_targetss r c s$�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. cs�S)Nrr)r�rrr��sz_patch_object.<locals>.<lambda>)r�) r�r�r�r�r�r�r�r�r,r�r)r�r� _patch_object}s  r!c s�t��tkr�fdd�}n �fdd�}|s2td��t|j��}|d\} } t|| | |||||i� } | | _xB|dd�D]2\} } t|| | |||||i� } | | _| jj| �qvW| 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. cst��S)N)r�r)r�rrr��sz!_patch_multiple.<locals>.<lambda>cs�S)Nrr)r�rrr��sz=Must supply at least one keyword argument with patch.multiplerr�N) r�strr&r>r�r�rr�r�) r�r�r�r�r�r�r,r�r�r�r�r�Z this_patcherr)r�r�_patch_multiple�s&        r#c Ks$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 a `MagicMock`. 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 `MagicMock` is used. 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 r�) r�r�r�r�r�r�r�r,r�r�rrrr�sE  c@sVeZdZdZfdfdd�Zdd�Zdd�Zd d �Zd d �Zd d�Z dd�Z eZ e Z dS)� _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. FcKs>t|t�rt|�}||_t|�|_|jj|�||_d|_dS)N) rr"r��in_dictrnr�r �clear� _original)rfr%r�r&r,rrrr!0s   z_patch_dict.__init__cs.t�t�r�j��St����fdd��}|S)Nc s"�j�z �||�S�j�XdS)N)r$� _unpatch_dict)r+r�)�frfrr�_inner>s z$_patch_dict.__call__.<locals>._inner)rrrr)rfr)r*r)r)rfrr$;s  z_patch_dict.__call__cCs\xVt|�D]J}t||�}|jtj�r t|d�r t|j|j|j �}||�}t |||�q W|S)Nr$) r�r<rrrr�r$r%r�r&rz)rfr�rrZ decoratorZ decoratedrrrrIs   z_patch_dict.decorate_classcCs |j�dS)zPatch the dict.N)r$)rfrrrr Tsz_patch_dict.__enter__cCs�|j}|j}|j}y |j�}Wn2tk rPi}x|D]}||||<q8WYnX||_|rdt|�y|j|�Wn.tk r�x|D]}||||<q�WYnXdS)N)r�r%r&rr"r'� _clear_dictr )rfr�r%r&rIr�rrrr$Ys"   z_patch_dict._patch_dictc CsV|j}|j}t|�y|j|�Wn.tk rPx|D]}||||<q8WYnXdS)N)r%r'r+r r")rfr%rIr�rrrr(ss z_patch_dict._unpatch_dictcGs |j�dS)zUnpatch the dict.F)r()rfr+rrrr �sz_patch_dict.__exit__N) r5r8rhr6r!r$rr r$r(r rrrrrrr$s   r$c CsBy |j�Wn0tk r<t|�}x|D] }||=q*WYnXdS)N)r&r"r>)r%�keysr�rrrr+�s   r+cCs xttj�D] }|j�q WdS)z7Stop all active patches. LIFO to unroll nested patches.N)r�r�rr)rrrr�_patch_stopall�sr-Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index trunc floor ceil bool next zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr)r�nrrrr��sr�ccs|]}d|VqdS)zr%sNr)rr/rrrr��s�__get__�__set__� __delete__� __reversed__� __missing__� __reduce__� __reduce_ex__Z__getinitargs__�__getnewargs__� __getstate__� __setstate__� __getformat__� __setformat__rgr��__subclasses__� __format__�__getnewargs_ex__cs�fdd�}||_|S)z:Turns a callable object (like a mock) into a real functioncs�|f|�|�S)Nr)rfr+r�)r'rr�method�sz_get_method.<locals>.method)r5)rr'r?r)r'rr��s r�cCsh|] }d|�qS)z__%s__r)rr?rrrr�srmr�r!r�� __prepare__�__instancecheck__�__subclasscheck__�__del__cCs tj|�S)N)r��__hash__)rfrrrr��sr�cCs tj|�S)N)r��__str__)rfrrrr��scCs tj|�S)N)r�� __sizeof__)rfrrrr��s)rDrErFr�y�?g�?) �__lt__�__gt__�__le__�__ge__�__int__r��__len__r � __complex__� __float__�__bool__� __index__cs�fdd�}|S)Ncs$�jj}|tk r|S�|kr dStS)NT)�__eq__rrr�NotImplemented)�other�ret_val)rfrrrQ�s z_get_eq.<locals>.__eq__r)rfrQr)rfr�_get_eq�s rUcs�fdd�}|S)Ncs �jjtk rtS�|krdStS)NF)�__ne__rrrrR)rS)rfrrrV�s  z_get_ne.<locals>.__ne__r)rfrVr)rfr�_get_ne�s rWcs�fdd�}|S)Ncs �jj}|tkrtg�St|�S)N)r�rrrr�)rT)rfrrr��sz_get_iter.<locals>.__iter__r)rfr�r)rfr� _get_iter�s rX)rQrVr�c Cs�tj|t�}|tk r||_dStj|�}|dk rdy ||�}Wntk rXt|�}YnX||_dStj|�}|dk r�||�|_dS)N)�_return_valuesrCrrY�_calculate_return_valuer"�_side_effect_methodsr_)r1r?rZfixedZreturn_calulatorrYZ side_effectorrrr�_set_return_values    r\c@seZdZdd�Zdd�ZdS)� MagicMixincOs&|j�tt|�j||�|j�dS)N)�_mock_set_magicsr�r]r!)rfr+r�rrrr!(szMagicMixin.__init__cCs�t}t|dd�dk rTtj|j�}t�}t|}x$|D]}|t|�jkr4t||�q4W|tt|�j�}t|�}x|D]}t||t ||��qtWdS)Nr�) �_magicsr<� intersectionr�rorrBr�rz� MagicProxy)rfZ these_magicsZ remove_magicsr�r�rrrr^.s   zMagicMixin._mock_set_magicsN)r5r8rhr!r^rrrrr]'sr]c@seZdZdZddd�ZdS)r z-A version of `MagicMock` that isn't callable.FcCs|j||�|j�dS)z�Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.N)r�r^)rfr�r�rrrr�Gs z"NonCallableMagicMock.mock_add_specN)F)r5r8rhr6r�rrrrr Esc@seZdZdZddd�ZdS)ra� MagicMock is a subclass of Mock with default implementations of most of the magic methods. You can use MagicMock without having to configure the magic methods yourself. If you use the `spec` or `spec_set` arguments then *only* magic methods that exist in the spec will be created. Attributes and the return value of a `MagicMock` will also be `MagicMocks`. FcCs|j||�|j�dS)z�Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.N)r�r^)rfr�r�rrrr�]s zMagicMock.mock_add_specN)F)r5r8rhr6r�rrrrrRs c@s.eZdZdd�Zdd�Zdd�Zd dd �ZdS) racCs||_||_dS)N)rr�)rfrr�rrrr!iszMagicProxy.__init__cOs|j�}|||�S)N)� create_mock)rfr+r,�mrrrr$mszMagicProxy.__call__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rzr\)rfr�r�rcrrrrbqs  zMagicProxy.create_mockNcCs|j�S)N)rb)rfrr�rrrr0zszMagicProxy.__get__)N)r5r8rhr!r$rbr0rrrrrahs rac@s(eZdZdZdd�Zdd�Zdd�ZdS) �_ANYz2A helper object that compares equal to everything.cCsdS)NTr)rfrSrrrrQ�sz _ANY.__eq__cCsdS)NFr)rfrSrrrrV�sz _ANY.__ne__cCsdS)Nz<ANY>r)rfrrrrg�sz _ANY.__repr__N)r5r8rhr6rQrVrgrrrrrdsrdcCsdd|}d}djdd�|D��}djdd�t|j��D��}|rD|}|r\|rT|d7}||7}||S)Nz%s(%%s)r�z, cSsg|] }t|��qSr)�repr)rr�rrrr��sz*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�rprrrr��s)r�r�r�)rr+r,r�Zformatted_argsZ args_stringZ kwargs_stringrrrr��sr�c@sveZdZdZfddddfdd�Zfddddfdd �Zd d �ZejZd d �Z dd�Z dd�Z dd�Z dd�Z dd�ZdS)r�a� A tuple for holding the results of a call to a mock, either in the form `(args, kwargs)` or `(name, args, kwargs)`. If args or kwargs are empty then a call tuple will compare equal to a tuple without those values. This makes comparisons less verbose:: _Call(('name', (), {})) == ('name',) _Call(('name', (1,), {})) == ('name', (1,)) _Call(((), {'a': 'b'})) == ({'a': 'b'},) The `_Call` object provides a useful shortcut for comparing with call:: _Call(((1, 2), {'a': 3})) == call(1, 2, a=3) _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3) If the _Call has no name then it will match any name. r�NFTc Cs�f}i}t|�}|dkr$|\}}}nr|dkrd|\} } t| t�rX| }t| t�rR| }qb| }q�| | }}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�tj|||f�Stj||||f�S)Nr�rbr�)r�rr"r?r�) r�rprr�r�� from_kallr+r,�_len�first�secondrrrr��s.      z _Call.__new__cCs||_||_||_dS)N)rvrt�_mock_from_kall)rfrprr�r�rfrrrr!�sz_Call.__init__c Csf|tkr dSy t|�}Wntk r,dSXd}t|�dkrH|\}}n |\}}}t|dd�rzt|dd�rz|j|jkrzdSd}|dkr�fi}}n�|dkr�|\}}}n�|dkr�|\} t| t�r�| }i}n"t| t�r�| }fi}}nf}| }nV|dk�r>|\} } t| t��r2| }t| t��r&| i}}n f| }}n | | }}ndS|�rV||k�rVdS||f||fkS) NTFr�rbrtrr�r�)rr�r�r<rtrr?r") rfrSZ len_otherZ self_nameZ self_argsZ self_kwargsZ other_nameZ other_argsZ other_kwargsrprhrirrrrQ�sP                z _Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)Nr�z())r)rr�)rvr�)rfr+r,rrrrr$s  z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rrfz%s.%s)rr�rf)rvr�)rfrrrrrrms  z_Call.__getattr__cOs|jd�||�S)Nr�)rm)rfr+r,rrrr�$sz _Call.countcOs|jd�||�S)N�index)rm)rfr+r,rrrrk'sz _Call.indexcCs||js&|jpd}|jd�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|jd�shd|}nd|}t|||�S)Nrz()zcall%srbzcall.%s)rjrvrr�r�)rfrr+r,rrrrg*s       z_Call.__repr__cCs8g}|}x"|dk r*|jr"|j|�|j}q Wtt|��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)rjr�rtrUr�)rf�valsr�rrr� call_list?s   z_Call.call_list)r5r8rhr6r�r!rQr�rVr$rmr�rkrgrmrrrrr��s  7r�)rfcKs,t|�rt|�}t|t�}d|i}|r0d|i}n |dkr<i}|rL|rLd|d<|j|�t}tj|�rji}n$t|�sxt}n|r�|r�t |� r�t}|j d|�}|} |dkr�d} |f||| |d�|��} t|t �r�t | |�} nt || ||�|dk o�| �r| |j|<|�r,| �r,d |k�r,t||dd | d �| _x�t|�D]�} t| ��rH�q6yt|| �} Wntk �rp�w6YnXd| i}|�r�d| i}t| t ��s�t| || | |�} | | j| <nZ| }t|t ��r�| j}t|| |�}||d <tf|| | |d �|��} | | j| <t | | |d�t| t ��r6t| | | ��q6W| S)aICreate 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�rr�)r�r�r�rrYz())r3rr�r�)r�rr�r�)r2)r@rrr rr%Zisdatadescriptorr=r rEr�r#rMr4r`rrYr�rdr<r"r�r1� _must_skiprz)r�r�r3r�rr,�is_typerrr�r1r�rIr�r�r2rrrrPst                    cCs|t|t�s$|t|di�krdS|j}xR|jD]H}|jj|t�}|tkrHq,t|tt f�rZdStt|dd�t �rp|SdSq,W|S)z[ Return whether we should skip the first argument on spec's `entry` attribute. rBFr0N) rrr<r�rArBrCr� staticmethod� classmethod�MethodWrapperTypes)r�r�ror�rJrrrrn�s  rnc Cs$y|jStk rt|�SXdS)N)r�r"r)rrrrr��sr�c@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dS)N)r��idsr�r�r3r)rfr�r�r�rrsr3rrrr!�s z_SpecState.__init__)FNNNF)r5r8rhr!rrrrr��sr�c#spt|t�rdnd��fdd�|j��D�}|d�krD|dd�}n|ddd �|d <x|D] }|Vq^WdS) N� � csg|] }|��qSrr)r�l)�seprrr� sz&_iterate_read_data.<locals>.<listcomp>r����rxrxrxrx)r�bytesr�)� read_dataZ data_as_list�liner)rwr�_iterate_read_data s  r|r�cs���fdd�}���fdd�}���fdd��tdkr`ddl}ttt|j��jtt|j����a|dkrttd t d �}ttd ����j _ t ��dg�d�j _ d�j_ d�j_ d�j_ |�j_���d <�d �j_|�j_����fd d�}||_�|_ |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` methoddline`, and `readlines` of the file handle to return. This is an empty string by default. cs �jjdk r�jjSt�d�S)Nr)� readlinesrYr>)r+r,)�_state�handlerr�_readlines_side_effect( s z)mock_open.<locals>._readlines_side_effectcs(�jjdk r�jjSt���j�d�S)Nr)�readrYrr�)r+r,)r~rrzrr�_read_side_effect- s z$mock_open.<locals>._read_side_effectc3sJ�jjdk rx�jjVqWx�dD] }|Vq&Wxt���Vq6WdS)Nr)�readlinerYr)r{)r~rrzrr�_readline_side_effect2 s  z(mock_open.<locals>._readline_side_effectNr�open)rr�)r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)r|r�r_r)r+r,)r�r~rrzrr� reset_dataS s    zmock_open.<locals>.reset_data)� file_spec�_ior>ror�� TextIOWrapper�union�BytesIOrr�r rYr|�writer�r�r}r_)r1rzr�r�r�r�r)r�r~rrzrr  s.  "     c@s(eZdZdZdd�Zdd�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. cKs tf|�S)N)r)rfr,rrrr�i szPropertyMock._get_child_mockcCs|�S)Nr)rfrZobj_typerrrr0l szPropertyMock.__get__cCs ||�dS)Nr)rfrr�rrrr1n szPropertyMock.__set__N)r5r8rhr6r�r0r1rrrrr ` s) rrrrrrrrr r r r r )F)F)NFNNN)FFNN)Nr�)o�__all__� __version__r%r�r �builtins�typesr� functoolsrrr�r� BaseExceptionr�platformrZlangZ Throwabler �superr�rr r(r4r/r=r@rErMrHrdr�rerirrZMISSINGr�ZDELETEDr�rqr|rr>rUr�r�r�r r�r�rr�r�r�r�r r!r#rr$r+r-rnZmultipleZstopallrZ magic_methodsZnumericsr�r�Zinplace�rightZ _non_defaultsr�r_r�r�rZrRrYrUrWrXr[r\r]r rrardrr�r?r�rrrnr�r�rrQr#r0rrr�r|r r rrrr�<module>s     4  i5 ,   1Jv        ,  w  D