Spade
Mini Shell
| Directory:~$ /proc/self/root/lib/python2.7/site-packages/ |
| [Home] [System Details] [Kill Me] |
�
{-�Pc@sUdddddddddd d
ddf
Zd
ZddlZddlZyddlZWnek
rteZnXyddlmZ Wnek
r�d�Zn,Xej
d ddfkr�e Zn d�ZyeWnek
r�e
ZZnXyeWnek
reZnXyeWnek
r:eZnXyeWnek
r_d�ZnXefZdejkr�ddlZeejjfZny
e
jZWnGek
r�ddlZddlZejdej�Z d�ZnXej
ddkZ!e"Z#dZ$dZ%e!r*dZ$dZ%ne&Z'd�Z(d�Z)d
e*fd!��YZ+e,e+j-�e.fZ/e0d"�Z1e0d#�Z2d$�Z3d%�Z4d&�Z5d'�Z6e0d(�Z7d)�Z8d*�Z9d+e*fd,��YZ:d-e*fd.��YZ;e;�Z<e<j=Z=e<j>Z?e<j@ZAd/fd0��YZBe,eB�ZCd1�ZDe,fZEe!r^e,eCfZEneFd2d3d4d5d6d7d8d9g�ZGd:�ZHd;eIfd<��YZJd=�ZKd>e*fd?��YZLd eLfd@��YZMdA�ZNdBeLfdC��YZOdeOeMfdD��YZPdE�ZQdF�ZRdG�ZSdHe*fdI��YZTdJ�ZUe=ee0eeedK�ZVee0eeedL�ZWe=ee0eeedM�ZXdNe*fdO��YZYdP�ZZdQ�Z[eVeX_*eYeX_\eWeX_]e[eX_^dReX__dSZ`dTZadUjbdV�eajc�D��ZddUjbdW�eajc�D��ZedXZfe!rJdYZfndZZfeFd[�d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpgD��Zgdq�ZheFdr�dUjbe`eaedeeefg�jc�D��ZieiegBZjeFdsdtdudvdwdxdyg�Zkidz�d{6d|�d}6d~�d6d��d�6Zliemd�6emd�6emd�6emd�6d�d�6e0d�6dd�6e0d�6d�d�6d�d�6e&d�6e&d�6d�d�6d�d�6ed��d�6d�d�6Znd��Zod��Zpd��Zqieod�6epd�6eqd�6Zrd��Zsd�e*fd���YZtd
eteMfd���YZudetePfd���YZvd�e*fd���YZwd�e*fd���YZxex�Zyd��Zzd�e{fd���YZ|e|d�e0�Z}e0e0eed��Z~d��Zd��Z�d�e*fd���YZ�e,e~�e,eyj��e,exj��fZ�eFd�d�d�d�d�d�d�g�Z�ea�edXd��Z�dePfd���YZ�dS(�tMockt MagicMocktpatchtsentineltDEFAULTtANYtcalltcreate_autospect
FILTER_DIRtNonCallableMocktNonCallableMagicMockt mock_opentPropertyMocks1.0.1i����N(twrapscs�fd�}|S(Ncs1�j|_�j|_�j|_�|_|S(N(t__name__t__doc__t
__module__t__wrapped__(tf(toriginal(s(/usr/lib/python2.7/site-packages/mock.pytinner3s
((RR((Rs(/usr/lib/python2.7/site-packages/mock.pyR
2siics�fd�}|S(Ncst��|�}�|_|S(N(toriginal_wrapsR(R(tfunc(s(/usr/lib/python2.7/site-packages/mock.pyR?s ((RR((Rs(/usr/lib/python2.7/site-packages/mock.pyR
>scCs
|j�S(N(tnext(tobj((s(/usr/lib/python2.7/site-packages/mock.pyRZstjavas^[a-z_][a-z0-9_]*$cCs
|tjkrtStj|�S(N(tkeywordtkwlisttFalsetregextmatch(tstring((s(/usr/lib/python2.7/site-packages/mock.pyt
_isidentifierksitim_selft__builtin__t__self__tbuiltinscCstt|�t�S(N(t
issubclassttypeR (R((s(/usr/lib/python2.7/site-packages/mock.pyt_is_instance_mock�scCs+t|t�p*t|t�o*t|t�S(N(t
isinstancetBaseExceptionst
ClassTypesR%(R((s(/usr/lib/python2.7/site-packages/mock.pyt
_is_exception�st_slottedcBseZdgZRS(ta(RRt __slots__(((s(/usr/lib/python2.7/site-packages/mock.pyR,�sc
Cs�tdkrtd��nt|t�r\|r\y
|j}Wntk
rRdSXt}n4t|t�s�y
|j }Wq�tk
r�dSXnt
r�ytj|�}Wntk
r�dSX|\}}}}}} }
n4ytj
|�\}}}}Wntk
rdSXt|td�dk r5|d}n|rH|d}nt
r{tj|||||| |
dd��}n!tj||||dd��}|dd!|fS(Nsinspect module not
availableitformatvaluecSsdS(Nt((tvalue((s(/usr/lib/python2.7/site-packages/mock.pyt<lambda>�scSsdS(NR0((R1((s(/usr/lib/python2.7/site-packages/mock.pyR2�si����(tinspecttNonetImportErrorR(R*t__init__tAttributeErrortTruet
FunctionTypest__call__tinPy3ktgetfullargspect TypeErrort
getargspectgetattrtselft
formatargspec(
Rt skipfirsttinstancetargspectregargstvarargstvarkwtdefaultstkwonlyt kwonlydeftannt varkwargst signature((s(/usr/lib/python2.7/site-packages/mock.pyt
_getsignature�sF
cCswt|�sdSt|||�}|dkr2dS|\}}d|}t|i�}t||�|t|�_dS(Nslambda
_mock_self, %s:
None(t _callableRNR4tevalt_copy_func_detailsR&t_mock_check_sig(RtmockRBRCtresultRMtsrctchecksig((s(/usr/lib/python2.7/site-packages/mock.pyt_check_signature�s
cCsV|j|_|j|_|j|_ts:|j|_dS|j|_|j|_dS(N(RRRR;t
func_defaultst__defaults__t__kwdefaults__(Rtfuncopy((s(/usr/lib/python2.7/site-packages/mock.pyRQ�scCs3t|t�rtSt|dd�dk r/tStS(NR:(R(R*R8R?R4R(R((s(/usr/lib/python2.7/site-packages/mock.pyRO�s
cCst|�ttfkS(N(R&tlistttuple(R((s(/usr/lib/python2.7/site-packages/mock.pyt_is_list�scCsot|t�s%t|dd�dk S|}|jjd�dk rGtSx!|jD]}t|�rQtSqQWt S(stGiven
an object, return True if the object is callable.
For classes, return True if instances would be callable.R:N(
R(R*R?R4t__dict__tgetR8t __bases__t_instance_callableR(Rtklasstbase((s(/usr/lib/python2.7/site-packages/mock.pyRb�scBs�e|�sdSe|e�}e|||�}|dkrAdS|\}}d|}e|i�}e||�|j} e| �s�d} ni|d6|d6}
d| }||
fdU|
| }e ||�|S(Nslambda %s: NoneR[t
_checksig_RSsYdef %s(*args, **kwargs):
_checksig_(*args, **kwargs)
return mock(*args, **kwargs)(
ROR(R*RNR4RPRQRR
t_setup_func(RSRRCRBRTRMRRURVtnametcontextR[((s(/usr/lib/python2.7/site-packages/mock.pyt_set_signatures&
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(targstkwargs(RS(s(/usr/lib/python2.7/site-packages/mock.pyRj,scs�j||�S(N(tassert_called_once_with(RkRl(RS(s(/usr/lib/python2.7/site-packages/mock.pyRm.scs�j||�S(N(tassert_has_calls(RkRl(RS(s(/usr/lib/python2.7/site-packages/mock.pyRn0scs�j||�S(N(tassert_any_call(RkRl(RS(s(/usr/lib/python2.7/site-packages/mock.pyRo2scsTt��_t��_�j��j}t|�rP|�k rP|j�ndS(N(t _CallListtmethod_callst
mock_callst
reset_mocktreturn_valueR'(tret(R[RS(s(/usr/lib/python2.7/site-packages/mock.pyRs4s
i(RSR'Rtcalledt
call_countR4t call_argsRptcall_args_listRqRrRttside_effectt_mock_childrenRjRmRnRoRst_mock_delegate(R[RSRjRmRnRoRs((R[RSs(/usr/lib/python2.7/site-packages/mock.pyRf%s. cCsd|dd!|kS(Ns__%s__ii����((Rg((s(/usr/lib/python2.7/site-packages/mock.pyt _is_magicPst_SentinelObjectcBs
eZdZd�Zd�ZRS(s!A unique, named, sentinel
object.cCs
||_dS(N(Rg(R@Rg((s(/usr/lib/python2.7/site-packages/mock.pyR6VscCsd|jS(Nssentinel.%s(Rg(R@((s(/usr/lib/python2.7/site-packages/mock.pyt__repr__Ys(RRRR6R(((s(/usr/lib/python2.7/site-packages/mock.pyR~Ts t _SentinelcBs
eZdZd�Zd�ZRS(sAAccess attributes to return a named object,
usable as a sentinel.cCs
i|_dS(N(t
_sentinels(R@((s(/usr/lib/python2.7/site-packages/mock.pyR6_scCs.|dkrt�n|jj|t|��S(NRa(R7R�t
setdefaultR~(R@Rg((s(/usr/lib/python2.7/site-packages/mock.pyt__getattr__bs (RRRR6R�(((s(/usr/lib/python2.7/site-packages/mock.pyR�]s t
OldStyleClasscBseZRS((RR(((s(/usr/lib/python2.7/site-packages/mock.pyR�pscCs2t|�ttttfkr.t|�|�S|S(N(R&tdictR\R]tset(R1((s(/usr/lib/python2.7/site-packages/mock.pyt_copyusRtt_mock_return_valueRzt_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(R|R4R?(R@Rgt _the_nametsig((s(/usr/lib/python2.7/site-packages/mock.pyt_get�s
cSs9|j}|dkr%||j|<nt|||�dS(N(R|R4R_tsetattr(R@R1RgR�R�((s(/usr/lib/python2.7/site-packages/mock.pyt_set�s (t_allowed_namestaddtproperty(RgR�R�R�((s(/usr/lib/python2.7/site-packages/mock.pyt_delegating_property�s
RpcBseZd�Zd�ZRS(cCs�t|t�stj||�St|�}t|�}||krGtSx@td||d�D]'}||||!}||kr_tSq_WtS(Nii(R(R\t__contains__tlenRtrangeR8(R@R1t len_valuetlen_selftitsub_list((s(/usr/lib/python2.7/site-packages/mock.pyR��scCstjt|��S(N(tpprinttpformatR\(R@((s(/usr/lib/python2.7/site-packages/mock.pyR�s(RRR�R(((s(/usr/lib/python2.7/site-packages/mock.pyRp�s cCs�t|�stS|js@|js@|jdk s@|jdk rDtS|}x)|dk ru||kritS|j}qMW|r�||_||_n|r�||_||_ntS(N(R'RR�R�R�R4R�R8(tparentR1Rgtnew_namet_parent((s(/usr/lib/python2.7/site-packages/mock.pyt_check_and_set_parent�s$
tBasecBseZeZdZd�ZRS(cOsdS(N((R@RkRl((s(/usr/lib/python2.7/site-packages/mock.pyR6�sN(RRRR�R4R�R6(((s(/usr/lib/python2.7/site-packages/mock.pyR��sc BsmeZdZd�Zd
d d d d d dd d�Zd�Zed�Zd�Z d�Z
d�Zd Ze
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#ed�Z$d�Z%d�Z&RS(!s A non-callable
version of
`Mock`cOs5t|j|fi|jd6�}tj|�}|S(NR(R&RRtobjectt__new__(tclsRktkwtnewRC((s(/usr/lib/python2.7/site-packages/mock.pyR��s"R0c Ks|dkr|}n|j}
||
d<||
d<||
d<||
d<|dk ra|}t}n|j||�i|
d<||
d<d|
d<t|
d<d|
d <d
|
d<t�|
d<t�|
d
<t�|
d<| r�|j| �ntt|�j ||||||�dS(NR�R�R�R�R{t_mock_wrapsR|t_mock_calledt_mock_call_argsit_mock_call_countt_mock_call_args_listt_mock_mock_callsRq(
R4R_R8t_mock_add_specRRptconfigure_mockt_superR R6(R@tspecR
Rgtspec_setR�t_spec_statet _new_namet_new_parentRlR_((s(/usr/lib/python2.7/site-packages/mock.pyR6�s2
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.R0N(R4R�R�R�R�R�(R@RSt attribute((s(/usr/lib/python2.7/site-packages/mock.pytattach_mocks
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�(R@R�R�((s(/usr/lib/python2.7/site-packages/mock.pyt
mock_add_specscCs}d}|dk rRt|�rRt|t�r7|}nt|�}t|�}n|j}||d<||d<||d<dS(Nt_spec_classt _spec_sett
_mock_methods(R4R^R(R*t
_get_classtdirR_(R@R�R�R�R_((s(/usr/lib/python2.7/site-packages/mock.pyR�s
cCs[|j}|jdk r'|jj}n|tkrW|jd|dd�}||_n|S(NR�R�s()(R�R|R4RtRt_get_child_mock(R@Ru((s(/usr/lib/python2.7/site-packages/mock.pyt__get_return_value-s cCs>|jdk r||j_n||_t||dd�dS(Ns()(R|R4RtR�R�(R@R1((s(/usr/lib/python2.7/site-packages/mock.pyt__set_return_value:s s1The
value to be returned when the mock is called.cCs
|jdkrt|�S|jS(N(R�R4R&(R@((s(/usr/lib/python2.7/site-packages/mock.pyt __class__Fs
RvRwRxRyRrcCs#|j}|dkr|jS|jS(N(R|R4R�Rz(R@R�((s(/usr/lib/python2.7/site-packages/mock.pyt__get_side_effectSs cCs:t|�}|j}|dkr-||_n ||_dS(N(t _try_iterR|R4R�Rz(R@R1R�((s(/usr/lib/python2.7/site-packages/mock.pyt__set_side_effectYs
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(RRvR4RxRwRpRrRyRqR{tvaluesR(t
_SpecStateRsR�R'(R@tchildRu((s(/usr/lib/python2.7/site-packages/mock.pyRsds 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/lib/python2.7/site-packages/mock.pyR2�sR�N(tsortedtitemstsplittpopR?R�(R@RltargtvalRktfinalRR�((s(/usr/lib/python2.7/site-packages/mock.pyR�ws
cCs]|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�sMock
object has no attribute
%rR�RgR
R�R�(R7R�R4t_all_magicsR}R{R`t_deletedR�R?R�R(R�RR�R�RCR�Rg(R@RgRTR
((s(/usr/lib/python2.7/site-packages/mock.pyR��s0 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} |jdk r�d
} |j
rwd} n| |jj} ndt|�j|| t|�fS(NR�s()R0RSis().ismock.s
name=%rs spec=%rs spec_set=%rs<%s%s%s
id='%s'>(s()s().(smocksmock.(R�R�R�R4tappendtidR�R\treversedR�R�tjoinR�R�RR&(
R@t
_name_listR�tlasttdottseent_firstRgtname_stringtspec_string((s(/usr/lib/python2.7/site-packages/mock.pyR�sL
cCs�|jpg}tt|��}t|j�}tr�g|D]}|jd�s=|^q=}g|D](}|jd�s�t|�re|^qe}ntt |||t|j
���S(sNFilter the output of `dir(mock)` to only useful members.
XXXX
t_(R�R�R&R\R_Rt
startswithR}R�R�R{(R@textrast from_typet from_dictte((s(/usr/lib/python2.7/site-packages/mock.pyt__dir__�s(c
s�|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((RkR�(RR@(s(/usr/lib/python2.7/site-packages/mock.pyR2sR�(R�R�t__setattr__R�R�R4R_R7t_unsupported_magicsR�R'R�R&t_get_methodR�R{R�(R@RgR1tmsg((RR@s(/usr/lib/python2.7/site-packages/mock.pyR��s2
cCs�|tkrJ|t|�jkrJtt|�|�||jkrJdSn||jkrltj||�n|jj|t�}|t kr�t
|��n|tk r�|j|=nt |j|<dS(N(R�R&R_tdelattrR�t__delattr__R{R`t_missingR�R7(R@RgR((s(/usr/lib/python2.7/site-packages/mock.pyR�s!
cCs|jpd}t|||�S(NRS(R�t_format_call_signature(R@RkRlRg((s(/usr/lib/python2.7/site-packages/mock.pyt_format_mock_call_signature(scCs]d}|j||�}|j}t|�dkr@|d}n|j|�}|||fS(Ns!Expected
call: %s
Actual call:
%sii(R�RxR�(R@RkRltmessagetexpected_stringRxt
actual_string((s(/usr/lib/python2.7/site-packages/mock.pyt_format_mock_failure_message-s
cOsw|}|jdkr=|j||�}td|f��n|j||fkrs|j||�}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 calledN(RxR4R�tAssertionErrorR�(t
_mock_selfRkRlR@texpectedR�((s(/usr/lib/python2.7/site-packages/mock.pyRj7scOsA|}|jdks1d|j}t|��n|j||�S(sVassert
that the mock was called exactly once and with the specified
arguments.is,Expected to be called once. Called %s
times.(RwR�Rj(R�RkRlR@R�((s(/usr/lib/python2.7/site-packages/mock.pyRmFs
cCs�|s5||jkr1td||jf��ndSt|j�}g}x@|D]8}y|j|�WqQtk
r�|j|�qQXqQW|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`.s(Calls not found.
Expected: %r
Actual: %rNs%r not all found in call list(RrR�R\tremovet
ValueErrorR�R](R@tcallst any_ordert all_callst not_foundtkall((s(/usr/lib/python2.7/site-packages/mock.pyRnQs
cOsGt||�}||jkrC|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(RRyR�R�(R@RkRlRR�((s(/usr/lib/python2.7/site-packages/mock.pyRoqs
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(R&R%t
CallableMixinR
RR Rt__mro__(R@R�t_typeRc((s(/usr/lib/python2.7/site-packages/mock.pyR�s
N('RRRR�R4R6R�RR�R�t"_NonCallableMock__get_return_valuet"_NonCallableMock__set_return_valuet"_NonCallableMock__return_value_docR�RtR�R�RvRwRxRyRrt!_NonCallableMock__get_side_effectt!_NonCallableMock__set_side_effectRzRsR�R�RR�R�R�R�R�RjRmRnRoR�(((s(/usr/lib/python2.7/site-packages/mock.pyR �sF
'
# 2 "
cCsW|dkr|St|�r |St|�r0|Syt|�SWntk
rR|SXdS(N(R4R+ROtiterR=(R((s(/usr/lib/python2.7/site-packages/mock.pyR��s
RcBsJeZddedddddddd�
Zd�Zd�Zd�ZRS(R0c
KsH||jd<tt|�j||||||| |
|�||_dS(NR�(R_R�RR6Rz(R@R�RzRtR
RgR�R�R�R�R�Rl((s(/usr/lib/python2.7/site-packages/mock.pyR6�s
cOsdS(N((R@RkRl((s(/usr/lib/python2.7/site-packages/mock.pyRR�scOs
|j||�|j||�S(N(RRt
_mock_call(R�RkRl((s(/usr/lib/python2.7/site-packages/mock.pyR:�scOs�|}t|_|jd7_t||fdt�|_|jjt||fdt��|j}|j}|j jtd||f��t
�}|dk}|jdk }|j
} x#|dk r�t|||f�}
|jr-d}|r�d}nt}|jdkrt}n|j||}n|r�|| krH|
}nt| ||f�}|jj|�|jdk }|r�|j
d| } q�n|j j|
�|j}t|�}
|
|kr�Pn|j|
�q�Wt}|j}|dk rjt|�r|�nt|�s@t|�}t|�r<|�n|S|||�}|tkrj|j}qjn|jdk r�|jtkr�|j||�S|tkr�|j}n|S(NittwoR0s()R�(R8RvRwt_CallRxRyR�R�R�RrR�R�R4R�RRqR�R�RRzR+RORRtR�R�(R�RkRlR@R�R�R�t
skip_next_dottdo_method_callsRgtthis_mock_callR�tthis_method_callt_new_parent_idtret_valteffectRT((s(/usr/lib/python2.7/site-packages/mock.pyR
�sn " N(RRR4RR6RRR:R
(((s(/usr/lib/python2.7/site-packages/mock.pyR�s 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.
Alternatively `side_effect` can be an exception class or instance. In
this case the exception will be raised when the mock is called.
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/lib/python2.7/site-packages/mock.pyRs4cCs=yt||�SWn%tk
r8t|�t||�SXdS(N(R?R7t
__import__(tthingtcomptimport_path((s(/usr/lib/python2.7/site-packages/mock.pyt_dot_lookup?s
cCs_|jd�}|jd�}t|�}x.|D]&}|d|7}t|||�}q1W|S(NR�is.%s(R�R�RR(ttargett
componentsRRR((s(/usr/lib/python2.7/site-packages/mock.pyt _importerGs
cCs
t|d�S(Ntis_local(thasattr(tpatcher((s(/usr/lib/python2.7/site-packages/mock.pyt_is_startedRst_patchcBsqeZd
Ze�Zd�Zd�Zd�Zd�Z d�Z
d�Zd�Zd�Z
d�Zd �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(R4RR�tgetterR�R�tnew_callableR�tcreateRt has_localR�tautospecRltadditional_patchers(
R@R!R�R�R�R#R�R%R"Rl((s(/usr/lib/python2.7/site-packages/mock.pyR6\s$ c
Cstt|j|j|j|j|j|j|j|j|j � }|j
|_
g|jD]}|j�^qU|_|S(N(
R
R!R�R�R�R#R�R%R"Rltattribute_nameR&tcopy(R@Rtp((s(/usr/lib/python2.7/site-packages/mock.pyR(ws%cCs)t|t�r|j|�S|j|�S(N(R(R*tdecorate_classtdecorate_callable(R@R((s(/usr/lib/python2.7/site-packages/mock.pyR:�s
cCsyxrt|�D]d}|jtj�s+q
nt||�}t|d�sOq
n|j�}t||||��q
W|S(NR:(R�R�RtTEST_PREFIXR?RR(R�(R@Rctattrt
attr_valueR((s(/usr/lib/python2.7/site-packages/mock.pyR*�scs~t�d�r#�jj|��St����fd���|g�_t�d�rzt�d�jj��_n�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(R]R/t __enter__R�R'R4tupdateR�RRtsystexc_infoR�t__exit__(Rktkeywargst
extra_argstentered_patchersR3tpatchingR�(Rtpatched(s(/usr/lib/python2.7/site-packages/mock.pyR9�s,
t func_codetcompat_co_firstlineno(RR/R�R
R?R:tco_firstlinenoR;(R@R((RR9s(/usr/lib/python2.7/site-packages/mock.pyR+�s#cCs�|j�}|j}t}t}y|j|}Wn)ttfk
r]t||t�}nXt}|j r�|tkr�td||f��n||fS(Ns!%s
does not have the attribute %r(
R!R�RRR_R7tKeyErrorR?R8R#(R@RRgRtlocal((s(/usr/lib/python2.7/site-packages/mock.pytget_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�RgR�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%RlR"R!RRR4R=R8R?RR(R*RR^ROR
R&R%R R�R1R'RbR�RttboolRt
temp_originalRR�R'R&R0(R@R�R�R�R%RlR"RR>tinherittKlasst_kwargst this_spectnot_callabletnew_attrR6R8R�((s(/usr/lib/python2.7/site-packages/mock.pyR0�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(RtRuntimeErrorRRBRR�RR�R�R#RR�R&R4(R@R3R((s(/usr/lib/python2.7/site-packages/mock.pyR4]s
cCs |j�}|jj|�|S(s-Activate a patch, returning
any created
mock.(R0t_active_patchesR�(R@RT((s(/usr/lib/python2.7/site-packages/mock.pytstartrscCs|jj|�|j�S(sStop
an active
patch.(RJtdiscardR4(R@((s(/usr/lib/python2.7/site-packages/mock.pytstopysN(RRR4R'R�RJR6R(R:R*R+R?R0R4RKRM(((s(/usr/lib/python2.7/site-packages/mock.pyR
Ws
2 ~ 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/lib/python2.7/site-packages/mock.pyR2�s(trsplitR=R�(RR�R!((Rs(/usr/lib/python2.7/site-packages/mock.pyt_get_target�sc
s1�fd�} t| ||||||||� S(s�
patch.object(target, attribute, new=DEFAULT, spec=None, create=False,
spec_set=None, autospec=None, new_callable=None, **kwargs)
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/lib/python2.7/site-packages/mock.pyR2�s(R (
RR�R�R�R#R�R%R"RlR!((Rs(/usr/lib/python2.7/site-packages/mock.pyt
_patch_object�sc
s�t��ttfkr*�fd�}n�fd�}|sNtd��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/lib/python2.7/site-packages/mock.pyR2�scs�S(N(((R(s(/usr/lib/python2.7/site-packages/mock.pyR2�ss=Must
supply at least one keyword argument with patch.multipleii(
R&tunicodetstrR�R\R�R
R'R&R�(
RR�R#R�R%R"RlR!R�R�R�Rtthis_patcher((Rs(/usr/lib/python2.7/site-packages/mock.pyt_patch_multiple�s& 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
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.
(ROR (
RR�R�R#R�R%R"RlR!R�((s(/usr/lib/python2.7/site-packages/mock.pyR�sEt_patch_dictcBs_eZdZded�Zd�Zd�Zd�Zd�Zd�Z d�Z
eZe
ZRS( 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(
R(t
basestringRtin_dictR�R�R1tclearR4t _original(R@RWR�RXRl((s(/usr/lib/python2.7/site-packages/mock.pyR6@s cs>t�t�r�j��St����fd��}|S(Ncs-�j�z�||�SWd�j�XdS(N(RUt
_unpatch_dict(RkR�(RR@(s(/usr/lib/python2.7/site-packages/mock.pyt_innerNs
(R(R*R*R
(R@RR[((RR@s(/usr/lib/python2.7/site-packages/mock.pyR:Ks
cCs�x~t|�D]p}t||�}|jtj�r
t|d�r
t|j|j|j �}||�}t
|||�q
q
W|S(NR:(R�R?R�RR,RRURWR�RXR�(R@RcR-R.t decoratort decorated((s(/usr/lib/python2.7/site-packages/mock.pyR*YscCs|j�dS(sPatch
the
dict.N(RU(R@((s(/usr/lib/python2.7/site-packages/mock.pyR0dscCs�|j}|j}|j}y|j�}Wn6tk
rci}x
|D]}||||<qHWnX||_|r�t|�ny|j|�Wn0tk
r�x
|D]}||||<q�WnXdS(N(R�RWRXR(R7RYt_clear_dictR1(R@R�RWRXRR�((s(/usr/lib/python2.7/site-packages/mock.pyRUis"
cCsd|j}|j}t|�y|j|�Wn0tk
r_x
|D]}||||<qDWnXdS(N(RWRYR^R1R7(R@RWRR�((s(/usr/lib/python2.7/site-packages/mock.pyRZ�s
cGs|j�tS(sUnpatch the
dict.(RZR(R@Rk((s(/usr/lib/python2.7/site-packages/mock.pyR4�s
((
RRRRR6R:R*R0RURZR4RKRM(((s(/usr/lib/python2.7/site-packages/mock.pyRU#s
cCsJy|j�Wn5tk
rEt|�}x|D]
}||=q1WnXdS(N(RXR7R\(RWtkeysR�((s(/usr/lib/python2.7/site-packages/mock.pyR^�s
cCs(x!ttj�D]}|j�qWdS(sStop
all active patches.N(R\R
RJRM(R((s(/usr/lib/python2.7/site-packages/mock.pyt_patch_stopall�sttests�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 s:add sub mul div floordiv mod lshift rshift and xor or pow t
ccs|]}d|VqdS(si%sN((t.0tn((s(/usr/lib/python2.7/site-packages/mock.pys <genexpr>�sccs|]}d|VqdS(sr%sN((RcRd((s(/usr/lib/python2.7/site-packages/mock.pys <genexpr>�sR0s
bool next s.unicode long nonzero oct hex truediv rtruediv
ccs|]}d|VqdS(s__%s__N((Rctmethod((s(/usr/lib/python2.7/site-packages/mock.pys <genexpr>�stcmptgetslicetsetslicetcoercet
subclassestformatR`R�tdeleteR�tmissingtreducet reduce_extgetinitargst
getnewargstgetstatetsetstatet getformatt setformattreprR�cs�fd�}||_|S(s:Turns
a callable object (like a mock) into a real
functioncs�|||�S(N((R@RkR�(R(s(/usr/lib/python2.7/site-packages/mock.pyRe�s(R(RgRRe((Rs(/usr/lib/python2.7/site-packages/mock.pyR��s ccs|]}d|VqdS(s__%s__N((RcRe((s(/usr/lib/python2.7/site-packages/mock.pys <genexpr>�sR�R�R6R�t__prepare____instancecheck__t__subclasscheck__t__del__cCs
tj|�S(N(R�t__hash__(R@((s(/usr/lib/python2.7/site-packages/mock.pyR2�sRzcCs
tj|�S(N(R�t__str__(R@((s(/usr/lib/python2.7/site-packages/mock.pyR2�sR{cCs
tj|�S(N(R�t
__sizeof__(R@((s(/usr/lib/python2.7/site-packages/mock.pyR2�sR|cCsttj|��S(N(RQR�R{(R@((s(/usr/lib/python2.7/site-packages/mock.pyR2�st__unicode__t__lt__t__gt__t__le__t__ge__it__int__R�t__len__R4y�?t__complex__g�?t __float__t__bool__t__nonzero__t1t__oct__t0x1t__hex__t__long__t __index__cs�fd�}|S(Ncs&�jj}|tk r|S�|kS(N(t__eq__R�R(totherR(R@(s(/usr/lib/python2.7/site-packages/mock.pyR�s((R@R�((R@s(/usr/lib/python2.7/site-packages/mock.pyt_get_eqscs�fd�}|S(Ncs
�jjtk rtS�|k S(N(t__ne__R�R(R�(R@(s(/usr/lib/python2.7/site-packages/mock.pyR� s((R@R�((R@s(/usr/lib/python2.7/site-packages/mock.pyt_get_nescs�fd�}|S(Ncs,�jj}|tkr"tg�St|�S(N(t__iter__R�RR (R(R@(s(/usr/lib/python2.7/site-packages/mock.pyR�s
((R@R�((R@s(/usr/lib/python2.7/site-packages/mock.pyt _get_itersR�R�R�cCs�tj|t�}|tk r+||_dStj|�}|dk r�y||�}Wntk
rut|�}nX||_dStj|�}|dk r�||�|_ndS(N( t_return_valuesR`RRtt_calculate_return_valueR4R7t_side_effect_methodsRz(RSReRgtfixedtreturn_calulatorRtt
side_effector((s(/usr/lib/python2.7/site-packages/mock.pyt_set_return_value!s
t
MagicMixincBseZd�Zd�ZRS(cOs'tt|�j||�|j�dS(N(R�R�R6t_mock_set_magics(R@RkR�((s(/usr/lib/python2.7/site-packages/mock.pyR69scCs�t}|jdk rstj|j�}t�}t|}x6|D]+}|t|�jkrAt||�qAqAWn|tt|�j�}t|�}x'|D]}t||t ||��q�WdS(N(
t_magicsR�R4tintersectionR�R&R_R�R�t
MagicProxy(R@tthese_magicst
remove_magicsR�R((s(/usr/lib/python2.7/site-packages/mock.pyR�>s
(RRR6R�(((s(/usr/lib/python2.7/site-packages/mock.pyR�8s 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�(R@R�R�((s(/usr/lib/python2.7/site-packages/mock.pyR�Ws(RRRRR�(((s(/usr/lib/python2.7/site-packages/mock.pyR
UscBseZdZed�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�(R@R�R�((s(/usr/lib/python2.7/site-packages/mock.pyR�ms(RRRRR�(((s(/usr/lib/python2.7/site-packages/mock.pyRbs
R�cBs/eZd�Zd�Zd�Zdd�ZRS(cCs||_||_dS(N(RgR�(R@RgR�((s(/usr/lib/python2.7/site-packages/mock.pyR6ys cOs|j�}|||�S(N(tcreate_mock(R@RkRltm((s(/usr/lib/python2.7/site-packages/mock.pyR:}scCsT|j}|j}|jd|d|d|�}t|||�t|||�|S(NRgR�R�(RgR�R�R�R�(R@R�R�R�((s(/usr/lib/python2.7/site-packages/mock.pyR��s cCs
|j�S(N(R�(R@RR((s(/usr/lib/python2.7/site-packages/mock.pyt__get__�sN(RRR6R:R�R4R�(((s(/usr/lib/python2.7/site-packages/mock.pyR�xs t_ANYcBs)eZdZd�Zd�Zd�ZRS(s2A
helper object that compares equal to
everything.cCstS(N(R8(R@R�((s(/usr/lib/python2.7/site-packages/mock.pyR��scCstS(N(R(R@R�((s(/usr/lib/python2.7/site-packages/mock.pyR��scCsdS(Ns<ANY>((R@((s(/usr/lib/python2.7/site-packages/mock.pyR�s(RRRR�R�R(((s(/usr/lib/python2.7/site-packages/mock.pyR��s c
Cs�d|}d}djg|D]}t|�^q�}djg|j�D]\}}d||f^qK�} |r|}n| r�|r�|d7}n|| 7}n||S(Ns%s(%%s)R0s,
s%s=%r(R�RvR�(
RgRkRlR�tformatted_argsR�targs_stringR�R1t
kwargs_string((s(/usr/lib/python2.7/site-packages/mock.pyR��s
(2
RcBsteZdZd d
d
eed�Zdd
d
eed�Zd�Zd�Z d�Z
d�Zd�Zd�Z
RS(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(NR0iii((R�R(RVR]R�(R�R1RgR�Rt from_kallRkRlt_lentfirsttsecond((s(/usr/lib/python2.7/site-packages/mock.pyR��s0 cCs||_||_||_dS(N(RgR�R�(R@R1RgR�RR�((s(/usr/lib/python2.7/site-packages/mock.pyR6�s cCs�|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(
NR0iiii(((((RR8R�R=RR(R]RV(R@R�t len_othert self_namet self_argstself_kwargst
other_namet
other_argstother_kwargsR1R�R�((s(/usr/lib/python2.7/site-packages/mock.pyR��sF
cCs|j|�S(N(R�(R@R�((s(/usr/lib/python2.7/site-packages/mock.pyR�scOsW|jdkr(td||fdd�S|jd}t|j||fd|d|�S(NR0Rgs()R�(RgR4R(R@RkRlRg((s(/usr/lib/python2.7/site-packages/mock.pyR:"s
cCsN|jdkr"td|dt�Sd|j|f}td|d|dt�S(NRgR�s%s.%sR�(RgR4RR(R@R-Rg((s(/usr/lib/python2.7/site-packages/mock.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�RgR�R�R�(R@RgRkRl((s(/usr/lib/python2.7/site-packages/mock.pyR1s
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(R4R�R�R�RpR�(R@tvalsR((s(/usr/lib/python2.7/site-packages/mock.pyt call_listFs
(N((RRRR4RR8R�R6R�R�R:R�RR�(((s(/usr/lib/python2.7/site-packages/mock.pyR�s
2 R�cKst|�rt|�}nt|t�}i|d6}|rMi|d6}n|dkrbi}n|j|�t}t|�tkr�i}n7t|�s�t }n"|r�|r�t
|�r�t }n|} |dkr�d} n|d|d|d| d||�}
t|t�r't|
|�}
nt
||
||�|dk r]|r]|
|j|<n|r�|r�d|kr�t||d td
dd|
�|
_nxdt|�D]V}t|�r�q�nt|t�r�|tkr�q�nyt||�}Wntk
rq�nXi|d6}|r0i|d6}nt|t�sgt|||
||�}
|
|
j|<nw|
}t|t�r�|
j}ntd|d|d|d||�}
|
|
j|<t|||�}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�R0R�R�R�RgRtRCR@s()R�RBN(R^R&R(R*R4R1RtDescriptorTypesROR
RbR9RiRWR{RR8RtR�R}tFunctionAttributesR?R7R�RSt
_must_skipR�(R�R�RCR�R@Rltis_typeRERDR�RSR�RR�R�RB((s(/usr/lib/python2.7/site-packages/mock.pyRWsn
cCs�t|t�s7|t|di�kr+tS|j}nt|d�sJ|SxR|jD]G}|jj|t �}|t kr�qTnt|t
tf�r�tS|SW|S(NR_R(R(R*R?RR�RRR_R`Rtstaticmethodtclassmethod(R�R�R�RcRT((s(/usr/lib/python2.7/site-packages/mock.pyR��scCs*y|jSWntk
r%t|�SXdS(N(R�R7R&(R((s(/usr/lib/python2.7/site-packages/mock.pyR��s
R�cBs
eZeddded�ZRS(cCs:||_||_||_||_||_||_dS(N(R�tidsR�R�RCRg(R@R�R�R�RgR�RC((s(/usr/lib/python2.7/site-packages/mock.pyR6�s N(RRRR4R6(((s(/usr/lib/python2.7/site-packages/mock.pyR��stfunc_closureR:RXt func_dicttfunc_doctfunc_globalst func_namecCs�tdkr]trTddl}ttt|j��jtt|j ����aq]t
an|dkr�tdddt�}ntdt�}d|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` method of the file handle to
return.
This is an empty string by default.
i����NRgtopenR�(t file_specR4R;t_ioR\R�R�t
TextIOWrappertuniontBytesIOtfileRR�twriteRtR0tread(RSt read_dataR�thandle((s(/usr/lib/python2.7/site-packages/mock.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(R@Rl((s(/usr/lib/python2.7/site-packages/mock.pyR�9 scCs|�S(N((R@Rtobj_type((s(/usr/lib/python2.7/site-packages/mock.pyR�< scCs||�dS(N((R@RR�((s(/usr/lib/python2.7/site-packages/mock.pyt__set__> s(RRRR�R�R�(((s(/usr/lib/python2.7/site-packages/mock.pyR0 s (�t__all__t__version__R�R2R3R5R4t functoolsR
Rtversion_infoRQt NameErrorRRRVtlongtintt
BaseExceptiont ExceptionRR)tplatformRtlangt ThrowabletisidentifierR
R7RtretcompiletIRR;tsuperR�R@tbuiltinR8RR'R+R�R,R&R-R�R�RRNRWRQROR^RbRiRfR}R~R�RRtMISSINGR�tDELETEDR�R�t ClassTypeR�R*R�R�R�R\RpR�R�R R�RRRRRR
RORPRTRRUR^R`R�tmultipletstopallR,t
magic_methodstnumericsR�R�tinplacetrighttextrat
_non_defaultsR�R�R�R�R�tNotImplementedR�R�R�R�R�R�R�R
RR�R�RR�R]RRRR�R�R�R�R9R�R�RR(((s(/usr/lib/python2.7/site-packages/mock.pyt<module>s�
1
+ �� d8 �* 1 Jv
+
� u !