Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.188.254.182
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : _mock_backport.pyc
�
>��cc@sydddddddddd	d
ddf
Zd
ZddlZddlZddlZddlZddlmZddlm	Z	m
Z
d�ee�D�Ze
fZdejkr�ddlZe
ejjfZneZeZd�Zd�Zdefd��YZeej�efZd�Ze d�Z!d�Z"d�Z#d�Z$d�Z%e d�Z&d�Z'd �Z(d!efd"��YZ)d#efd$��YZ*e*�Z+e+j,Z,e+j-Z.e+j/Z0d%�Z1e2d&d'd(d)d*d+d,d-g�Z3d.�Z4d/e5fd0��YZ6d1�Z7d2efd3��YZ8d4efd5��YZ9d	e9fd6��YZ:d7�Z;d8e9fd9��YZ<de<e:fd:��YZ=d;�Z>d<�Z?d=�Z@d>efd?��YZAd@�ZBe,eCe eCeCeCdA�ZDeCe eCeCeCdB�ZEe,eCe eCeCeCdC�ZFdDefdE��YZGdF�ZHdG�ZIeDeF_eGeF_JeEeF_KeIeF_LdHeF_MdIZNdJZOdKjPdL�eOjQ�D��ZRdKjPdM�eOjQ�D��ZSe2dN�dOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_gD��ZTd`�ZUe2da�dKjPeNeOeReSg�jQ�D��ZVeVeTBZWe2dbdcdddedfdgdhg�ZXidi�dj6dk�dl6dm�dn6ZYieZdo6eZdp6eZdq6eZdr6dsdt6e du6dvdw6e dx6dydz6d{d|6ed}6dsd~6Z[d�Z\d��Z]d��Z^ie\d�6e]d�6e^d�6Z_d��Z`d�efd���YZad
eae:fd���YZbdeae=fd���YZcd�efd���YZdd�efd���YZeee�Zfd��Zgd�ehfd���YZieid�e �Zje e eCeCd��Zkd��Zld��Zmd�efd���YZneek�eefjo�fZpeefjojq�fZreCasd��ZteCd�d��Zude=fd���YZvdS(�tMockt	MagicMocktpatchtsentineltDEFAULTtANYtcalltcreate_autospect
FILTER_DIRtNonCallableMocktNonCallableMagicMockt	mock_opentPropertyMocks1.0i����N(t
ModuleType(twrapstpartialcCs%h|]}|jd�s|�qS(t_(t
startswith(t.0tname((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pys	<setcomp>$s	tjavacCstt|�t�S(N(t
issubclassttypeR	(tobj((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_is_instance_mock3scCs+t|t�p*t|t�o*t|t�S(N(t
isinstancetBaseExceptionsRR(R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt
_is_exception9st_slottedcBseZdgZRS(ta(t__name__t
__module__t	__slots__(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR@scCs�t|t�rA|rAy
|j}Wntk
r7dSXt}n4t|t�suy
|j}Wqutk
rqdSXn|r�t|d�}n|}y|t	j
|�fSWntk
r�dSXdS(s�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    N(RRt__init__tAttributeErrortNonetTruet
FunctionTypest__call__Rtinspectt	signaturet
ValueError(tfunctas_instanceteat_selftsig_func((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_get_signature_objectJs$

	


cs]t|||���dkr"dS�\}��fd�}t||�|t|�_dS(Ncs�j||�dS(N(tbind(t
_mock_selftargstkwargs(tsig(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pytchecksigos(R.R#t_copy_func_detailsRt_mock_check_sig(R*tmockt	skipfirsttinstanceR4((R3s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_check_signaturejs
cCs�|j|_|j|_y|j|_Wntk
r;nXy|j|_Wntk
r_nXy|j|_Wntk
r�nXy|j|_Wntk
r�nXdS(N(Rt__doc__t__text_signature__R"Rt__defaults__t__kwdefaults__(R*tfuncopy((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR5us$



cCs3t|t�rtSt|dd�dk	r/tStS(NR&(RRR$tgetattrR#tFalse(R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt	_callable�s
cCst|�ttfkS(N(Rtlistttuple(R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_is_list�scCs`t|t�s%t|dd�dk	Sx4|f|jD]"}|jjd�dk	r6tSq6WtS(stGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.R&N(	RRR@R#t__mro__t__dict__tgetR$RA(Rtbase((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_instance_callable�scs�e|�sdSe|e�}e|||�}|dkrAdS|\}��fd�}e||�|j}|j�s�d}ni|d6|d6}d|}	|	|U||}
e|
|�|
S(Ncs�j||�dS(N(R/(R1R2(R3(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR4�sR?t
_checksig_R7sYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs)(	RBRRR.R#R5Rtisidentifiert_setup_func(R7toriginalR9R8tresultR*R4RtcontexttsrcR?((R3s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_set_signature�s$
		


cs��_t��sdS�fd�}�fd�}�fd�}�fd�}��fd�}t�_d�_d�_t��_t��_	t��_
�j�_�j�_�j
�_
|�_|�_|�_|�_|�_��_dS(Ncs�j||�S(N(tassert_called_with(R1R2(R7(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRS�scs�j||�S(N(tassert_called_once_with(R1R2(R7(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRT�scs�j||�S(N(tassert_has_calls(R1R2(R7(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRU�scs�j||�S(N(tassert_any_call(R1R2(R7(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRV�scsTt��_t��_�j��j}t|�rP|�k	rP|j�ndS(N(t	_CallListtmethod_callst
mock_callst
reset_mocktreturn_valueR(tret(R?R7(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRZ�s
	i(R7RRAtcalledt
call_countR#t	call_argsRWtcall_args_listRXRYR[tside_effectt_mock_childrenRSRTRURVRZt_mock_delegate(R?R7RSRTRURVRZ((R?R7s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRM�s.									cCsd|dd!|kS(Ns__%s__ii����((R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt	_is_magic�st_SentinelObjectcBs eZdZd�Zd�ZRS(s!A unique, named, sentinel object.cCs
||_dS(N(R(tselfR((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!�scCsd|jS(Nssentinel.%s(R(Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt__repr__�s(RRR;R!Rg(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRe�s	t	_SentinelcBs eZdZd�Zd�ZRS(sAAccess attributes to return a named object, usable as a sentinel.cCs
i|_dS(N(t
_sentinels(Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!scCs.|dkrt�n|jj|t|��S(Nt	__bases__(R"Rit
setdefaultRe(RfR((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt__getattr__s	(RRR;R!Rl(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRh�s	cCs2t|�ttttfkr.t|�|�S|S(N(RtdictRCRDtset(tvalue((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_copysR[t_mock_return_valueRat_mock_side_effectt_mock_parentt_mock_new_parentt
_mock_namet_mock_new_namecCsBtj|�d|}||d�}||d�}t||�S(Nt_mock_cSs/|j}|dkr"t||�St||�S(N(RcR#R@(RfRt	_the_nameR3((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_get#s	
cSs9|j}|dkr%||j|<nt|||�dS(N(RcR#RGtsetattr(RfRoRRxR3((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_set(s	(t_allowed_namestaddtproperty(RRxRyR{((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_delegating_property s


RWcBseZd�Zd�ZRS(cCs�t|t�stj||�St|�}t|�}||krGtSx@td||d�D]'}||||!}||kr_tSq_WtS(Nii(RRCt__contains__tlenRAtrangeR$(RfRot	len_valuetlen_selftitsub_list((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�5scCstjt|��S(N(tpprinttpformatRC(Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRgCs(RRR�Rg(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRW3s	cCs�t|�stS|js@|js@|jdk	s@|jdk	rDtS|}x)|dk	ru||kritS|j}qMW|r�||_||_n|r�||_||_ntS(N(RRARuRvRsR#RtR$(tparentRoRtnew_namet_parent((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_check_and_set_parentGs$
		t	_MockItercBs#eZd�Zd�Zd�ZRS(cCst|�|_dS(N(titerR(RfR((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!ascCs|S(N((Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt__iter__cscCs
t|j�S(N(tnextR(Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt__next__es(RRR!R�R�(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�`s		tBasecBseZeZdZd�ZRS(cOsdS(N((RfR1R2((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!ksN(RRRRqR#RrR!(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�hscBs�eZdZd�Zd"d"d"d"d"d"dd"ed"ed�Zd�Zed�Zeed�Z	d�Z
d�Zd	Ze
e
ee�Ze
d
��Zed�Zed�Zed
�Zed�Zed�Zd�Zd�Ze
ee�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%ed�Z&d �Z'd!�Z(RS(#s A non-callable version of `Mock`cOs5t|j|fi|jd6�}tj|�}|S(NR;(RRR;tobjectt__new__(tclsR1tkwtnewR9((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�ss"tcKs>|dkr|}n|j}
||
d<||
d<||
d<||
d<|dk	ra|}t}n|
dkr||dk	}
n|j|||	|
�i|
d<||
d<d|
d<t|
d<d|
d	<d
|
d<t�|
d<t�|
d
<t�|
d<||
d<|r|j|�ntt|�j	||||||�dS(NRsRuRvRtRbt_mock_wrapsRct_mock_calledt_mock_call_argsit_mock_call_countt_mock_call_args_listt_mock_mock_callsRXt_mock_unsafe(
R#RGR$t_mock_add_specRARWtconfigure_mockt_safe_superR	R!(RftspecRRtspec_setR�t_spec_statet	_new_namet_new_parentt_spec_as_instancet	_eat_selftunsafeR2RG((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!|s8		



	









cCs8d|_d|_d|_d|_t|||�dS(s�
        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.R�N(R#RsRtRuRvRz(RfR7t	attribute((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pytattach_mock�s
				cCs|j||�dS(s�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�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt
mock_add_spec�sc	Cs�d}d}|dk	rzt|�rzt|t�r=|}nt|�}t|||�}|oh|d}t|�}n|j}||d<||d<||d<||d<dS(Nit_spec_classt	_spec_sett_spec_signaturet
_mock_methods(R#RERRt
_get_classR.tdirRG(	RfR�R�R�R�R�R�tresRG((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��s		


cCs[|j}|jdk	r'|jj}n|tkrW|jd|dd�}||_n|S(NR�R�s()(RqRcR#R[Rt_get_child_mock(RfR\((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt__get_return_value�s		cCs>|jdk	r||j_n||_t||dd�dS(Ns()(RcR#R[RqR�(RfRo((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt__set_return_value�s	s1The value to be returned when the mock is called.cCs |jdkrt|�S|jS(N(R�R#R(Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt	__class__�s
R]R^R_R`RYcCsj|j}|dkr|jS|j}|dk	rft|�rft|t�rft|�}||_n|S(N(RcR#RrRatcallableRR�(Rft	delegatedtsf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt__get_side_effect�s		)cCs:t|�}|j}|dkr-||_n	||_dS(N(t	_try_iterRcR#RrRa(RfRoR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt__set_side_effects
	cCs�t|_d|_d|_t�|_t�|_t�|_x6|j	j
�D]%}t|t�rjqOn|j
�qOW|j}t|�r�||k	r�|j
�ndS(s-Restore the mock object to its initial state.iN(RAR]R#R_R^RWRYR`RXRbtvaluesRt
_SpecStateRZRqR(RftchildR\((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRZs				cKs�xzt|j�dd��D]]\}}|jd�}|j�}|}x|D]}t||�}qPWt|||�qWdS(sZSet 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)tkeycSs|djd�S(Nit.(tcount(tentry((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt<lambda>0R�R�N(tsortedtitemstsplittpopR@Rz(RfR2targtvalR1tfinalRR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�#s	
cCs�|ddhkr!t|��n[|jdk	ra||jksK|tkr|td|��q|nt|�r|t|��n|js�|jd�r�t|��q�n|jj|�}|t	kr�t|��n�|dkrCd}|j
dk	r	t|j
|�}n|jd|d|d|d	|d
|�}||j|<nFt
|t�r�t|j|j|j|j|j�}||j|<n|S(NR�R�sMock object has no attribute %rtasserttassretR�RRR�R�(R�R�(R"R�R#t_all_magicsRdR�RRbRHt_deletedR�R@R�RR�RR�R�R9R�R(RfRROR((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRl9s6			c
Cs�|jg}|j}|}d}|dgkr9d}nt�}xz|dk	r�|}|j|j|�d}|jdkr�d}n|j}t|�|kr�Pn|jt|��qEWtt|��}|j	p�d}t
|�dkr|dd
kr|d7}qn||d<dj|�}d}|dkrJd	|}nd}	|jdk	r�d
}	|j
rwd}	n|	|jj}	ndt|�j||	t|�fS(NR�s()R�R7is().ismock.s name=%rs spec=%rs spec_set=%rs<%s%s%s id='%s'>(s()s().(R7smock.(RvRtRnR#tappendtidR}RCtreversedRuR�tjoinR�R�RR(
Rft
_name_listR�tlasttdottseent_firstRtname_stringtspec_string((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRg_sL					

		cCs�tstj|�S|jpg}tt|��}t|j�}g|D]}|jd�sJ|^qJ}g|D](}|jd�s�t	|�rr|^qr}t
t|||t|j���S(s8Filter the output of `dir(mock)` to only useful members.R(
RR�t__dir__R�R�RRCRGRRdR�RnRb(Rftextrast	from_typet	from_dictte((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��s
(cs�|tkrtj�||�S�jrh�jdk	rh|�jkrh|�jkrhtd|��n|tkr�d|}t|��n�|t	krI�jdk	r�|�jkr�td|��nt
|�stt��|t
||��|���fd�}q�t�|d|�tt��||�|�j|<n>|dkrb|�_dSt�|||�r�|�j|<ntj�||�S(Ns!Mock object has no attribute '%s's.Attempting to set unsupported magic method %r.cs��||�S(N((R1R�(RNRf(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��R�R�(R|R�t__setattr__R�R�R#RGR"t_unsupported_magicsR�RRzRt_get_methodR�RbR�(RfRRotmsg((RNRfs:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��s2
	cCs�|tkrJ|t|�jkrJtt|�|�||jkrJdSn||jkrltj||�n|jj|t�}|t	kr�t
|��n|tk	r�|j|=nt	|j|<dS(N(R�RRGtdelattrR�t__delattr__RbRHt_missingR�R"(RfRR((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��s!
cCs|jpd}t|||�S(NR7(Rut_format_call_signature(RfR1R2R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_format_mock_call_signature�scCs]d}|j||�}|j}t|�dkr@|d}n|j|�}|||fS(Ns!Expected call: %s
Actual call: %sii(R�R_R�(RfR1R2tmessagetexpected_stringR_t
actual_string((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_format_mock_failure_message�s	
cCs�|j}|dk	r�t|�dkr<d}|\}}n|\}}}y||j||�fSWq�tk
r�}|jd�SXn|SdS(s
        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.
        iR�N(R�R#R�R/t	TypeErrortwith_traceback(Rft_callR3RR1R2R�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt
_call_matcher�s	cCsD|}|jdkr@d|jp$d|jf}t|��ndS(s/assert that the mock was never called.
        is7Expected '%s' to not have been called. Called %s times.R7N(R^RutAssertionError(R0RfR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pytassert_not_called�s
cs�|��jdkr=�j���}td|f��n���fd�}�j��f�}�j�j�}||kr�t|���ndS(s�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.sExpected call: %s
Not calledcs�j���}|S(N(R�(R�(R1R2Rf(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_error_message
sN(R_R#R�R�R�(R0R1R2texpectedR�tactual((R1R2Rfs:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRSscOsP|}|jdks@d|jp$d|jf}t|��n|j||�S(sVassert that the mock was called exactly once and with the specified
        arguments.is1Expected '%s' to be called once. Called %s times.R7(R^RuR�RS(R0R1R2RfR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRTscs�g|D]}�j|�^q}t�fd��jD��}|ss||krotd|�jf��ndSt|�}g}x@|D]8}y|j|�Wq�tk
r�|j|�q�Xq�W|r�tdt|�f��ndS(s�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`.c3s|]}�j|�VqdS(N(R�(Rtc(Rf(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pys	<genexpr>,ss(Calls not found.
Expected: %r
Actual: %rNs%r not all found in call list(	R�RWRYR�RCtremoveR)R�RD(Rftcallst	any_orderR�R�t	all_callst	not_foundtkall((Rfs:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRU!s$
"

cOso|j||f�}g|jD]}|j|�^q}||krk|j||�}td|��ndS(s�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.s%s call not foundN(R�R`R�R�(RfR1R2R�R�R�R�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRVCs%cKset|�}t|t�sNt|t�r3t}q[t|t�r[t}q[n
|jd}||�S(sPCreate 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).i(RRt
CallableMixinR
RR	RRF(RfR�t_typetklass((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�Rs	
N()RRR;R�R#RAR!R�R�R�t"_NonCallableMock__get_return_valuet"_NonCallableMock__set_return_valuet"_NonCallableMock__return_value_docR~R[R�RR]R^R_R`RYt!_NonCallableMock__get_side_effectt!_NonCallableMock__set_side_effectRaRZR�RlRgR�R�R�R�R�R�R�RSRTRURVR�(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR	psN	
)	
		
				
				&	2		"			
					"	cCsW|dkr|St|�r |St|�r0|Syt|�SWntk
rR|SXdS(N(R#RRBR�R�(R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�fs
R�cBsJeZddedddddddd�
Zd�Zd�Zd�ZRS(R�c
KsH||jd<tt|�j|||||||	|
|�||_dS(NRq(RGR�R�R!Ra(RfR�RaR[RRR�R�R�R�R�R2((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!xs

cOsdS(N((RfR1R2((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR6�scOs |j||�|j||�S(N(R6t
_mock_call(R0R1R2((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR&�scOs�|}t|_|jd7_|j}|j}t||fdt�}||_|jj|�|j	jtd||f��t
�}|dk}|jdk	}	|j
}
x#|dk	r�t|||f�}|jr!d}|r�d}nt}|jdkr
t}n|j||}n|	r�||
kr<|}
nt|
||f�}
|jj|
�|jdk	}	|	r�|j
d|
}
q�n|j	j|�|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(NittwoR�s()R�(R$R]R^RvRtt_CallR_R`R�RYRnRsR#RuRARXR�R}RRaRRBR�R[R�Rq(R0R1R2RfR�R�R�R�t
skip_next_dottdo_method_callsRtthis_mock_callR�tthis_method_callt_new_parent_idtret_valteffectRO((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�sp														N(RRR#RR!R6R&R(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�vs			cBseZdZRS(s�	
    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.
    (RRR;(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�s1cCs=yt||�SWn%tk
r8t|�t||�SXdS(N(R@R"t
__import__(tthingtcomptimport_path((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_dot_lookups


cCs_|jd�}|jd�}t|�}x.|D]&}|d|7}t|||�}q1W|S(NR�is.%s(R�R�RR(ttargett
componentsRRR((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt	_importers
cCs
t|d�S(Ntis_local(thasattr(tpatcher((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_is_started#st_patchcBsneZd
ZgZd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�ZRS(c

Cs�|dk	rE|tk	r'td��n|dk	rEtd��qEn||_||_||_||_||_||_t	|_
||_||_|	|_
g|_dS(Ns,Cannot use 'new' and 'new_callable' togethers1Cannot use 'autospec' and 'new_callable' together(R#RR)tgetterR�R�tnew_callableR�tcreateRAt	has_localR�tautospecR2tadditional_patchers(
RfRR�R�R�R R�R"RR2((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!-s$										c
Cstt|j|j|j|j|j|j|j|j|j	�	}|j
|_
g|jD]}|j�^qU|_|S(N(
RRR�R�R�R R�R"RR2tattribute_nameR#tcopy(RfRtp((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR%Hs%cCs)t|t�r|j|�S|j|�S(N(RRtdecorate_classtdecorate_callable(RfR*((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR&Us
cCsyxrt|�D]d}|jtj�s+q
nt||�}t|d�sOq
n|j�}t||||��q
W|S(NR&(R�RRtTEST_PREFIXR@RR%Rz(RfRtattrt
attr_valueR((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR'[scsQt�d�r#�jj|��St����fd���|g�_�S(Nt	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�}�nXWdx!t|�D]}|j
|�q�WXdS(N(RDR,t	__enter__R�R$R#tupdateR�RRtsystexc_infoR�t__exit__(R1tkeywargst
extra_argstentered_patchersR0tpatchingR�(R*tpatched(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR6ns,	
(RR,R�R(RfR*((R*R6s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR(iscCs�|j�}|j}t}t}y|j|}Wn)ttfk
r]t||t�}nXt}|t	kr�t
|t�r�t|_n|jr�|tkr�td||f��n||fS(Ns!%s does not have the attribute %r(
RR�RRARGR"tKeyErrorR@R$t	_builtinsRR
R (RfRRRNtlocal((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pytget_original�s	cCs�|j|j|j}}}|j|j}}|j}|j�|_|tkr]d}n|tkrrd}n|tkr�d}n|dk	r�|dk	r�t
d��n|dk	s�|dk	r�|tdfkr�t
d��n|j�\}}|t
krb|dkrbt}	|tkrG|}|tkr�|}d}q�n?|dk	rq|tkr�|}d}q�n|tkr�|}n|dk	s�|dk	r�|t
kr�t
d��nt|t�r�t}	q�nt}
i}|dk	r�|}
nm|dk	s
|dk	rb|}|dk	r(|}nt|�rCd|k}
n
t|�}
|
rbt}
qbn|dk	r{||d<n|dk	r�||d<nt|
t�r�t|
t�r�|jr�|j|d<n|j|�|
|�}|	r�t|�r�|}|dk	r|}nt|�r4t|�r4t}
n|jd�|
d|d	d
|�|_q�n�|dk	r�|t
k	r�t
d��n|t
kr�t
d��nt|�}|tkr�|}nt|d|d
|j|�}n|r�t
d��n|}||_||_t |j|j|�|j!dk	r�i}|jt
kr]|||j!<nx<|j"D]1}|j#�}|jt
krg|j|�qgqgW|S|S(sPerform the patch.sCan't specify spec and autospecs6Can't provide explicit spec_set *and* spec or autospecs!Can't use 'spec' with create=TrueR&R�R�RR�R�s()sBautospec creates the mock for you. Can't specify autospec and new.s%Can't use 'autospec' with create=Truet_names.Can't pass kwargs to a mock we aren't creatingN($R�R�R�R"R2RRRRAR#R�R$R:RRRRRER�R
RR	R�R.RRJR�R[tboolRt
temp_originalRRzR$R#R-(RfR�R�R�R"R2RRNR9tinherittKlasst_kwargst	this_spectnot_callabletnew_attrR3R5R�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR-�s�							



	

	
			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(sUndo the patch.s stop called on unstarted patcherN(RtRuntimeErrorRR=RRzRR�R�R RR�R#R1(RfR0R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR1's cCs |j�}|jj|�|S(s-Activate a patch, returning any created mock.(R-t_active_patchesR�(RfRO((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pytstart<scCs2y|jj|�Wntk
r'nX|j�S(sStop an active patch.(RER�R)R1(Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pytstopCs

N(RRR#R$RER!R%R&R'R(R:R-R1RFRG(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR(s		
			(		~		csby�jdd�\�}Wn*ttfk
rHtd�f��nX�fd�}||fS(NR�is.Need a valid target to patch. You supplied: %rcs
t��S(N(R((R(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�UR�(trsplitR�R)(RR�R((Rs:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_get_targetOsc

s1�fd�}	t|	||||||||�	S(s
    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(N(((R(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�kR�(R(
RR�R�R�R R�R"RR2R((Rs:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt
_patch_objectYsc
s�t��tkr$�fd�}n�fd�}|sHtd��nt|j��}|d\}	}
t||	|
|||||i�	}|	|_xU|dD]I\}	}
t||	|
|||||i�	}|	|_|jj|�q�W|S(s�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(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��R�cs�S(N(((R(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��R�s=Must supply at least one keyword argument with patch.multipleii(	RtstrR)RCR�RR$R#R�(
RR�R R�R"RR2RR�R�R�Rtthis_patcher((Rs:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_patch_multiplers&		c

Ks4t|�\}}	t||	|||||||�	S(s�

    `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 with 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.
    (RIR(
RR�R�R R�R"RR2RR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�sEt_patch_dictcBs_eZdZded�Zd�Zd�Zd�Zd�Zd�Z	d�Z
eZe
ZRS(	s#
    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.
    cKs\t|t�rt|�}n||_t|�|_|jj|�||_d|_	dS(N(
RRKRtin_dictRmR�R.tclearR#t	_original(RfROR�RPR2((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!s		cs>t�t�r�j��St����fd��}|S(Ncs-�j�z�||�SWd�j�XdS(N(RNt
_unpatch_dict(R1R�(tfRf(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_inners
(RRR'R(RfRSRT((RSRfs:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR&s
cCs�x~t|�D]p}t||�}|jtj�r
t|d�r
t|j|j|j	�}||�}t
|||�q
q
W|S(NR&(R�R@RRR)RRNROR�RPRz(RfRR*R+t	decoratort	decorated((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR'%scCs|j�dS(sPatch the dict.N(RN(Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR-0scCs�|j}|j}|j}y|j�}Wn6tk
rci}x |D]}||||<qHWnX||_|r�t|�ny|j|�Wn0tk
r�x |D]}||||<q�WnXdS(N(R�RORPR%R"RQt_clear_dictR.(RfR�RORPRNR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRN5s"			

	


cCsd|j}|j}t|�y|j|�Wn0tk
r_x |D]}||||<qDWnXdS(N(RORQRWR.R"(RfRORNR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRROs		


cGs|j�tS(sUnpatch the dict.(RRRA(RfR1((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR1\s
((
RRR;RAR!R&R'R-RNRRR1RFRG(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRN�s					
	cCsJy|j�Wn5tk
rEt|�}x|D]
}||=q1WnXdS(N(RPR"RC(ROtkeysR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRWes

cCs(x!ttj�D]}|j�qWdS(s7Stop all active patches. LIFO to unroll nested patches.N(R�RRERG(R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_patch_stopallnsttests�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod neg pos abs invert complex int float index trunc floor ceil bool next sAadd sub mul div floordiv mod lshift rshift and xor or pow truedivt ccs|]}d|VqdS(si%sN((Rtn((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pys	<genexpr>�sccs|]}d|VqdS(sr%sN((RR\((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pys	<genexpr>�sccs|]}d|VqdS(s__%s__N((Rtmethod((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pys	<genexpr>�sRHRntdeleteR�tmissingtreducet	reduce_extgetinitargst
getnewargstgetstatetsetstatet	getformatt	setformattreprR�t
subclassestformatcs�fd�}||_|S(s:Turns a callable object (like a mock) into a real functioncs�|||�S(N((RfR1R�(R*(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR]�s(R(RR*R]((R*s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��s	ccs|]}d|VqdS(s__%s__N((RR]((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pys	<genexpr>�sRlR�R!R�t__prepare____instancecheck__t__subclasscheck__t__del__cCs
tj|�S(N(R�t__hash__(Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��R�RncCs
tj|�S(N(R�t__str__(Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��R�RocCs
tj|�S(N(R�t
__sizeof__(Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��R�Rpt__lt__t__gt__t__le__t__ge__it__int__R�it__len__R1y�?t__complex__g�?t	__float__t__bool__t	__index__cs�fd�}|S(Ncs&�jj}|tk	r|S�|kS(N(t__eq__RqR(totherR(Rf(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR{�s((RfR{((Rfs:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_get_eq�scs�fd�}|S(Ncs �jjtk	rtS�|k	S(N(t__ne__RqR(R|(Rf(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR~�s((RfR~((Rfs:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_get_ne�scs�fd�}|S(Ncs,�jj}|tkr"tg�St|�S(N(R�RqRR�(R(Rf(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��s
((RfR�((Rfs:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt	_get_iter�sR{R~R�cCs�tj|t�}|tk	r+||_dStj|�}|dk	r�y||�}Wntk
rut|�}nX||_dStj|�}|dk	r�||�|_ndS(N(	t_return_valuesRHRR[t_calculate_return_valueR#R"t_side_effect_methodsRa(R7R]Rtfixedtreturn_calulatorR[t
side_effector((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_set_return_value�s	
	t
MagicMixincBseZd�Zd�ZRS(cOs'tt|�j||�|j�dS(N(R�R�R!t_mock_set_magics(RfR1R�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!�scCs�t}|jdk	rstj|j�}t�}t|}x6|D]+}|t|�jkrAt||�qAqAWn|tt|�j�}t|�}x'|D]}t||t	||��q�WdS(N(
t_magicsR�R#tintersectionRnRRGR�Rzt
MagicProxy(Rftthese_magicst
remove_magicsR�R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�s	


(RRR!R�(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��s	cBseZdZed�ZRS(s-A version of `MagicMock` that isn't callable.cCs|j||�|j�dS(s�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�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�s(RRR;RAR�(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR
scBseZdZed�ZRS(s�
    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`.
    cCs|j||�|j�dS(s�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�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�0s(RRR;RAR�(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR%s
R�cBs/eZd�Zd�Zd�Zdd�ZRS(cCs||_||_dS(N(RR�(RfRR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!<s	cOs|j�}|||�S(N(tcreate_mock(RfR1R2tm((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR&@scCsT|j}|j}|jd|d|d|�}t|||�t|||�|S(NRR�R�(RR�R�RzR�(RfR�R�R�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�Ds			cCs
|j�S(N(R�(RfRR((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt__get__MsN(RRR!R&R�R#R�(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�;s				t_ANYcBs2eZdZejZd�Zd�Zd�ZRS(s2A helper object that compares equal to everything.cCstS(N(R$(RfR|((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR{WscCstS(N(RA(RfR|((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR~ZscCsdS(Ns<ANY>((Rf((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRg]s(RRR;R�RnR{R~Rg(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�Rs
			c
Cs�d|}d}djg|D]}t|�^q�}djgt|j��D]\}}d||f^qQ�}	|r�|}n|	r�|r�|d7}n||	7}n||S(Ns%s(%%s)R�s, s%s=%r(R�RhR�R�(
RR1R2R�tformatted_argsR�targs_stringR�Rot
kwargs_string((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�ds
(8	

R	cBs�eZdZejZdddeed�Zd
ddeed�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zd	�Zd
�ZRS(s�
    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.
    cCsd}d}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�iii((R�RRKRDR�(R�RoRR�Rt	from_kallR1R2t_lentfirsttsecond((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��s0						cCs||_||_||_dS(N(RR�R�(RfRoRR�RR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!�s		cCs�|tkrtSyt|�}Wntk
r4tSXd}t|�dkr\|\}}n|\}}}d}|dkr�di}}n�|dkr�|\}}}n�|dkr|\}	t|	t�r�|	}i}qot|	t�r|	}di}}qod}|	}n]|\}
}t|
t�rb|
}t|t�rR|i}}qod	|}}n
|
|}}|r�||kr�tS||f||fkS(
NR�iiii(((((RR$R�R�RARRDRK(RfR|t	len_othert	self_namet	self_argstself_kwargst
other_namet
other_argstother_kwargsRoR�R�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR{�sF
			
cCs|j|�S(N(R{(RfR|((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR~�scOsW|jdkr(td||fdd�S|jd}t|j||fd|d|�S(NR�Rs()R�(RR#R	(RfR1R2R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR&�s
cCsN|jdkr"td|dt�Sd|j|f}td|d|dt�S(NRR�s%s.%sR�(RR#R	RA(RfR*R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRl�scOs|jd�||�S(NR�(Rl(RfR1R2((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��scOs|jd�||�S(Ntindex(Rl(RfR1R2((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��scCs�|js8|jpd}|jd�r4d|}n|St|�dkr_d}|\}}nD|\}}}|s}d}n&|jd�s�d|}n
d|}t|||�S(NRs()scall%siscall.%s(R�RRR�R�(RfRR1R2((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyRg�s	
	

cCsQg}|}x2|dk	r@|jr4|j|�n|j}qWtt|��S(s�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�R�RWR�(RftvalsR((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt	call_lists	
(N((RRR;R�RnR#RAR$R�R!R{R~R&RlR�R�RgR�(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR	vs	 	2						R�cKst|�rt|�}nt|t�}i|d6}|rMi|d6}n|dkrbi}n|r{|r{t|d<n|j|�t}t|�tkr�i}n7t|�s�t	}n"|r�|r�t
|�r�t	}n|jd|�}|}	|dkr
d}	n|d|d|d|	d||�}
t|t�rRt
|
|�}
nt||
||�|dk	r�|r�|
|j|<n|r�|r�d	|kr�t||d
tddd
|
�|
_nxMt|�D]?}t|�r�q�nyt||�}Wntk
rq�nXi|d6}|r:i|d6}nt|t�sqt|||
||�}
|
|
j|<n�|
}t|t�r�|
j}nt|||�}||d<td|d|d|d||�}
|
|
j|<t||
d|�t|
t�r�t|
||
�q�q�W|
S(sICreate 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�R�RR�R�R�R�R[R9R;s()R�R�R8N(RERRR#R$R.RtDescriptorTypesRBR
RJR�R%RRR:RbRR[R�RdR@R"R�R7t
_must_skipRz(R�R�R9R�R;R2tis_typeR@R?R�R7R�RNR�R�R8((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR%st
	

				


	
cCs�t|t�s7|t|di�kr+tS|j}nxt|jD]i}|jj|t�}|tkrnqAnt|t	t
f�r�tStt|dd�t�r�|StSqAW|S(s[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    RGR�N(
RRR@RAR�RFRGRHRtstaticmethodtclassmethodR#tMethodWrapperTypes(R�R�R�RRO((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��scCs*y|jSWntk
r%t|�SXdS(N(R�R"R(R((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��s
R�cBs eZeddded�ZRS(cCs:||_||_||_||_||_||_dS(N(R�tidsR�R�R9R(RfR�R�R�RR�R9((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR!�s					N(RRRAR#R!(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR��sccstg|jd�D]}dj|�^q}|ddkrH|d }n|dd |d<x|D]}|VqaWdS(Ns
s{}
i����(R�Rj(t	read_datatltdata_as_listtline((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_iterate_read_data�s+

R�cs3��fd�}��fd�}��fd�}tdkr�ddl}ttt|j��jtt|j����an|dkr�t	dddt
�}nt	dt����j_t
|��d�j_d�j_d�j_d�j_|�j_|��j_|�j_�|_|S(	s�
    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��S(N(t	readlinesR[R#RC(R1R2(t_datathandle(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_readlines_side_effect�s
cs)�jjdk	r�jjSdj��S(NR�(treadR[R#R�(R1R2(R�R�(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_read_side_effect	s
c3sG�jjdk	r-xtr)�jjVqWnx�D]}|Vq4WdS(N(treadlineR[R#R$(R�(R�R�(s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt_readline_side_effect	s
	
i����NRtopenR�(t	file_specR#t_ioRCRnR�t
TextIOWrappertuniontBytesIORR�R-R[R�twriteR�R�R�Ra(R7R�R�R�R�R�((R�R�s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�s(	6	cBs)eZdZd�Zd�Zd�ZRS(sW
    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(RfR2((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�0	scCs|�S(N((RfRtobj_type((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR�3	scCs||�dS(N((RfRR�((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt__set__5	s(RRR;R�R�R�(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyR'	s		(wt__all__t__version__t__builtin__R'R�R/ttypesR
t	functoolsRRR�R8t
BaseExceptionRtplatformRtlangt	ThrowableR$RtsuperR�RRR�RRRR~R�R.RAR:R5RBRERJRRRMRdReRhRRtMISSINGR�tDELETEDR�RpRnR|RRCRWR�R�R�R	R�R�RRRRRRIR#RJRMRRNRWRYRmtmultipletstopallR)t
magic_methodstnumericsR�R�tinplacetrightt
_non_defaultsR�R�R�R�R�tNotImplementedR�R}RR�R�R�R�R
RR�R�RR�RDR	RRR�R�R�R{R%R�R�R�R�RR(((s:/usr/local/python-2.7/lib/python2.7/test/_mock_backport.pyt<module>s$						 					+											��	e5			�(			1	Jv										(
	



			

	
		�	w				8
© 2025 GrazzMean