ž qyMa1c@s‹dddddddddd d d d f Zd ZddlZddlZddlZddlmZefZdej kr ddl Z ee j j fZne ZeZdd„Zdd„ZGdd„deƒZeejƒefZedd„Zedd„Zdd„Zdd„Zd d!„Zd"d#„Zed$d%„Z d&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*d.d/„Z+e,d0d1d2d3d4d5d6d7gƒZ-d8d9„Z.Gd:d;„d;e/ƒZ0d<d=„Z1Gd>d?„d?eƒZ2Gd@d „d e2ƒZ3dAdB„Z4GdCdD„dDe2ƒZ5GdEd„de5e3ƒZ6dFdG„Z7dHdI„Z8dJdK„Z9GdLdM„dMeƒZ:dNdO„Z;e&e<ee<e<e<dPdQ„Z=e<ee<e<e<dRdS„Z>e&e<ee<e<e<dTd„Z?GdUdV„dVeƒZ@dWdX„ZAdYdZ„ZBe=e?_e@e?_Ce>e?_DeBe?_Ed[e?_Fd\ZGd]ZHd^jId_d`„eHjJƒDƒƒZKd^jIdad`„eHjJƒDƒƒZLe,dbd`„dcdddedfdgdhdidjdkdldmdndodpdqdrdsgDƒƒZMdtdu„ZNe,dvd`„d^jIeGeHeKeLgƒjJƒDƒƒZOeOeMBZPe,dwdxdydzd{d|d}gƒZQid~d„d€6dd„d‚6dƒd„d„6ZRi eSd…6eSd†6eSd‡6eSdˆ6d‰dŠ6ed‹6ddŒ6ed6dŽd6dd‘6e d’6d‰d“6ZTd”d•„ZUd–d—„ZVd˜d™„ZWieUdš6eVd›6eWdœ6ZXddž„ZYGdŸd „d eƒZZGd¡d „d eZe3ƒZ[Gd¢d„deZe6ƒZ\Gd£d¤„d¤eƒZ]Gd¥d¦„d¦eƒZ^e^ƒZ_d§d¨„Z`Gd©dª„dªeaƒZbebd«eƒZceee<e<d¬d„Zdd­d®„Zed¯d°„ZfGd±d²„d²eƒZgeedƒee_jhƒfZie<aje<d³d´d „ZkGdµd „d e6ƒZldS(¶uMocku MagicMockupatchusentineluDEFAULTuANYucallucreate_autospecu FILTER_DIRuNonCallableMockuNonCallableMagicMocku mock_openu PropertyMocku1.0iN(uwrapsujavacCstt|ƒtƒS(N(u issubclassutypeuNonCallableMock(uobj((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_is_instance_mock.su_is_instance_mockcCs+t|tƒp*t|tƒo*t|tƒS(N(u isinstanceuBaseExceptionsutypeu issubclass(uobj((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _is_exception4su _is_exceptioncBs|EeZdZdgZdS(u_slotteduaN(u__name__u __module__u __qualname__u __slots__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_slotted;su_slottedc CsIt|tƒrE| rEy |j}Wntk r;dSYnXd}n8t|tƒs}y |j}Wq}tk rydSYq}Xnytj|ƒ}Wnt k r¨dSYnX|\}}}}}} } t |ddƒdk rï|dd…}n|r|dd…}ntj |||||| | ddd„ƒ} | dd…|fS(Nu__self__iu formatvaluecSsdS(Nu((uvalue((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuesu_getsignature..Tiÿÿÿÿ( u isinstanceutypeu__init__uAttributeErroruTrueu FunctionTypesu__call__uinspectugetfullargspecu TypeErrorugetattruNoneu formatargspec( ufuncu skipfirstuinstanceuargspecuregargsuvarargsuvarkwudefaultsukwonlyu kwonlydefuannu signature((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _getsignatureEs0          u _getsignaturecCswt|ƒsdSt|||ƒ}|dkr2dS|\}}d|}t|iƒ}t||ƒ|t|ƒ_dS(Nulambda _mock_self, %s: None(u _callableu _getsignatureuNoneuevalu_copy_func_detailsutypeu_mock_check_sig(ufuncumocku skipfirstuinstanceuresultu signatureusrcuchecksig((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_check_signatureis     u_check_signaturecCs@|j|_|j|_|j|_|j|_|j|_dS(N(u__name__u__doc__u __module__u __defaults__u__kwdefaults__(ufuncufuncopy((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_copy_func_detailszs     u_copy_func_detailscCs3t|tƒrdSt|ddƒdk r/dSdS(Nu__call__TF(u isinstanceutypeuTrueugetattruNoneuFalse(uobj((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _callable„s u _callablecCst|ƒttfkS(N(utypeulistutuple(uobj((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_is_listŒsu_is_listcCs`t|tƒs%t|ddƒdk Sx4|f|jD]"}|jjdƒdk r6dSq6WdS(utGiven an object, return True if the object is callable. For classes, return True if instances would be callable.u__call__NTF( u isinstanceutypeugetattruNoneu__mro__u__dict__ugetuTrueuFalse(uobjubase((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_instance_callable’s u_instance_callablec Cs×t|ƒsdSt|tƒ}t|||ƒ}|dkrAdS|\}}d|}t|iƒ}t||ƒ|j} | jƒs‘d} ni|d6|d6} d| }t || ƒ| | } t | |ƒ| S(Nulambda %s: Noneufuncopyu _checksig_umockuYdef %s(*args, **kwargs): _checksig_(*args, **kwargs) return mock(*args, **kwargs)( u _callableu isinstanceutypeu _getsignatureuNoneuevalu_copy_func_detailsu__name__u isidentifieruexecu _setup_func( umockuoriginaluinstanceu skipfirsturesultu signatureufuncusrcuchecksigunameucontextufuncopy((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_set_signature¡s&            u_set_signaturecsˆˆ_tˆƒsdS‡fdd†}‡fdd†}‡fdd†}‡fdd†}‡‡fd d †}d ˆ_d ˆ_dˆ_tƒˆ_tƒˆ_ tƒˆ_ ˆj ˆ_ ˆj ˆ_ ˆj ˆ_ |ˆ_|ˆ_|ˆ_|ˆ_|ˆ_ˆˆ_dS( Ncsˆj||ŽS(N(uassert_called_with(uargsukwargs(umock(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuassert_called_withÈsu'_setup_func..assert_called_withcsˆj||ŽS(N(uassert_called_once_with(uargsukwargs(umock(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuassert_called_once_withÊsu,_setup_func..assert_called_once_withcsˆj||ŽS(N(uassert_has_calls(uargsukwargs(umock(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuassert_has_callsÌsu%_setup_func..assert_has_callscsˆj||ŽS(N(uassert_any_call(uargsukwargs(umock(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuassert_any_callÎsu$_setup_func..assert_any_callcsTtƒˆ_tƒˆ_ˆjƒˆj}t|ƒrP|ˆk rP|jƒndS(N(u _CallListu method_callsu mock_callsu reset_mocku return_valueu_is_instance_mock(uret(ufuncopyumock(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu reset_mockÐs     u_setup_func..reset_mockiF(umocku_is_instance_mockuFalseucalledu call_countuNoneu call_argsu _CallListucall_args_listu method_callsu mock_callsu return_valueu side_effectu_mock_childrenuassert_called_withuassert_called_once_withuassert_has_callsuassert_any_callu reset_mocku_mock_delegate(ufuncopyumockuassert_called_withuassert_called_once_withuassert_has_callsuassert_any_callu reset_mock((ufuncopyumocku2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _setup_funcÁs.                u _setup_funccCsd|dd…|kS(Nu__%s__iiþÿÿÿ((uname((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _is_magicìsu _is_magiccBs2|EeZdZdZdd„Zdd„ZdS(u_SentinelObjectu!A unique, named, sentinel object.cCs ||_dS(N(uname(uselfuname((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__init__òsu_SentinelObject.__init__cCs d|jS(Nu sentinel.%s(uname(uself((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__repr__õsu_SentinelObject.__repr__N(u__name__u __module__u __qualname__u__doc__u__init__u__repr__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_SentinelObjectðs u_SentinelObjectcBs2|EeZdZdZdd„Zdd„ZdS(u _SentineluAAccess attributes to return a named object, usable as a sentinel.cCs i|_dS(N(u _sentinels(uself((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__init__ûsu_Sentinel.__init__cCs.|dkrt‚n|jj|t|ƒƒS(Nu __bases__(uAttributeErroru _sentinelsu setdefaultu_SentinelObject(uselfuname((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu __getattr__þs  u_Sentinel.__getattr__N(u__name__u __module__u __qualname__u__doc__u__init__u __getattr__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _Sentinelùs u _SentinelcCs2t|ƒttttfkr.t|ƒ|ƒS|S(N(utypeudictulistutupleuset(uvalue((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_copy su_copyu return_valueu_mock_return_valueu side_effectu_mock_side_effectu _mock_parentu_mock_new_parentu _mock_nameu_mock_new_namecCsHtj|ƒd|}||dd„}||dd„}t||ƒS(Nu_mock_cSs/|j}|dkr"t||ƒSt||ƒS(N(u_mock_delegateuNoneugetattr(uselfunameu _the_nameusig((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_gets   u"_delegating_property.._getcSs9|j}|dkr%||j|._set(u_allowed_namesuadduproperty(unameu _the_nameu_getu_set((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_delegating_propertys   u_delegating_propertycBs,|EeZdZdd„Zdd„ZdS(u _CallListcCs‘t|tƒstj||ƒSt|ƒ}t|ƒ}||krGdSxCtd||dƒD]*}||||…}||kr_dSq_WdS(NiiFT(u isinstanceulistu __contains__ulenuFalseurangeuTrue(uselfuvalueu len_valueulen_selfuiusub_list((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu __contains__0s    u_CallList.__contains__cCstjt|ƒƒS(N(upprintupformatulist(uself((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__repr__>su_CallList.__repr__N(u__name__u __module__u __qualname__u __contains__u__repr__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _CallList.s u _CallListcCs°t|ƒsdS|js@|js@|jdk s@|jdk rDdS|}x)|dk ru||kridS|j}qMW|r‘||_||_n|r¬||_||_ndS(NFT(u_is_instance_mockuFalseu _mock_nameu_mock_new_nameu _mock_parentuNoneu_mock_new_parentuTrue(uparentuvalueunameunew_nameu_parent((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_check_and_set_parentBs$       u_check_and_set_parentcBs,|EeZdZeZdZdd„ZdS(uBasecOsdS(N((uselfuargsukwargs((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__init___su Base.__init__N(u__name__u __module__u __qualname__uDEFAULTu_mock_return_valueuNoneu_mock_side_effectu__init__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuBase\suBasec BsÁ|EeZdZdZdd„Zd9d9d9d9d9d9dd9dd„Zdd„Zd:d d „Z d d „Z d d„Z dd„Z dZ ee e e ƒZedd„ƒZedƒZedƒZedƒZedƒZedƒZdd„Zdd„ZeeeƒZdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Z d+d,„Z!d-d.„Z"d/d0„Z#d1d2„Z$d:d3d4„Z%d5d6„Z&d7d8„Z'd9S(;uNonCallableMocku A non-callable version of `Mock`cOs5t|j|fi|jd6ƒ}tj|ƒ}|S(Nu__doc__(utypeu__name__u__doc__uobjectu__new__(uclsuargsukwunewuinstance((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__new__gs"uNonCallableMock.__new__uc Ks|dkr|}n|j} || d<|| d<|| d<|| d<|dk ra|}d}n|j||ƒi| d<|| d|jdk r||j_n||_t||ddƒdS(Nu()(u_mock_delegateuNoneu return_valueu_mock_return_valueu_check_and_set_parent(uselfuvalue((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__set_return_valueÍs u"NonCallableMock.__set_return_valueu1The value to be returned when the mock is called.cCs |jdkrt|ƒS|jS(N(u _spec_classuNoneutype(uself((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu __class__Ùs uNonCallableMock.__class__ucalledu call_countu call_argsucall_args_listu mock_callscCs#|j}|dkr|jS|jS(N(u_mock_delegateuNoneu_mock_side_effectu side_effect(uselfu delegated((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__get_side_effectæs  u!NonCallableMock.__get_side_effectcCs:t|ƒ}|j}|dkr-||_n ||_dS(N(u _try_iteru_mock_delegateuNoneu_mock_side_effectu side_effect(uselfuvalueu delegated((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__set_side_effectìs     u!NonCallableMock.__set_side_effectcCsªd|_d|_d|_tƒ|_tƒ|_tƒ|_x6|j j ƒD]%}t |t ƒrjqOn|j ƒqOW|j}t|ƒr¦||k r¦|j ƒndS(u-Restore the mock object to its initial state.iNF(uFalseucalleduNoneu call_argsu call_countu _CallListu mock_callsucall_args_listu method_callsu_mock_childrenuvaluesu isinstanceu _SpecStateu reset_mocku_mock_return_valueu_is_instance_mock(uselfuchilduret((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu reset_mock÷s       uNonCallableMock.reset_mockcKs„x}t|jƒddd„ƒD]]\}}|jdƒ}|jƒ}|}x|D]}t||ƒ}qSWt|||ƒqWdS(uZSet 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)ukeycSs|djdƒS(Niu.(ucount(uentry((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyusu0NonCallableMock.configure_mock..u.N(usorteduitemsusplitupopugetattrusetattr(uselfukwargsuarguvaluargsufinaluobjuentry((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuconfigure_mock s   uNonCallableMock.configure_mockc Cs]|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|(u()u().(umockumock.(u_mock_new_nameu_mock_new_parentusetuNoneuappenduiduaddulistureversedu _mock_nameulenujoinu _spec_classu _spec_setu__name__utype( uselfu _name_listu_parentulastudotuseenu_firstunameu name_stringu spec_string((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__repr__CsL            uNonCallableMock.__repr__cCsŽtstj|ƒS|jpg}tt|ƒƒ}t|jƒ}dd„|Dƒ}dd„|Dƒ}tt |||t|j ƒƒƒS(u8Filter the output of `dir(mock)` to only useful members.cSs%g|]}|jdƒs|‘qS(u_(u startswith(u.0ue((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu ~s u+NonCallableMock.__dir__..cSs2g|](}|jdƒ s(t|ƒr|‘qS(u_(u startswithu _is_magic(u.0ue((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu s ( u FILTER_DIRuobjectu__dir__u _mock_methodsudirutypeulistu__dict__usortedusetu_mock_children(uselfuextrasu from_typeu from_dict((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__dir__us uNonCallableMock.__dir__c s|tkrtjˆ||ƒSˆjrhˆjdk rh|ˆjkrh|ˆjkrhtd|ƒ‚n"|tkrd|}t|ƒ‚ný|t krLˆjdk rÊ|ˆjkrÊtd|ƒ‚nt |ƒst t ˆƒ|t ||ƒƒ|‰‡‡fdd†}qŠtˆ|d|ƒt t ˆƒ||ƒ|ˆj||dkre|ˆ_dStˆ|||ƒrŠ|ˆj|—su-NonCallableMock.__setattr__..u __class__(u_allowed_namesuobjectu __setattr__u _spec_setu _mock_methodsuNoneu__dict__uAttributeErroru_unsupported_magicsu _all_magicsu_is_instance_mockusetattrutypeu _get_methodu_check_and_set_parentu_mock_childrenu _spec_class(uselfunameuvalueumsg((uoriginaluselfu2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu __setattr__…s2       uNonCallableMock.__setattr__cCsÆ|tkrJ|t|ƒjkrJtt|ƒ|ƒ||jkrJdSn||jkrltj||ƒn|jj|tƒ}|t krœt |ƒ‚n|tk rµ|j|=nt |j|s u_patch.copy..( u_patchugetteru attributeunewuspecucreateuspec_setuautospecu new_callableukwargsuattribute_nameuadditional_patchers(uselfupatcher((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyucopy s  u _patch.copycCs)t|tƒr|j|ƒS|j|ƒS(N(u isinstanceutypeudecorate_classudecorate_callable(uselfufunc((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__call__s u_patch.__call__cCsyxrt|ƒD]d}|jtjƒs+q nt||ƒ}t|dƒsOq n|jƒ}t||||ƒƒq W|S(Nu__call__(udiru startswithupatchu TEST_PREFIXugetattruhasattrucopyusetattr(uselfuklassuattru attr_valueupatcher((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyudecorate_classs u_patch.decorate_classcsTtˆdƒr#ˆjj|ƒˆStˆƒ‡‡fdd†ƒ‰|gˆ_ˆS(Nu 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(utupleu patchingsu __enter__uappenduattribute_nameuNoneuupdateunewuDEFAULTu _is_startedusysuexc_infoureversedu__exit__(uargsukeywargsu extra_argsuentered_patchersuexc_infoupatchinguarg(ufuncupatched(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyupatched/s*       u)_patch.decorate_callable..patched(uhasattru patchingsuappenduwraps(uselfufunc((ufuncupatchedu2/opt/alt/python33/lib64/python3.3/unittest/mock.pyudecorate_callable*s ! u_patch.decorate_callablec Csž|jƒ}|j}t}d}y|j|}Wn*ttfk r^t||tƒ}YnXd}|j r”|tkr”td||fƒ‚n||fS(Nu!%s does not have the attribute %rFT( ugetteru attributeuDEFAULTuFalseu__dict__uAttributeErroruKeyErrorugetattruTrueucreate(uselfutargetunameuoriginalulocal((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu get_originalRs  u_patch.get_originalcCsž|j|j|j}}}|j|j}}|j}|jƒ|_|dkr]d}n|dkrrd}n|dkr‡d}n|dk r®|dk r®t dƒ‚n|dk sÆ|dk rá|dkrát dƒ‚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³t dƒ‚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|| dsu_get_target..(ursplitu TypeErroru ValueError(utargetu attributeugetter((utargetu2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _get_targetsu _get_targetc s4‡fdd†} t| ||||||||ƒ S(u 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(((utarget(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu$su_patch_object..(u_patch( utargetu attributeunewuspecucreateuspec_setuautospecu new_callableukwargsugetter((utargetu2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _patch_objectsu _patch_objectc sÿtˆƒtkr'‡fdd†}n‡fdd†}|sNtdƒ‚nt|jƒƒ}|d\} } t|| | |||||iƒ } | | _x[|dd…D]I\} } t|| | |||||iƒ } | | _| jj| ƒq®W| S(u¾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(u _importer((utarget(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuBsu!_patch_multiple..csˆS(N(((utarget(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuDsu=Must supply at least one keyword argument with patch.multipleiiN( utypeustru ValueErrorulistuitemsu_patchuattribute_nameuadditional_patchersuappend( utargetuspecucreateuspec_setuautospecu new_callableukwargsugetteruitemsu attributeunewupatcheru this_patcher((utargetu2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_patch_multiple+s&   u_patch_multiplec Ks4t|ƒ\}} t|| |||||||ƒ S(u¼ `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. (u _get_targetu_patch( utargetunewuspecucreateuspec_setuautospecu new_callableukwargsugetteru attribute((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyupatch\sEcBs€|EeZdZdZfddd„Zdd„Zdd„Zdd „Zd d „Z d d „Z dd„Z eZ e Z dS(u _patch_dictu# 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( u isinstanceustru _importeruin_dictudictuvaluesuupdateuclearuNoneu _original(uselfuin_dictuvaluesuclearukwargs((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__init__Ås  u_patch_dict.__init__csAtˆtƒrˆjˆƒStˆƒ‡‡fdd†ƒ}|S(Nc s-ˆjƒzˆ||ŽSWdˆjƒXdS(N(u _patch_dictu _unpatch_dict(uargsukw(ufuself(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_innerÓs u$_patch_dict.__call__.._inner(u isinstanceutypeudecorate_classuwraps(uselfufu_inner((ufuselfu2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__call__Ðs !u_patch_dict.__call__cCs…x~t|ƒD]p}t||ƒ}|jtjƒr t|dƒr t|j|j|j ƒ}||ƒ}t |||ƒq q W|S(Nu__call__( udirugetattru startswithupatchu TEST_PREFIXuhasattru _patch_dictuin_dictuvaluesuclearusetattr(uselfuklassuattru attr_valueu decoratoru decorated((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyudecorate_classÞs u_patch_dict.decorate_classcCs|jƒdS(uPatch the dict.N(u _patch_dict(uself((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu __enter__ésu_patch_dict.__enter__cCsÊ|j}|j}|j}y|jƒ}Wn7tk rdi}x|D]}||||@su ccs|]}d|VqdS(ur%sN((u.0un((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu Asccs|]}d|VqdS(u__%s__N((u.0umethod((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu Gsugetusetudeleteureversedumissingureduceu reduce_exu getinitargsu getnewargsugetstateusetstateu getformatu setformatureprudiru subclassesuformatcs‡fdd†}||_|S(u:Turns a callable object (like a mock) into a real functioncsˆ|||ŽS(N((uselfuargsukw(ufunc(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyumethodPsu_get_method..method(u__name__(unameufuncumethod((ufuncu2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _get_methodNs u _get_methodccs|]}d|VqdS(u__%s__N((u.0umethod((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu Wsu __getattr__u __setattr__u__init__u__new__u__prepare____instancecheck__u__subclasscheck__u__del__cCs tj|ƒS(N(uobjectu__hash__(uself((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuesuu__hash__cCs tj|ƒS(N(uobjectu__str__(uself((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyufsu__str__cCs tj|ƒS(N(uobjectu __sizeof__(uself((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyugsu __sizeof__u__lt__u__gt__u__le__u__ge__iu__int__u __contains__u__len__u__exit__yð?u __complex__gð?u __float__u__bool__u __index__cs‡fdd†}|S(Ncs&ˆjj}|tk r|Sˆ|kS(N(u__eq__u_mock_return_valueuDEFAULT(uotheruret_val(uself(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__eq__{s  u_get_eq..__eq__((uselfu__eq__((uselfu2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_get_eqzsu_get_eqcs‡fdd†}|S(Ncs ˆjjtk rtSˆ|k S(N(u__ne__u_mock_return_valueuDEFAULT(uother(uself(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__ne__ƒsu_get_ne..__ne__((uselfu__ne__((uselfu2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_get_ne‚su_get_necs‡fdd†}|S(Ncs,ˆjj}|tkr"tgƒSt|ƒS(N(u__iter__u_mock_return_valueuDEFAULTuiter(uret_val(uself(u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__iter__Šs   u_get_iter..__iter__((uselfu__iter__((uselfu2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu _get_iter‰su _get_iteru__eq__u__ne__u__iter__c Csµtj|tƒ}|tk r+||_dStj|ƒ}|dk r„y||ƒ}Wntk rvt|ƒ}YnX||_dStj|ƒ}|dk r±||ƒ|_ndS(N( u_return_valuesugetuDEFAULTu return_valueu_calculate_return_valueuNoneuAttributeErroru_side_effect_methodsu side_effect(umockumethodunameufixedureturn_calulatoru return_valueu side_effector((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_set_return_value›s      u_set_return_valuecBs,|EeZdZdd„Zdd„ZdS(u MagicMixincOs'tt|ƒj||Ž|jƒdS(N(u _safe_superu MagicMixinu__init__u_mock_set_magics(uselfuargsukw((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__init__³suMagicMixin.__init__cCsÆt}|jdk rstj|jƒ}tƒ}t|}x6|D]+}|t|ƒjkrAt||ƒqAqAWn|tt|ƒjƒ}t|ƒ}x'|D]}t||t ||ƒƒqŸWdS(N( u_magicsu _mock_methodsuNoneu intersectionusetutypeu__dict__udelattrusetattru MagicProxy(uselfu these_magicsu remove_magicsuentryu_type((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_mock_set_magics¸s     uMagicMixin._mock_set_magicsN(u__name__u __module__u __qualname__u__init__u_mock_set_magics(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu MagicMixin²s u MagicMixincBs)|EeZdZdZddd„ZdS(uNonCallableMagicMocku-A version of `MagicMock` that isn't callable.cCs|j||ƒ|jƒdS(uð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(u_mock_add_specu_mock_set_magics(uselfuspecuspec_set((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu mock_add_specÑsu"NonCallableMagicMock.mock_add_specNF(u__name__u __module__u __qualname__u__doc__uFalseu mock_add_spec(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyuNonCallableMagicMockÏscBs)|EeZdZdZddd„ZdS(u MagicMocku„ 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(uð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(u_mock_add_specu_mock_set_magics(uselfuspecuspec_set((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu mock_add_specçsuMagicMock.mock_add_specNF(u__name__u __module__u __qualname__u__doc__uFalseu mock_add_spec(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu MagicMockÜs cBsG|EeZdZdd„Zdd„Zdd„Zd dd„Zd S( u MagicProxycCs||_||_dS(N(unameuparent(uselfunameuparent((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__init__ós uMagicProxy.__init__cOs|jƒ}|||ŽS(N(u create_mock(uselfuargsukwargsum((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__call__÷s uMagicProxy.__call__cCsT|j}|j}|jd|d|d|ƒ}t|||ƒt|||ƒ|S(Nunameu _new_nameu _new_parent(unameuparentu_get_child_mockusetattru_set_return_value(uselfuentryuparentum((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu create_mockûs   uMagicProxy.create_mockcCs |jƒS(N(u create_mock(uselfuobju_type((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__get__suMagicProxy.__get__N(u__name__u __module__u __qualname__u__init__u__call__u create_mockuNoneu__get__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu MagicProxyòs   u MagicProxycBs>|EeZdZdZdd„Zdd„Zdd„ZdS( u_ANYu2A helper object that compares equal to everything.cCsdS(NT(uTrue(uselfuother((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__eq__ su _ANY.__eq__cCsdS(NF(uFalse(uselfuother((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__ne__su _ANY.__ne__cCsdS(Nu((uself((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__repr__su _ANY.__repr__N(u__name__u __module__u __qualname__u__doc__u__eq__u__ne__u__repr__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_ANY s  u_ANYcCs‹d|}d}djdd„|Dƒƒ}djdd„|jƒDƒƒ}|r]|}n|rƒ|rv|d7}n||7}n||S(Nu%s(%%s)uu, cSsg|]}t|ƒ‘qS((urepr(u.0uarg((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu s u*_format_call_signature..cSs&g|]\}}d||f‘qS(u%s=%r((u.0ukeyuvalue((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu s (ujoinuitems(unameuargsukwargsumessageuformatted_argsu args_stringu kwargs_string((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_format_call_signatures    u_format_call_signaturecBs˜|EeZdZdZfdddddd„Zfdddddd„Zdd„Z dd „Z d d „Z d d „Z dd„Z dd„ZdS(u_Callu£ 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. c Csd}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(Nuiii(ulenu isinstanceustrutupleu__new__( uclsuvalueunameuparentutwou from_kalluargsukwargsu_lenufirstusecond((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__new__>s0           u _Call.__new__cCs||_||_||_dS(N(unameuparentu from_kall(uselfuvalueunameuparentutwou from_kall((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__init___s  u_Call.__init__c CsŸ|tkrdSyt|ƒ}Wntk r8dSYnXd}t|ƒdkr`|\}}n|\}}}d}|dkr‘fi}}nâ|dkr¯|\}}}nÄ|dkr|\} t| tƒrâ| }i}qst| tƒr| }fi}}qsf}| }n]|\} } t| tƒrf| }t| tƒrV| i}}qsf| }}n | | }}|r‰||kr‰dS||f||fkS(NuiiiiTF(uANYuTrueulenu TypeErroruFalseu isinstanceutupleustr( uselfuotheru len_otheru self_nameu self_argsu self_kwargsu other_nameu other_argsu other_kwargsuvalueufirstusecond((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__eq__fsF           u _Call.__eq__cCs|j|ƒ S(N(u__eq__(uselfuother((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__ne__˜su _Call.__ne__cOsW|jdkr(td||fddƒS|jd}t|j||fd|d|ƒS(Nuunameu()uparent(unameuNoneu_Call(uselfuargsukwargsuname((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__call__œs u_Call.__call__cCsN|jdkr"td|ddƒSd|j|f}td|d|ddƒS(Nunameu from_kallu%s.%suparentF(unameuNoneu_CalluFalse(uselfuattruname((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu __getattr__¤su_Call.__getattr__cCs³|js8|jpd}|jdƒr4d|}n|St|ƒdkr_d}|\}}nD|\}}}|s}d}n&|jdƒs™d|}n d|}t|||ƒS(Nucallu()ucall%siucall.%s(u from_kallunameu startswithulenu_format_call_signature(uselfunameuargsukwargs((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__repr__«s     u_Call.__repr__cCsQg}|}x2|dk r@|jr4|j|ƒn|j}qWtt|ƒƒS(u•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(uNoneu from_kalluappenduparentu _CallListureversed(uselfuvalsuthing((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu call_listÀs  u_Call.call_listNFT(u__name__u __module__u __qualname__u__doc__uNoneuFalseuTrueu__new__u__init__u__eq__u__ne__u__call__u __getattr__u__repr__u call_list(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_Call+s   2    u_Callu from_kallcKsèt|ƒrt|ƒ}nt|tƒ}i|d6}|rMi|d6}n|dkrbi}n|j|ƒt}t|ƒtkri}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 ||EeZdZdZdd„Zdd„Zdd„ZdS( u PropertyMockuW 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(u MagicMock(uselfukwargs((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu_get_child_mockœsuPropertyMock._get_child_mockcCs|ƒS(N((uselfuobjuobj_type((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__get__ŸsuPropertyMock.__get__cCs||ƒdS(N((uselfuobjuval((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu__set__¡suPropertyMock.__set__N(u__name__u __module__u __qualname__u__doc__u_get_child_mocku__get__u__set__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyu PropertyMock“s  (mu__all__u __version__uinspectupprintusysu functoolsuwrapsu BaseExceptionuBaseExceptionsuplatformujavaulangu ThrowableuTrueu FILTER_DIRusuperu _safe_superu_is_instance_mocku _is_exceptionuobjectu_slottedutypeuaupropertyuDescriptorTypesuFalseu _getsignatureu_check_signatureu_copy_func_detailsu _callableu_is_listu_instance_callableu_set_signatureu _setup_funcu _is_magicu_SentinelObjectu _SentinelusentineluDEFAULTuMISSINGu_missinguDELETEDu_deletedu_copyusetu_allowed_namesu_delegating_propertyulistu _CallListu_check_and_set_parentuBaseuNonCallableMocku _try_iteru CallableMixinuMocku _dot_lookupu _importeru _is_startedu_patchu _get_targetuNoneu _patch_objectu_patch_multipleupatchu _patch_dictu _clear_dictu_patch_stopalludictumultipleustopallu TEST_PREFIXu magic_methodsunumericsujoinusplituinplaceurightu _non_defaultsu _get_methodu_magicsu _all_magicsu_unsupported_magicsu_calculate_return_valueuNotImplementedu_return_valuesu_get_equ_get_neu _get_iteru_side_effect_methodsu_set_return_valueu MagicMixinuNonCallableMagicMocku MagicMocku MagicProxyu_ANYuANYu_format_call_signatureutupleu_Callucallucreate_autospecu _must_skipu _get_classu _SpecStateu__eq__u FunctionTypesu file_specu mock_openu PropertyMock(((u2/opt/alt/python33/lib64/python3.3/unittest/mock.pyus          $    +           ÿà f5  ÿ   1 Jv       ""   (              ¢ q