ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python34/lib64/python3.4/unittest/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/unittest/__pycache__/mock.cpython-34.pyo

�
j f�,�@s�dddddddddd	d
ddf
Zd
ZddlZddlZddlZddlmZmZefZ	dej
kr�ddlZeejj
fZ	ndZeZdd�Zdd�ZGdd�de�Zeej�efZdd�Zddd�Zdd�Zd d!�Zd"d#�Zd$d%�Zdd&d'�Zd(d)�Z d*d+�Z!Gd,d-�d-e�Z"Gd.d/�d/e�Z#e#�Z$e$j%Z%e$j&Z'e$j(Z)d0d1�Z*e+d2d3d4d5d6d7d8d9g�Z,d:d;�Z-Gd<d=�d=e.�Z/d>d?�Z0Gd@dA�dAe�Z1GdBdC�dCe�Z2GdDd	�d	e2�Z3dEdF�Z4GdGdH�dHe2�Z5GdId�de5e3�Z6dJdK�Z7dLdM�Z8dNdO�Z9GdPdQ�dQe�Z:dRdS�Z;e%ddddddTdU�Z<ddddddVdW�Z=e%ddddddXd�Z>GdYdZ�dZe�Z?d[d\�Z@d]d^�ZAe<e>_e?e>_Be=e>_CeAe>_Dd_e>_Ed`ZFdaZGdbjHdcdd�eGjI�D��ZJdbjHdedd�eGjI�D��ZKe+dfdd�dgdhdidjdkdldmdndodpdqdrdsdtdudvdwgD��ZLdxdy�ZMe+dzdd�dbjHeFeGeJeKg�jI�D��ZNeNeLBZOe+d{d|d}d~dd�d�g�ZPid�d��d�6d�d��d�6d�d��d�6ZQieRd�6eRd�6eRd�6eRd�6d�d�6dd�6dd�6dd�6d�d�6d�d�6dd�6d�d�6ZSd�d��ZTd�d��ZUd�d��ZVieTd�6eUd�6eVd�6ZWd�d��ZXGd�d��d�e�ZYGd�d
�d
eYe3�ZZGd�d�deYe6�Z[Gd�d��d�e�Z\Gd�d��d�e�Z]e]�Z^d�d��Z_Gd�d��d�e`�Zaead�d�Zbddddd�d�Zcd�d��Zdd�d��ZeGd�d��d�e�Zfeec�ee^jg�fZhee^jgji�fZjdakd�d��Zldd�d�d�ZmGd�d�de6�ZndS)��Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMockz1.0�N)�wraps�partial�javaTcCstt|�t�S)N)�
issubclass�typer
)�obj�r�2/opt/alt/python34/lib64/python3.4/unittest/mock.py�_is_instance_mock.srcCs+t|t�p*t|t�o*t|t�S)N)�
isinstance�BaseExceptionsrr)rrrr�
_is_exception4src@seZdZdgZdS)�_slotted�aN)�__name__�
__module__�__qualname__�	__slots__rrrrr;srcCs�t|t�rE|rEy
|j}Wntk
r;dSYnXd}n8t|t�s}y
|j}Wq}tk
rydSYq}Xn|r�t|d�}n|}y|tj|�fSWnt	k
r�dSYnXdS)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)�funcZas_instanceZeat_selfZsig_funcrrr�_get_signature_objectEs$

		


r(Fcs`t|||���dkr"dS�\}��fdd�}t||�|t|�_dS)Ncs�j||�dS)N)�bind)�
_mock_self�args�kwargs)�sigrr�checksigjsz"_check_signature.<locals>.checksig)r(�_copy_func_detailsr�_mock_check_sig)r'�mock�	skipfirst�instancer.r)r-r�_check_signaturees
r4c#Cs�|j|_|j|_y|j|_Wntk
r<YnXy|j|_Wntk
raYnXy|j|_Wntk
r�YnXy|j|_Wntk
r�YnXdS)N)r�__doc__�__text_signature__r"r�__defaults__�__kwdefaults__)r'�funcopyrrrr/ps$



r/cCs3t|t�rdSt|dd�dk	r/dSdS)NTr$F)rr�getattr)rrrr�	_callable�s
r;cCst|�ttfkS)N)r�list�tuple)rrrr�_is_list�sr>cCs`t|t�s%t|dd�dk	Sx4|f|jD]"}|jjd�dk	r6dSq6WdS)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rCcs�t|�sdSt|t�}t|||�}|dkrAdS|\}��fdd�}t||�|j}|j�s�d}ni|d6|d6}d|}	t|	|�||}
t|
|�|
S)Ncs�j||�dS)N)r))r+r,)r-rrr.�sz _set_signature.<locals>.checksigr9Z
_checksig_r1zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))	r;rrr(r/r�isidentifier�exec�_setup_func)r1�originalr3r2�resultr'r.�name�context�srcr9r)r-r�_set_signature�s$
		



rLcs��_t��sdS�fdd�}�fdd�}�fdd�}�fdd�}��fd	d
�}d�_d�_d�_t��_t��_t��_�j	�_	�j
�_
�j�_|�_|�_
|�_|�_|�_��_dS)
Ncs�j||�S)N)�assert_called_with)r+r,)r1rrrM�sz'_setup_func.<locals>.assert_called_withcs�j||�S)N)�assert_called_once_with)r+r,)r1rrrN�sz,_setup_func.<locals>.assert_called_once_withcs�j||�S)N)�assert_has_calls)r+r,)r1rrrO�sz%_setup_func.<locals>.assert_has_callscs�j||�S)N)�assert_any_call)r+r,)r1rrrP�sz$_setup_func.<locals>.assert_any_callcsTt��_t��_�j��j}t|�rP|�k	rP|j�ndS)N)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer)�ret)r9r1rrrT�s
	z_setup_func.<locals>.reset_mockFr)r1r�called�
call_count�	call_argsrQ�call_args_listrRrSrU�side_effect�_mock_childrenrMrNrOrPrT�_mock_delegate)r9r1rMrNrOrPrTr)r9r1rrF�s.									rFcCsd|dd�|kS)Nz__%s__����r)rIrrr�	_is_magic�sr`c@s.eZdZdZdd�Zdd�ZdS)�_SentinelObjectz!A unique, named, sentinel object.cCs
||_dS)N)rI)�selfrIrrrr!�sz_SentinelObject.__init__cCsd|jS)Nzsentinel.%s)rI)rbrrr�__repr__�sz_SentinelObject.__repr__N)rrrr5r!rcrrrrra�srac@s.eZdZdZdd�Zdd�ZdS)�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.cCs
i|_dS)N)�
_sentinels)rbrrrr!�sz_Sentinel.__init__cCs.|dkrt�n|jj|t|��S)N�	__bases__)r"re�
setdefaultra)rbrIrrr�__getattr__�s	z_Sentinel.__getattr__N)rrrr5r!rhrrrrrd�srdcCs2t|�ttttfkr.t|�|�S|S)N)r�dictr<r=�set)�valuerrr�_copysrlrU�_mock_return_valuer[�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCsHtj|�d|}||dd�}||dd�}t||�S)NZ_mock_cSs/|j}|dkr"t||�St||�S)N)r]r:)rbrI�	_the_namer-rrr�_gets	
z"_delegating_property.<locals>._getcSs9|j}|dkr%||j|<nt|||�dS)N)r]r@�setattr)rbrkrIrsr-rrr�_set#s	z"_delegating_property.<locals>._set)�_allowed_names�add�property)rIrsrtrvrrr�_delegating_propertys


rzc@s(eZdZdd�Zdd�ZdS)rQcCs�t|t�stj||�St|�}t|�}||krGdSxCtd||d�D]*}||||�}||kr_dSq_WdS)NFr�T)rr<�__contains__�len�range)rbrkZ	len_valueZlen_self�iZsub_listrrrr|0sz_CallList.__contains__cCstjt|��S)N)�pprintZpformatr<)rbrrrrc>sz_CallList.__repr__N)rrrr|rcrrrrrQ.srQcCs�t|�sdS|js@|js@|jdk	s@|jdk	rDdS|}x)|dk	ru||kridS|j}qMW|r�||_||_n|r�||_||_ndS)NFT)rrqrrrorp)�parentrkrI�new_name�_parentrrr�_check_and_set_parentBs$
		r�c@s4eZdZdd�Zdd�Zdd�ZdS)�	_MockItercCst|�|_dS)N)�iterr)rbrrrrr!\sz_MockIter.__init__cCs|S)Nr)rbrrr�__iter__^sz_MockIter.__iter__cCs
t|j�S)N)�nextr)rbrrr�__next__`sz_MockIter.__next__N)rrrr!r�r�rrrrr�[sr�c@s(eZdZeZdZdd�ZdS)�BaseNcOsdS)Nr)rbr+r,rrrr!fsz
Base.__init__)rrrrrmrnr!rrrrr�csr�c@s�eZdZdZdd�Zdddddddddddd�
Zd	d
�Zddd�Zddd
d�Zdd�Z	dd�Z
dZee	e
e�Z
edd��Zed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�Zddd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Z d1d2�Z!d3d4�Z"d5d6�Z#dd7d8�Z$d9d:�Z%d;d<�Z&dS)=r
z A non-callable version of `Mock`cOs5t|j|fi|jd6�}tj|�}|S)Nr5)rrr5�object�__new__)�clsr+�kw�newr3rrrr�ns"zNonCallableMock.__new__N�Fc
Ks4|dkr|}n|j}||d<||d<||d<||d<|dk	ra|}d}n|
dkr||dk	}
n|j|||	|
�i|d<||d<d|d<d	|d
<d|d<d|d
<t�|d<t�|d<t�|d<|r|j|�ntt|�j||||||�dS)NrorqrrrpTr\�_mock_wrapsr]FZ_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrR)r@�_mock_add_specrQ�configure_mock�_safe_superr
r!)
rb�specrrI�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfr,r@rrrr!ws6		



	








zNonCallableMock.__init__cCs8d|_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�)rorprqrrru)rbr1�	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�)rbr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_specc	Cs�d}d}|dk	rzt|�rzt|t�r=|}nt|�}t|||�}|oh|d}t|�}n|j}||d<||d<||d<||d<dS)Nr{�_spec_class�	_spec_set�_spec_signature�
_mock_methods)r>rr�
_get_classr(�dirr@)	rbr�r�r�r�r�r��resr@rrrr��s		


zNonCallableMock._mock_add_speccCs[|j}|jdk	r'|jj}n|tkrW|jd|dd�}||_n|S)Nr�r�z())rmr]rUr�_get_child_mock)rbrVrrrZ__get_return_value�s		z"NonCallableMock.__get_return_valuecCs>|jdk	r||j_n||_t||dd�dS)Nz())r]rUrmr�)rbrkrrrZ__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)rbrrr�	__class__�s
zNonCallableMock.__class__rWrXrYrZrScCsj|j}|dkr|jS|j}|dk	rft|�rft|t�rft|�}||_n|S)N)r]rnr[�callablerr�)rb�	delegatedZsfrrrZ__get_side_effect�s		)z!NonCallableMock.__get_side_effectcCs:t|�}|j}|dkr-||_n	||_dS)N)�	_try_iterr]rnr[)rbrkr�rrrZ__set_side_effect�s
	z!NonCallableMock.__set_side_effectcCs�|dkrg}nt|�|kr+dS|jt|��d|_d|_d|_t�|_t�|_t�|_x9|j	j
�D](}t|t�r�q�n|j
|�q�W|j}t|�r�||k	r�|j
|�ndS)z-Restore the mock object to its initial state.NFr)�id�appendrWrYrXrQrSrZrRr\�valuesr�
_SpecStaterTrmr)rbZvisitedZchildrVrrrrT
s$					zNonCallableMock.reset_mockcKs�x}t|j�ddd��D]]\}}|jd�}|j�}|}x|D]}t||�}qSWt|||�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)�keycSs|djd�S)Nr�.)�count)�entryrrr�<lambda>0sz0NonCallableMock.configure_mock.<locals>.<lambda>r�N)�sorted�items�split�popr:ru)rbr,�arg�valr+�finalrr�rrrr�#s	
zNonCallableMock.configure_mockcCs]|dkrt|��n[|jdk	r[||jksE|tkrvtd|��qvnt|�rvt|��n|jj|�}|tkr�t|��n�|dkrd}|jdk	r�t|j|�}n|j	d|d|d|d|d|�}||j|<nFt
|t�rYt|j
|j|j|j|j�}||j|<n|S)Nr�zMock object has no attribute %rr�rIrr�r�)r"r��_all_magicsr`r\rA�_deletedr�r:r�rr�rr�r�r3r�rI)rbrIrHrrrrrh9s0		zNonCallableMock.__getattr__c
Cs�|jg}|j}|}d}|dgkr9d}nt�}xz|dk	r�|}|j|j|�d}|jdkr�d}n|j}t|�|kr�Pn|jt|��qEWtt|��}|jp�d}t	|�dkr|dd
kr|d7}qn||d<dj
|�}d}|dkrJd	|}nd}	|jdk	r�d
}	|jrwd}	n|	|jj
}	ndt|�j
||	t|�fS)Nr��()r�r1r{�().r�mock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�)zmockr�)rrrprjr�r�rxr<�reversedrqr}�joinr�r�rr)
rbZ
_name_listr��last�dot�seenZ_firstrIZname_stringZspec_stringrrrrc\sL					

		zNonCallableMock.__repr__cCs�tstj|�S|jpg}tt|��}t|j�}dd�|D�}dd�|D�}tt	|||t|j
���S)z8Filter the output of `dir(mock)` to only useful members.cSs%g|]}|jd�s|�qS)�_)�
startswith)�.0�errr�
<listcomp>�s	z+NonCallableMock.__dir__.<locals>.<listcomp>cSs2g|](}|jd�s(t|�r|�qS)r�)r�r`)r�r�rrrr��s	)r	r��__dir__r�r�rr<r@r�rjr\)rbZextrasZ	from_typeZ	from_dictrrrr��s
zNonCallableMock.__dir__cs�|tkrtj�||�S�jrh�jdk	rh|�jkrh|�jkrhtd|��n"|tkr�d|}t|��n�|tkrL�jdk	r�|�jkr�td|��nt	|�st
t��|t||��|���fdd�}q�t
�|d|�t
t��||�|�j|<n>|dkre|�_dSt
�|||�r�|�j|<ntj�||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��||�S)Nr)r+r�)rGrbrrr��sz-NonCallableMock.__setattr__.<locals>.<lambda>r�)rwr��__setattr__r�r�r@r"�_unsupported_magicsr�rrur�_get_methodr�r\r�)rbrIrk�msgr)rGrbrr��s2
	zNonCallableMock.__setattr__cCs�|tkrJ|t|�jkrJtt|�|�||jkrJdSn||jkrltj||�n|jj|t�}|t	kr�t
|��n|tk	r�|j|=nt	|j|<dS)N)r�rr@�delattrr��__delattr__r\rA�_missingr�r")rbrIrrrrr��s!
zNonCallableMock.__delattr__cCs|jpd}t|||�S)Nr1)rq�_format_call_signature)rbr+r,rIrrr�_format_mock_call_signature�sz+NonCallableMock._format_mock_call_signaturecCscd}|j||�}|j}t|�dkrF|dd�}n|j|�}|||fS)Nz!Expected call: %s
Actual call: %s�r{)r�rYr})rbr+r,�message�expected_stringrYZ
actual_stringrrr�_format_mock_failure_message�s	z,NonCallableMock._format_mock_failure_messagecCs�|j}|dk	r�t|�dkr<d}|\}}n|\}}}y||j||�fSWq�tk
r�}z|jd�SWYdd}~Xq�Xn|SdS)a
        Given a call (or simply a (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.
        Nr^r�)r�r}r)�	TypeError�with_traceback)rb�_callr-rIr+r,r�rrr�
_call_matcher�s	#zNonCallableMock._call_matchercs�|��jdkr=�j���}td|f��n���fdd�}�j��f�}�j�j�}||kr�t|t�r�|nd}t|��|�ndS)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,rbrr�_error_messagesz:NonCallableMock.assert_called_with.<locals>._error_message)rYr��AssertionErrorr�r�	Exception)r*r+r,�expectedr��actual�causer)r+r,rbrrM�sz"NonCallableMock.assert_called_withcOsP|}|jdks@d|jp$d|jf}t|��n|j||�S)zVassert that the mock was called exactly once and with the specified
        arguments.r{z1Expected '%s' to be called once. Called %s times.r1)rXrqr�rM)r*r+r,rbr�rrrrNsz'NonCallableMock.assert_called_once_withcs
�fdd�|D�}t|t�r.|nd}t�fdd��jD��}|s�||kr�td|�jf�|�ndSt|�}g}xA|D]9}y|j|�Wq�tk
r�|j|�Yq�Xq�W|rtdt	|�f�|�ndS)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)rbrrr�!s	z4NonCallableMock.assert_has_calls.<locals>.<listcomp>Nc3s|]}�j|�VqdS)N)r�)r�r�)rbrr�	<genexpr>#sz3NonCallableMock.assert_has_calls.<locals>.<genexpr>z(Calls not found.
Expected: %r
Actual: %rz%r not all found in call list)
rr�rQrSr�r<�remover&r�r=)rbZcallsZ	any_orderr�r�Z	all_callsZ	not_foundZkallr)rbrrOs*
"	

z NonCallableMock.assert_has_callscs��j||f�}�fdd��jD�}||kr�t|t�rR|nd}�j||�}td|�|�ndS)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�)r�r�)rbrrr�As	z3NonCallableMock.assert_any_call.<locals>.<listcomp>Nz%s call not found)r�rZrr�r�r�)rbr+r,r�r�r�r�r)rbrrP:s
zNonCallableMock.assert_any_callcKset|�}t|t�sNt|t�r3t}q[t|t�r[t}q[n
|jd}||�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�
CallableMixinrrr
rr?)rbr��_type�klassrrrr�Js	
zNonCallableMock._get_child_mock)'rrrr5r�r!r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docryrUr�rzrWrXrYrZrSZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr[rTr�rhrcr�r�r�r�r�r�rMrNrOrPr�rrrrr
ksL
(
	
		
#2"
#cCs[|dkr|St|�r |St|�r0|Syt|�SWntk
rV|SYnXdS)N)rr;r�r�)rrrrr�^s
r�c@s^eZdZddeddddddddd�
Zdd�Zdd�Zd	d
�ZdS)r�Nr�c
KsH||jd<tt|�j|||||||	|
|�||_dS)Nrm)r@r�r�r!r[)rbr�r[rUrrIr�r�r�r�r�r,rrrr!ps

zCallableMixin.__init__cOsdS)Nr)rbr+r,rrrr0}szCallableMixin._mock_check_sigcOs |j||�|j||�S)N)r0�
_mock_call)r*r+r,rrrr$�szCallableMixin.__call__cOs�|}d|_|jd7_|j}|j}t||fdd�}||_|jj|�|jjtd||f��t	�}|dk}|j
dk	}	|j}
x#|dk	r�t|||f�}|jr!d}|r�d}nd}|jdkr
d}n|j||}n|	r�||
kr<|}
nt|
||f�}
|jj|
�|j
dk	}	|	r�|jd|
}
q�n|jj|�|j}t
|�}||kr�Pn|j|�q�Wt}|j}|dk	r^t|�r|�nt|�sLt|�}t|�r0|�n|tkrH|j}n|S|||�}n|jdk	r�|jtkr�|j||�S|tkr�|j}n|S)NTr{�twor�z()r�F)rWrXrrrp�_CallrYrZr�rSrjrorqrRr�rxrr[rr;r�rUr�rm)r*r+r,rbr�r�r�r�Z
skip_next_dotZdo_method_callsrIZthis_mock_callr�Zthis_method_callZ_new_parent_id�ret_valZeffectrHrrrr��sp														zCallableMixin._mock_call)rrrrr!r0r$r�rrrrr�ns	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)rrrr5rrrrr�s1cCsAyt||�SWn)tk
r<t|�t||�SYnXdS)N)r:r"�
__import__)�thing�comp�import_pathrrr�_dot_lookups


r�cCs_|jd�}|jd�}t|�}x.|D]&}|d|7}t|||�}q1W|S)Nr�rz.%s)r�r�r�r�)�targetZ
componentsr�r�r�rrr�	_importers
r�cCs
t|d�S)N�is_local)�hasattr)�patcherrrr�_is_startedsr�c@s�eZdZdZgZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�ZdS)�_patchNc

Cs�|dk	rE|tk	r'td��n|dk	rEtd��qEn||_||_||_||_||_||_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)
rbr�r�r�r�r�r�r�r�r,rrrr!%s$										z_patch.__init__c
Csht|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|j��qSr)�copy)r��prrrr�Hs	z_patch.copy.<locals>.<listcomp>)r�r�r�r�r�r�r�r�r�r,�attribute_namer�)rbr�rrrr�@sz_patch.copycCs)t|t�r|j|�S|j|�S)N)rr�decorate_class�decorate_callable)rbr'rrrr$Ms
z_patch.__call__cCsyxrt|�D]d}|jtj�s+q
nt||�}t|d�sOq
n|j�}t||||��q
W|S)Nr$)r�r�r�TEST_PREFIXr:r�r�ru)rbr��attr�
attr_valuer�rrrrSsz_patch.decorate_classcsTt�d�r#�jj|��St����fdd���|g�_�S)N�	patchingscsg}g}t�}z�y�xh�jD]]}|j�}|j|�|jdk	rc|j|�q%|jtkr%|j|�q%q%W|t|�7}�||�SWn?||kr�t|�r�|j|�nt	j
�}�YnXWdx!t|�D]}|j|�q�WXdS)N)
r=r�	__enter__r�r��updater�rr��sys�exc_infor��__exit__)r+Zkeywargs�
extra_argsZentered_patchersr	�patchingr�)r'�patchedrrr
fs*	
z)_patch.decorate_callable.<locals>.patched)r�rr�r)rbr'r)r'r
rras!z_patch.decorate_callablecCs�|j�}|j}t}d}y|j|}Wn*ttfk
r^t||t�}YnXd}|jr�|tkr�td||f��n||fS)NFTz!%s does not have the attribute %r)r�r�rr@r"�KeyErrorr:r�)rbr�rIrG�localrrr�get_original�s	z_patch.get_originalcCs�|j|j|j}}}|j|j}}|j}|j�|_|dkr]d}n|dkrrd}n|dkr�d}n|dk	r�|dk	r�td��n|dk	s�|dk	r�|dkr�td��n|j	�\}}|t
kr\|dkr\d}	|dkrA|}|dkr�|}d}q�n?|dk	rk|dkr�|}d}q�n|dkr�|}n|dk	s�|dk	r�|t
kr�td��nt|t�r�d}	q�nt
}
i}|dk	r�|}
nm|dk	s|dk	r\|}|dk	r"|}nt|�r=d|k}
n
t|�}
|
r\t}
q\n|dk	ru||d<n|dk	r�||d	<nt|
t�r�t|
t�r�|jr�|j|d
<n|j|�|
|�}|	r�t|�r�|}|dk	r|}nt|�r.t|�r.t}
n|jd
�|
d|dd
|�|_q�n�|dk	r�|t
k	r�td��n|t
kr�td��nt|�}|dkr�|}nt|d	|d|j|�}n|r�td��n|}||_||_t|j|j|�|jdk	r�i}|jt
krW|||j<nx<|jD]1}|j �}|jt
kra|j|�qaqaW|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�rIr�r�z()zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True�_namez.Can't pass kwargs to a mock we aren't creating)TN)!r�r�r�r�r,r�r�r�r�rrrrrr>r�rrr
r�rrrCr�rU�boolr�
temp_originalr�rur�r�r)rbr�r�r�r�r,r�rGrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrrr�rrrr�s�							



	

	
			z_patch.__enter__cGs�t|�std��n|jrO|jtk	rOt|j|j|j�nOt|j|j�|j	r�t
|j|j�r�t|j|j|j�n|`|`|`x3t|j�D]"}t|�r�|j
|�q�q�WdS)zUndo the patch.z stop called on unstarted patcherN)r��RuntimeErrorr�rrrur�r�r�r�r�r�r�r
)rbr	r�rrrr
s z_patch.__exit__cCs |j�}|jj|�|S)z-Activate a patch, returning any created mock.)r�_active_patchesr�)rbrHrrr�start1sz_patch.startcCs3y|jj|�Wntk
r(YnX|j�S)zStop an active patch.)rr�r&r
)rbrrr�stop8s

z_patch.stop)rrrr�rr!r�r$rrrrr
rrrrrrr� s
(~r�csfy�jdd�\�}Wn+ttfk
rItd�f��YnX�fdd�}||fS)Nr�r{z.Need a valid target to patch. You supplied: %rcs
t��S)N)r�r)r�rrr�Jsz_get_target.<locals>.<lambda>)�rsplitr�r&)r�r�r�r)r�r�_get_targetDsrc

s4�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_objectNsrc
s�t��tkr'�fdd�}n�fdd�}|sNtd��nt|j��}|d\}	}
t||	|
|||||i�	}|	|_x[|dd�D]I\}	}
t||	|
|||||i�	}|	|_|jj|�q�W|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.
    cs
t��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�r�r�r�)
r�r�r�r�r�r�r,r�r�r�r�r�Zthis_patcherr)r�r�_patch_multiplegs&		rc

Ks4t|�\}}	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.
    )rr�)
r�r�r�r�r�r�r�r,r�r�rrrr�sEc@s|eZdZdZfddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
eZe
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|�}n||_t|�|_|jj|�||_d|_dS)N)	rrr��in_dictrir�r�clear�	_original)rbr r�r!r,rrrr!s		z_patch_dict.__init__csAt�t�r�j��St����fdd��}|S)Nc
s-�j�z�||�SWd�j�XdS)N)r�
_unpatch_dict)r+r�)�frbrr�_inners
z$_patch_dict.__call__.<locals>._inner)rrrr)rbr$r%r)r$rbrr$s
!z_patch_dict.__call__cCs�x~t|�D]p}t||�}|jtj�r
t|d�r
t|j|j|j	�}||�}t
|||�q
q
W|S)Nr$)r�r:r�rrr�rr r�r!ru)rbr�rrZ	decoratorZ	decoratedrrrrsz_patch_dict.decorate_classcCs|j�dS)zPatch the dict.N)r)rbrrrr%sz_patch_dict.__enter__cCs�|j}|j}|j}y|j�}Wn7tk
rdi}x|D]}||||<qHWYnX||_|r�t|�ny|j|�Wn1tk
r�x|D]}||||<q�WYnXdS)N)r�r r!r�r"r"�_clear_dictr)rbr�r r!rGr�rrrr*s"			

	


z_patch_dict._patch_dictcCse|j}|j}t|�y|j|�Wn1tk
r`x|D]}||||<qDWYnXdS)N)r r"r&rr")rbr rGr�rrrr#Ds		


z_patch_dict._unpatch_dictcGs|j�dS)zUnpatch the dict.F)r#)rbr+rrrr
Qs
z_patch_dict.__exit__N)
rrrr5r!r$rrrr#r
rrrrrrr�s
rcCsKy|j�Wn6tk
rFt|�}x|D]
}||=q1WYnXdS)N)r!r"r<)r �keysr�rrrr&Zs

r&cCs(x!ttj�D]}|j�qWdS)z7Stop all active patches. LIFO to unroll nested patches.N)r�r�rr)rrrr�_patch_stopallcsr(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 zAadd sub mul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr)r��nrrrr��sr�ccs|]}d|VqdS)zr%sNr)r�r*rrrr��sccs|]}d|VqdS)z__%s__Nr)r��methodrrrr��srArjZdeleter�Zmissing�reduceZ	reduce_exZgetinitargsZ
getnewargs�getstate�setstateZ	getformatZ	setformat�reprr�Z
subclasses�formatcs�fdd�}||_|S)z:Turns a callable object (like a mock) into a real functioncs�|||�S)Nr)rbr+r�)r'rrr+�sz_get_method.<locals>.method)r)rIr'r+r)r'rr��s	r�ccs|]}d|VqdS)z__%s__Nr)r�r+rrrr��srhr�r!r�Z__prepare____instancecheck__�__subclasscheck__�__del__cCs
tj|�S)N)r��__hash__)rbrrrr��sr�r3cCs
tj|�S)N)r��__str__)rbrrrr��sr4cCs
tj|�S)N)r��
__sizeof__)rbrrrr��sr5�__lt__�__gt__�__le__�__ge__r{�__int__r|�__len__r
y�?�__complex__g�?�	__float__�__bool__�	__index__cs�fdd�}|S)Ncs&�jj}|tk	r|S�|kS)N)�__eq__rmr)�otherr�)rbrrr@�sz_get_eq.<locals>.__eq__r)rbr@r)rbr�_get_eq�srBcs�fdd�}|S)Ncs �jjtk	rtS�|k	S)N)�__ne__rmr)rA)rbrrrC�sz_get_ne.<locals>.__ne__r)rbrCr)rbr�_get_ne�srDcs�fdd�}|S)Ncs,�jj}|tkr"tg�St|�S)N)r�rmrr�)r�)rbrrr��s
z_get_iter.<locals>.__iter__r)rbr�r)rbr�	_get_iter�srEr@rCr�cCs�tj|t�}|tk	r+||_dStj|�}|dk	r�y||�}Wntk
rvt|�}YnX||_dStj|�}|dk	r�||�|_ndS)N)�_return_valuesrArrU�_calculate_return_valuer"�_side_effect_methodsr[)r1r+rIZfixedZreturn_calulatorrUZ
side_effectorrrr�_set_return_value�s	
	rIc@s(eZdZdd�Zdd�ZdS)�
MagicMixincOs1|j�tt|�j||�|j�dS)N)�_mock_set_magicsr�rJr!)rbr+r�rrrr!�s
zMagicMixin.__init__cCs�t}t|dd�dk	r|tj|j�}t�}t|}x6|D]+}|t|�jkrJt||�qJqJWn|tt|�j�}t|�}x'|D]}t||t	||��q�WdS)Nr�)
�_magicsr:�intersectionr�rjrr@r�ru�
MagicProxy)rbZthese_magicsZ
remove_magicsr�r�rrrrK�s	


zMagicMixin._mock_set_magicsN)rrrr!rKrrrrrJ�srJc@s%eZdZdZddd�ZdS)rz-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�rK)rbr�r�rrrr�sz"NonCallableMagicMock.mock_add_specN)rrrr5r�rrrrrsc@s%eZdZdZddd�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�rK)rbr�r�rrrr�(szMagicMock.mock_add_specN)rrrr5r�rrrrrs
c@sCeZdZdd�Zdd�Zdd�Zddd	�ZdS)
rNcCs||_||_dS)N)rIr�)rbrIr�rrrr!4s	zMagicProxy.__init__cOs|j�}|||�S)N)�create_mock)rbr+r,�mrrrr$8szMagicProxy.__call__cCsT|j}|j}|jd|d|d|�}t|||�t|||�|S)NrIr�r�)rIr�r�rurI)rbr�r�rPrrrrO<s			zMagicProxy.create_mockNcCs
|j�S)N)rO)rbrr�rrr�__get__EszMagicProxy.__get__)rrrr!r$rOrQrrrrrN3s	rNc@s:eZdZdZdd�Zdd�Zdd�ZdS)	�_ANYz2A helper object that compares equal to everything.cCsdS)NTr)rbrArrrr@Msz_ANY.__eq__cCsdS)NFr)rbrArrrrCPsz_ANY.__ne__cCsdS)Nz<ANY>r)rbrrrrcSsz
_ANY.__repr__N)rrrr5r@rCrcrrrrrRJsrRcCs�d|}d}djdd�|D��}djdd�|j�D��}|r]|}n|r�|rv|d7}n||7}n||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)r/)r�r�rrrr�]s	z*_format_call_signature.<locals>.<listcomp>cSs&g|]\}}d||f�qS)z%s=%rr)r�r�rkrrrr�_s	)r�r�)rIr+r,r�Zformatted_argsZargs_stringZ
kwargs_stringrrrr�Zs
	

r�c@s�eZdZdZfdddddd�Zfdddddd�Zd	d
�Zdd�Zd
d�Zdd�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.
    NFTcCsd}f}i}t|�}|dkr<|\}}}n�|dkr�|\}	}
t|	t�r�|	}t|
t�r�|
}q�|
}q�|	|
}}nN|dkr�|\}t|t�r�|}q�t|t�r�|}q�|}n|rtj|||f�Stj||||f�S)Nr�r�r^r{)r}rrr=r�)r�rkrIr�r��	from_kallr+r,�_len�first�secondrrrr�s0						z
_Call.__new__cCs||_||_||_dS)N)rIr�rS)rbrkrIr�r�rSrrrr!�s		z_Call.__init__cCs�|tkrdSyt|�}Wntk
r8dSYnXd}t|�dkr`|\}}n|\}}}d}|dkr�fi}}n�|dkr�|\}}}n�|dkr|\}	t|	t�r�|	}i}q�t|	t�r|	}fi}}q�f}|	}np|dkr�|\}
}t|
t�rr|
}t|t�rb|i}}qf|}}q�|
|}}ndS|r�||kr�dS||f||fkS)NTFr�r^rr�r{)rr}r�rr=r)rbrAZ	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsrkrUrVrrrr@�sJ
				z_Call.__eq__cCs|j|�S)N)r@)rbrArrrrC�sz_Call.__ne__cOsW|jdkr(td||fdd�S|jd}t|j||fd|d|�S)Nr�rIz()r�)rIr�)rbr+r,rIrrrr$�s
z_Call.__call__cCsN|jdkr"td|dd�Sd|j|f}td|d|dd�S)NrIrSFz%s.%sr�)rIr�)rbrrIrrrrh�sz_Call.__getattr__cCs�|js8|jpd}|jd�r4d|}n|St|�dkr_d}|\}}nD|\}}}|s}d}n&|jd�s�d|}n
d|}t|||�S)Nrz()zcall%sr^zcall.%s)rSrIr�r}r�)rbrIr+r,rrrrc�s	
	

z_Call.__repr__cCsQg}|}x2|dk	r@|jr4|j|�n|j}qWtt|��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)rSr�r�rQr�)rb�valsr�rrr�	call_lists	
z_Call.call_list)rrrr5r�r!r@rCr$rhrcrXrrrrr�ls 3r�rScKst|�rt|�}nt|t�}i|d6}|rMi|d6}n|dkrbi}n|r{|r{d|d<n|j|�t}t|�tkr�i}n7t|�s�t}n"|r�|r�t|�r�t}n|j	d|�}|}	|dkr
d}	n|d|d	|d
|	d||�}
t|t
�rRt|
|�}
nt||
||�|dk	r�|r�|
|j
|<n|r�|r�d|kr�t||ddd
dd|
�|
_nxNt|�D]@}t|�r�q�nyt||�}Wntk
rw�YnXi|d6}|r;i|d6}nt|t
�srt|||
||�}
|
|
j
|<n�|
}t|t
�r�|
j}nt|||�}||d<td|d|d
|d	||�}
|
|
j
|<t||
d|�t|
t
�r�t|
||
�q�q�W|
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�rIr�r�r�r�rUr3rz()r�r�r2)r>rrrr�DescriptorTypesr;rrCr�r#rLr4r\rrUr�r`r:r"r�r1�
_must_skipru)r�r�r3r�rr,�is_typerrr�r1r�rGr�r�r2rrrrst
	

				


	
cCs�t|t�s7|t|di�kr+dS|j}nxt|jD]i}|jj|t�}|tkrnqAnt|tt	f�r�dStt|dd�t
�r�|SdSqAW|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    r@FrQN)rrr:r�r?r@rAr�staticmethod�classmethod�MethodWrapperTypes)r�r�r[r�rHrrrrZ�srZcCs.y|jSWntk
r)t|�SYnXdS)N)r�r"r)rrrrr��s
r�c@s+eZdZddddddd�ZdS)r�FNcCs:||_||_||_||_||_||_dS)N)r��idsr�r�r3rI)rbr�r�r�rIr_r3rrrr!�s					z_SpecState.__init__)rrrr!rrrrr��sr�c#s�t|t�rdnd��fdd�|j��D�}|d�kr`|dd�}n|ddd	�|d
<x|D]}|VqWdS)Ns
�
csg|]}|��qSrr)r��l)�seprrr��s	z&_iterate_read_data.<locals>.<listcomp>r{���rcrcrcrc)r�bytesr�)�	read_dataZdata_as_list�liner)rbr�_iterate_read_data�s"
rgr�csw��fdd�}���fdd�}��fdd��tdkr�ddl}ttt|j��jtt|j����an|dkr�td	d
dt	�}ntdt����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)�	readlinesrUr<)r+r,)�_state�handlerr�_readlines_side_effect�s
z)mock_open.<locals>._readlines_side_effectcs6�jjdk	r�jjSt���j�d�S)Nr)�readrUrr�)r+r,)rirjrerr�_read_side_effect�s
z$mock_open.<locals>._read_side_effectc3sE�jjdk	r'x�jjVqWnx�dD]}|Vq2WdS)Nr)�readlinerU)rf)rirjrr�_readline_side_effect�s
z(mock_open.<locals>._readline_side_effectNrrI�openr�r{csJt���d<�jj�dkrF���d<�d�j_ntS)Nrr{)rgrnr[r)r+r,)rorirjrerr�
reset_data	s

zmock_open.<locals>.reset_data)�	file_spec�_ior<rjr��
TextIOWrapper�union�BytesIOrrprrUrg�writerlrnrhr[)r1rerkrmrsrqr)rorirjrerr�s.	6
		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
t|�S)N)r)rbr,rrrr�*	szPropertyMock._get_child_mockcCs|�S)Nr)rbrZobj_typerrrrQ-	szPropertyMock.__get__cCs||�dS)Nr)rbrr�rrr�__set__/	szPropertyMock.__set__N)rrrr5r�rQrxrrrrr
!	s)o�__all__�__version__r%r�r�	functoolsrr�
BaseExceptionr�platformrZlangZ	Throwabler	�superr�rrr�rrrryrYr(r4r/r;r>rCrLrFr`rardrrZMISSINGr�ZDELETEDr�rlrjrwrzr<rQr�r�r�r
r�r�rr�r�r�r�rrrrrr&r(riZmultipleZstopallrZ
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr�rLr�r�rG�NotImplementedrFrBrDrErHrIrJrrrNrRrr�r=r�rrrZr�r�r@r#rQr^rrrgrr
rrrr�<module>s			 +							��e5�%		1	Jv						""	(
	





	�	w	B

Zerion Mini Shell 1.0