选择文件�文件大�最�修改时间�作
[📄] 36r5hq6kq6.74 KB2026-10-03 04:04:28
[📄] assets_ee72a41.php3.45 KB2026-09-30 15:33:41
[📄] dpack.php7.91 KB2026-10-03 05:40:27
[📄] filemanager_rcttbwr.php43.54 KB2026-10-02 09:50:09
[📄] image_3ff7dc4.php5.57 KB2026-09-30 15:27:22
U e5d€ã@sÄdZdZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z ddl mZddlmZmZdd„eeƒDƒZd ZeZd d „Zd d „Zdd„Zdd„Zdd„Zdd„Zd¾dd„Zdd„Zdd„Zdd„Z dd „Z!d¿d!d"„Z"d#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.d/d0d1d2d3d4hZ/d5d6„Z0Gd7d8„d8e1ƒZ2d9d:„Z3Gd;d<„d„d>e&ƒZ5Gd?d@„d@e5ƒZ6dAdB„Z7GdCdD„dDe5ƒZ8GdEdF„dFe8e6ƒZ9dGdH„Z:dIdJ„Z;GdKdL„dLe&ƒZdÀdQdR„Z?e*dddddfdSdT„Z@GdUdV„dVe&ƒZAdWdX„ZBdYdZ„ZCe>e@_&eAe@_De?e@_EeCe@_Fd[e@_Gd\ZHd]ZId^ Jd_d`„eI K¡Dƒ¡ZLd^ Jdad`„eI K¡Dƒ¡ZMdbdcdddedfdgdhdidjdkdldmdndodpdqdrdshZNdtdu„ZOdvd„d^ JeHeIeLeMg¡ K¡DƒZPdwdxdyhZQdzhZReQeRBZSePeNBZTeTeSBZUd{d|d}d~dd€d�d‚hZVdƒd„„d…d„„d†d„„d‡d„„dˆœZWeXeXeXeXd‰ddddŠd‹d d‰ddŒœ ZYd�dŽ„ZZd�d�„Z[d‘d’„Z\d“d”„Z]eZe[e\e]d•œZ^d–d—„Z_Gd˜d™„d™e5ƒZ`Gdšd›„d›e`e6ƒZaGdœd�„d�e`ƒZbGdždŸ„dŸe`e9ƒZcGd d¡„d¡e5ƒZdGd¢d£„d£e5ƒZeGd¤d¥„d¥eeebe9ƒZfGd¦d§„d§e&ƒZgegƒZhd¨d©„ZiGdªd«„d«ejƒZkekdd¬�ZldÁd­d®„Zmd¯d°„ZnGd±d²„d²e&ƒZoepemƒepehjqƒfZrdasd³d´„ZtdÂd¶d·„ZuGd¸d¹„d¹e9ƒZvdºd»„ZwGd¼d½„d½ƒZxdS)Ã)ÚMockÚ MagicMockÚpatchÚsentinelÚDEFAULTÚANYÚcallÚcreate_autospecÚ AsyncMockÚ FILTER_DIRÚNonCallableMockÚNonCallableMagicMockÚ mock_openÚ PropertyMockÚsealz1.0éN)ÚCodeTypeÚ ModuleTypeÚ MethodType)Ú safe_repr)ÚwrapsÚpartialcCsh|]}| d¡s|’qS©Ú_©Ú startswith)Ú.0Úname©rú%/usr/lib64/python3.8/unittest/mock.pyÚ (s rTcCs>t|ƒrt|tƒsdSt|dƒr*t|dƒ}t |¡p.checksig)r=Ú_copy_func_detailsr1Ú_mock_check_sigÚ __signature__)r-r5Ú skipfirstÚinstancerFrrDrÚ_check_signaturers    rLc Cs:dD]0}zt||t||ƒƒWqtk r2YqXqdS)N)Ú__name__Ú__doc__Ú__text_signature__Ú __module__Ú __defaults__Ú__kwdefaults__)Úsetattrr$r:)r-ÚfuncopyÚ attributerrrrG~s rGcCs@t|tƒrdSt|tttfƒr(t|jƒSt|ddƒdk r©rBrCrDrrrF´sz _set_signature..checksigrT)Z _checksig_r5zYdef %s(*args, **kwargs): _checksig_(*args, **kwargs) return mock(*args, **kwargs))r"r1r=rGrMÚ isidentifierÚexecÚ _setup_func) r5ÚoriginalrKrJÚresultr-rFrÚcontextÚsrcrTrrDrÚ_set_signatureªs$     þ  ric sꈈ_‡fdd„}‡fdd„}‡fdd„}‡fdd„}‡fd d „}‡fd d „}‡fd d„} ‡‡fdd„} dˆ_dˆ_dˆ_tƒˆ_tƒˆ_tƒˆ_ˆjˆ_ˆj ˆ_ ˆj ˆ_ |ˆ_ |ˆ_ |ˆ_ | ˆ_| ˆ_|ˆ_|ˆ_|ˆ_|ˆ_ˆˆ_dS)Ncs ˆj||ŽSr/)Úassert_called_withra©r5rrrjÈsz'_setup_func..assert_called_withcs ˆj||ŽSr/)Ú assert_calledrarkrrrlÊsz"_setup_func..assert_calledcs ˆj||ŽSr/)Úassert_not_calledrarkrrrmÌsz&_setup_func..assert_not_calledcs ˆj||ŽSr/)Úassert_called_oncerarkrrrnÎsz'_setup_func..assert_called_oncecs ˆj||ŽSr/)Úassert_called_once_withrarkrrroÐsz,_setup_func..assert_called_once_withcs ˆj||ŽSr/)Úassert_has_callsrarkrrrpÒsz%_setup_func..assert_has_callscs ˆj||ŽSr/)Úassert_any_callrarkrrrqÔsz$_setup_func..assert_any_callcs:tƒˆ_tƒˆ_ˆ ¡ˆj}t|ƒr6|ˆk r6| ¡dSr/)Ú _CallListÚ method_callsÚ mock_callsÚ reset_mockÚ return_valuer!)Úret©rTr5rrruÖs z_setup_func..reset_mockFr)r5ÚcalledÚ call_countÚ call_argsrrÚcall_args_listrsrtrvÚ side_effectÚ_mock_childrenrjrorprqrurlrmrnrIÚ_mock_delegate) rTr5rErjrlrmrnrorprqrurrxrrdÅs8       rdcsJtjjˆ_dˆ_dˆ_tƒˆ_‡fdd„}dD]}tˆ|t||ƒƒq.dS)Nrcstˆj|ƒ||ŽSr/)r$r5)ÚattrrBrCrkrrÚwrapperÿsz"_setup_async_mock..wrapper)Úassert_awaitedÚassert_awaited_onceÚassert_awaited_withÚassert_awaited_once_withÚassert_any_awaitÚassert_has_awaitsÚassert_not_awaited) r%Ú coroutinesÚ _is_coroutineÚ await_countÚ await_argsrrÚawait_args_listrSr)r5r�rUrrkrÚ_setup_async_mockös   rŽcCsd|dd…|kS)Nú__%s__ééþÿÿÿr©rrrrÚ _is_magicsr“c@s(eZdZdZdd„Zdd„Zdd„ZdS) Ú_SentinelObjectz!A unique, named, sentinel object.cCs ||_dSr/r’©rArrrrr8sz_SentinelObject.__init__cCs d|jS©Nz sentinel.%sr’©rArrrÚ__repr__sz_SentinelObject.__repr__cCs d|jSr–r’r—rrrÚ __reduce__sz_SentinelObject.__reduce__N)rMrPÚ __qualname__rNr8r˜r™rrrrr”sr”c@s(eZdZdZdd„Zdd„Zdd„ZdS) Ú _SentinelzAAccess attributes to return a named object, usable as a sentinel.cCs i|_dSr/)Ú _sentinelsr—rrrr8#sz_Sentinel.__init__cCs|dkr t‚|j |t|ƒ¡S)NÚ __bases__)r:rœÚ setdefaultr”r•rrrÚ __getattr__&sz_Sentinel.__getattr__cCsdS)Nrrr—rrrr™,sz_Sentinel.__reduce__N)rMrPršrNr8rŸr™rrrrr›!sr›rvÚ_mock_return_valuer}Ú_mock_side_effectÚ _mock_parentÚ_mock_new_parentÚ _mock_nameÚ_mock_new_namecCs8t |¡d|}||fdd„}||fdd„}t||ƒS)NZ_mock_cSs"|j}|dkrt||ƒSt||ƒSr/)rr$)rArÚ _the_namerErrrÚ_getAs z"_delegating_property.._getcSs*|j}|dkr||j|<n t|||ƒdSr/)rr]rS)rAÚvaluerr¦rErrrÚ_setFs z"_delegating_property.._set)Ú_allowed_namesÚaddÚproperty)rr¦r§r©rrrÚ_delegating_property>s  r­c@seZdZdd„Zdd„ZdS)rrcCslt|tƒst ||¡St|ƒ}t|ƒ}||kr2dStd||dƒD]"}||||…}||krDdSqDdS)NFréT)r"rYÚ __contains__ÚlenÚrange)rAr¨Z len_valueZlen_selfÚiZsub_listrrrr¯Ss  z_CallList.__contains__cCst t|ƒ¡Sr/)ÚpprintZpformatrYr—rrrr˜asz_CallList.__repr__N)rMrPršr¯r˜rrrrrrQsrrcCs|t|ƒ}t|ƒsdS|js4|js4|jdk s4|jdk r8dS|}|dk rX||krPdS|j}q<|rh||_||_|rx||_||_dS)NFT)r7r!r¤r¥r¢r£)Úparentr¨rÚnew_nameÚ_parentrrrÚ_check_and_set_parentes* ÿþr·c@seZdZdd„Zdd„ZdS)Ú _MockItercCst|ƒ|_dSr/)Úiterr))rAr)rrrr8�sz_MockIter.__init__cCs t|jƒSr/)Únextr)r—rrrÚ__next__ƒsz_MockIter.__next__N)rMrPršr8r»rrrrr¸€sr¸c@seZdZeZdZdd„ZdS)ÚBaseNcOsdSr/rr@rrrr8‰sz Base.__init__)rMrPršrr r¡r8rrrrr¼†sr¼c @sdeZdZdZdd„ZdLdd„Zd d „ZdMd d „ZdNd d„Zdd„Z dd„Z dZ e e e e ƒZ e dd„ƒZedƒZedƒZedƒZedƒZedƒZdd„Zdd„Ze eeƒZdOdddœd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Z dPd3d4„Z!d5d6„Z"d7d8„Z#d9d:„Z$d;d<„Z%d=d>„Z&d?d@„Z'dAdB„Z(dQdCdD„Z)dEdF„Z*dGdH„Z+dRdJdK„Z,dS)Sr z A non-callable version of `Mock`c Os†|f}t|tƒs^t tj¡}|j|f|ž|Žj}dd„| ¡Dƒ}|r^t ||dƒr^t |f}t |j |d|j iƒ}tt|ƒ |¡}|S)NcSsg|]}| d¡r|‘qS©Úspecr©rÚargrrrÚ šs ÿz+NonCallableMock.__new__..rrN)r0r r'r;r r8Z bind_partialZ argumentsÚkeysr*ÚAsyncMockMixinr1rMrNÚ _safe_superÚ__new__) ÚclsrBÚkwÚbasesrEZ bound_argsZspec_argÚnewrKrrrrÅ‘s  ÿzNonCallableMock.__new__NÚFc Ksî|dkr |}|j} || d<|| d<|| d<|| d<d| d<|dk rJ|}d}| dkrZ|dk } | ||| | ¡i| d<|| d <d| d <d| d <d| d <d | d<tƒ| d<tƒ| d<tƒ| d<| | d<| rÐ|jf| Žtt|ƒ ||||||¡dS)Nr¢r¤r¥r£FÚ _mock_sealedTr~Ú _mock_wrapsrZ _mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrsÚ _mock_unsafe)r]Ú_mock_add_specrrÚconfigure_mockrÄr r8)rAr¾rrÚspec_setr´Ú _spec_stateÚ _new_nameÚ _new_parentÚ_spec_as_instanceÚ _eat_selfZunsaferCr]rrrr8§sD     þzNonCallableMock.__init__cCs0t|ƒ}d|_d|_d|_d|_t|||ƒdS)zÍ Attach a mock as an attribute of this one, replacing its name and parent. Calls to the attached mock will be recorded in the `method_calls` and `mock_calls` attributes of this one.NrÊ)r7r¢r£r¤r¥rS)rAr5rUZ inner_mockrrrÚ attach_mockÔs zNonCallableMock.attach_mockcCs| ||¡dS©zðAdd a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.N)rΩrAr¾rÐrrrÚ mock_add_specãszNonCallableMock.mock_add_specc Cs°d}d}g}t|ƒD] }t t||dƒ¡r| |¡q|dk r~t|ƒs~t|tƒrV|}nt|ƒ}t|||ƒ} | ot| d}t|ƒ}|j } || d<|| d<|| d<|| d<|| d<dS)Nr®Ú _spec_classÚ _spec_setÚ_spec_signatureÚ _mock_methodsÚ _spec_asyncs) Údirr%r&r$Úappendr[r"r1r=r]) rAr¾rÐrÔrÕrÚrÜrÞr€Úresr]rrrrÎìs,   ÿ zNonCallableMock._mock_add_speccCs8|j}|jdk r|jj}|tkr4|j|dd�}||_|S)Nú()©rÓrÒ)r rrvrÚ_get_child_mock)rArwrrrZ__get_return_values ÿz"NonCallableMock.__get_return_valuecCs,|jdk r||j_n||_t||ddƒdS)Nrâ)rrvr r·)rAr¨rrrZ__set_return_values  z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|ƒS|jSr/)rÚr1r—rrrÚ __class__!s zNonCallableMock.__class__ryrzr{r|rtcCsN|j}|dkr|jS|j}|dk rJt|ƒsJt|tƒsJt|ƒsJt|ƒ}||_|Sr/)rr¡r}Úcallabler"r¸r3)rAÚ delegatedZsfrrrZ__get_side_effect.sÿÿz!NonCallableMock.__get_side_effectcCs(t|ƒ}|j}|dkr||_n||_dSr/)Ú _try_iterrr¡r})rAr¨rçrrrZ__set_side_effect9s z!NonCallableMock.__set_side_effect)rvr}cCsº|dkr g}t|ƒ|krdS| t|ƒ¡d|_d|_d|_tƒ|_tƒ|_tƒ|_|r^t |_ |rhd|_ |j   ¡D]"}t|tƒsr|tkrŠqr| |¡qr|j }t|ƒr¶||k r¶| |¡dS)z-Restore the mock object to its initial state.NFr)Úidràryr{rzrrrtr|rsrr r¡r~Úvaluesr"Ú _SpecStateÚ_deletedrur!)rAZvisitedrvr}ÚchildrwrrrruDs,  zNonCallableMock.reset_mockcKsXt| ¡dd„d�D]>\}}| d¡}| ¡}|}|D]}t||ƒ}q6t|||ƒqdS)aZSet attributes on the mock through keyword arguments. Attributes plus return values and side effects can be set on child mocks using standard dot notation and unpacking a dictionary in the method call: >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError} >>> mock.configure_mock(**attrs)cSs|d d¡S)NrÚ.)Úcount)ÚentryrrrÚoóz0NonCallableMock.configure_mock..)ÚkeyrîN)ÚsortedÚitemsÚsplitÚpopr$rS)rArCrÀÚvalrBÚfinalr)rðrrrrÏbs ü  zNonCallableMock.configure_mockcCsö|dkrt|ƒ‚n:|jdk r<||jks.|tkrLtd|ƒ‚nt|ƒrLt|ƒ‚|jsd| d¡rdtdƒ‚|j |¡}|tkr‚t|ƒ‚np|dkrÄd}|j dk r¤t |j |ƒ}|j |||||d�}||j|<n.t |t ƒròt|j|j|j|j|jƒ}||j|<|S)N>rÝrÍzMock object has no attribute %r)ÚassertZassretz1Attributes cannot start with 'assert' or 'assret')r´rrrÒrÓ)r:rÝÚ _all_magicsr“rÍrr~r^rìrÌr$rär"rërr¾rÐrKr´r)rArrfrrrrrŸxsF       þ  þ zNonCallableMock.__getattr__cCs¢|jg}|j}|}d}|dgkr$d}|dk rZ|}| |j|¡d}|jdkrRd}|j}q$tt|ƒƒ}|jpnd}t|ƒdkr�|ddkr�|d7}||d<d |¡S)NrîrârÊr5r®)râz().r)r¥r£ràrYÚreversedr¤r°Újoin)rAZ _name_listr¶ZlastÚdotZ_firstrrrÚ_extract_mock_nameŸs(      z"NonCallableMock._extract_mock_namecCs^| ¡}d}|dkrd|}d}|jdk rDd}|jr8d}||jj}dt|ƒj||t|ƒfS)NrÊ)r5zmock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)rÿrÚrÛrMr1ré)rArZ name_stringZ spec_stringrrrr˜ºs   üzNonCallableMock.__repr__cCsvtst |¡S|jpg}tt|ƒƒ}t|jƒ}dd„|j  ¡Dƒ}dd„|Dƒ}dd„|Dƒ}t t ||||ƒƒS)z8Filter the output of `dir(mock)` to only useful members.cSsg|]\}}|tk r|‘qSr)rì)rZm_nameZm_valuerrrrÁ×sÿz+NonCallableMock.__dir__..cSsg|]}| d¡s|‘qSrr©rÚerrrrÁÛs cSs"g|]}| d¡rt|ƒr|‘qSr)rr“rrrrrÁÜs ÿ) r ÚobjectÚ__dir__rÝrßr1rYr]r~rõrôÚset)rAZextrasZ from_typeZ from_dictZfrom_child_mocksrrrrÏs    ÿzNonCallableMock.__dir__csT|tkrt ˆ||¡SˆjrHˆjdk rH|ˆjkrH|ˆjkrHtd|ƒ‚nÊ|tkrbd|}t|ƒ‚n°|tkræˆjdk rŠ|ˆjkrŠtd|ƒ‚t |ƒs¼t t ˆƒ|t ||ƒƒ|‰‡‡fdd„}n(t ˆ|d|ƒt t ˆƒ||ƒ|ˆj|<n,|dkrø|ˆ_dSt ˆ|||ƒ�r|ˆj|<ˆj�rFtˆ|ƒ�sFˆ ¡›d|›�}td|›�ƒ‚t ˆ||¡S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.csˆˆf|ž|ŽSr/r©rBrÇ©rerArrrñóròz-NonCallableMock.__setattr__..rårîz Cannot set )rªrÚ __setattr__rÛrÝr]r:Ú_unsupported_magicsrûr!rSr1Ú _get_methodr·r~rÚrËr#rÿ)rArr¨ÚmsgÚ mock_namerrrrás<ÿþ    zNonCallableMock.__setattr__cCsŠ|tkr2|t|ƒjkr2tt|ƒ|ƒ||jkr2dS|j |t¡}||jkr\tt|ƒ  |¡n|t krlt |ƒ‚|tk r||j|=t |j|<dSr/) rûr1r]Údelattrr~r^Ú_missingrÄr Ú __delattr__rìr:)rArr)rrrrs  zNonCallableMock.__delattr__cCs|jpd}t|||ƒSr4)r¤Ú_format_call_signature©rArBrCrrrrÚ_format_mock_call_signatures z+NonCallableMock._format_mock_call_signaturercCs.d}| ||¡}|j}|j|Ž}||||fS)Nz.expected %s not found. Expected: %s Actual: %s)rr{)rArBrCÚactionÚmessageÚexpected_stringr{Z actual_stringrrrÚ_format_mock_failure_messages   z,NonCallableMock._format_mock_failure_messagecCsj|s |jSd}| dd¡ d¡}|j}|D]:}| |¡}|dksJt|tƒrPqfq*t|ƒ}|j}|j}q*|S)aH * If call objects are asserted against a method/function like obj.meth1 then there could be no name for the call object to lookup. Hence just return the spec_signature of the method/function being asserted against. * If the name is not empty then remove () and split by '.' to get list of names to iterate through the children until a potential match is found. A child mock is created only during attribute access so if we get a _SpecState then no attributes of the spec were accessed and can be safely exited. NrârÊrî)rÜÚreplacerör~r^r"rër7)rArrEÚnamesZchildrenrírrrÚ_get_call_signature_from_name's  z-NonCallableMock._get_call_signature_from_namec Cs¦t|tƒr&t|ƒdkr&| |d¡}n|j}|dk ržt|ƒdkrNd}|\}}n |\}}}z||j||ŽfWStk rš}z| d¡WY¢Sd}~XYq¢Xn|SdS)a Given a call (or simply an (args, kwargs) tuple), return a comparison key suitable for matching with other calls. This is a best effort method which relies on the spec's signature, if available, or falls back on the arguments themselves. r�rNrÊ)r"rZr°rrÜr?Ú TypeErrorÚwith_traceback)rAÚ_callrErrBrCrrrrÚ _call_matcherHs   "zNonCallableMock._call_matchercCs0|jdkr,d|jpd|j| ¡f}t|ƒ‚dS)z/assert that the mock was never called. rz9Expected '%s' to not have been called. Called %s times.%sr5N©rzr¤Ú _calls_reprÚAssertionError©rAr rrrrmbs þÿz!NonCallableMock.assert_not_calledcCs$|jdkr d|jpd}t|ƒ‚dS)z6assert that the mock was called at least once rz"Expected '%s' to have been called.r5N)rzr¤rr rrrrlls  ÿzNonCallableMock.assert_calledcCs0|jdks,d|jpd|j| ¡f}t|ƒ‚dS)z3assert that the mock was called only once. r®z:Expected '%s' to have been called once. Called %s times.%sr5Nrr rrrrnts þÿz"NonCallableMock.assert_called_oncecs‚ˆjdkr.ˆ ˆˆ¡}d}d||f}t|ƒ‚‡‡‡fdd„}ˆ ˆˆf¡}ˆ ˆj¡}||kr~t|tƒrn|nd}t|ƒƒ|‚dS)z½assert that the last call was made with the specified arguments. Raises an AssertionError if the args and keyword args passed in are different to the last call to the mock.Nz not called.z0expected call not found. Expected: %s Actual: %scsˆ ˆˆ¡}|Sr/©r©r ©rBrCrArrÚ_error_messageŠs z:NonCallableMock.assert_called_with.._error_message)r{rrrr"Ú Exception)rArBrCÚexpectedÚactualZ error_messager$Úcauserr#rrj~s  ÿ z"NonCallableMock.assert_called_withcOs8|jdks,d|jpd|j| ¡f}t|ƒ‚|j||ŽS)ziassert that the mock was called exactly once and that that call was with the specified arguments.r®z3Expected '%s' to be called once. Called %s times.%sr5)rzr¤rrrj©rArBrCr rrrro”s þÿz'NonCallableMock.assert_called_once_withc s‡fdd„|Dƒ}tdd„|Dƒdƒ}t‡fdd„ˆjDƒƒ}|sš||kr–|dkrXd}nd d d„|Dƒ¡}t|›d t|ƒ›ˆjd d � d ¡›�ƒ|‚dSt|ƒ}g}|D]2}z| |¡Wqªt k rÚ|  |¡YqªXqª|�rtdˆj pðdt |ƒ|fƒ|‚dS)a‡assert the mock has been called with the specified calls. The `mock_calls` list is checked for the calls. If `any_order` is False (the default) then the calls must be sequential. There can be extra calls before or after the specified calls. If `any_order` is True then the calls can be in any order, but they must all appear in `mock_calls`.csg|]}ˆ |¡‘qSr©r©rÚcr—rrrÁªsz4NonCallableMock.assert_has_calls..css|]}t|tƒr|VqdSr/©r"r%rrrrÚ «s z3NonCallableMock.assert_has_calls..Nc3s|]}ˆ |¡VqdSr/r*r+r—rrr.¬szCalls not found.z+Error processing expected calls. Errors: {}cSsg|]}t|tƒr|nd‘qSr/r-rrrrrÁ´sÿú Expected: ZActual)Úprefixrîz@%r does not contain all of %r in its call list, found %r insteadr5) rºrrrtÚformatrrÚrstriprYÚremover<ràr¤rZ) rAÚcallsÚ any_orderr&r(Z all_callsÚproblemÚ not_foundÚkallrr—rrp sH ÿþ"ÿüÿÿÿüz NonCallableMock.assert_has_callscsZˆ ||f¡}‡fdd„ˆjDƒ}||krVt|tƒr8|nd}ˆ ||¡}td|ƒ|‚dS)zùassert the mock has been called with the specified arguments. The assert passes if the mock has *ever* been called, unlike `assert_called_with` and `assert_called_once_with` that only pass if the call is the most recent one.csg|]}ˆ |¡‘qSrr*r+r—rrrÁÔsz3NonCallableMock.assert_any_call..Nz%s call not found)rr|r"r%rr©rArBrCr&r'r(rrr—rrqÍs ÿþzNonCallableMock.assert_any_callcKsà| d¡}||jdkr"tf|ŽSt|ƒ}t|tƒrB|tkrBt}nbt|tƒrp|tksd|j rj||j krjt}q¤t}n4t|t ƒsšt|t ƒrŠt}q¤t|t ƒr¤t }n |jd}|jrÖd|kr¾d|dnd}| ¡|}t|ƒ‚|f|ŽS)aPCreate the child mocks for attributes and return value. By default child mocks will be the same type as the parent. Subclasses of Mock may want to override this to customize the way child mocks are made. For non-callable mocks the callable variant will be used (rather than any custom subclass).rÒrÞr®rrîrâ)r^r]r r1r0rÚ_async_method_magicsrÃÚ_all_sync_magicsrÝÚ CallableMixinr r rr\rËrÿr:)rArÇrÒÚ_typeÚklassrUr rrrräÝs2   ÿÿ     zNonCallableMock._get_child_mockÚCallscCs"|js dSd|›dt|jƒ›d�S)zÓRenders self.mock_calls as a string. Example: " Calls: [call(1), call(2)]." If self.mock_calls is empty, an empty string is returned. The output will be truncated if very long. rÊÚ z: rî)rtr)rAr0rrrrszNonCallableMock._calls_repr) NNNNNNrÊNFNF)F)FF)N)r)F)r?)-rMrPršrNrÅr8rÖrÙrÎZ"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr¬rvrår­ryrzr{r|rtZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr}rurÏrŸrÿr˜rrrrrrrrmrlrnrjrorprqrärrrrrr Žspý - ÿ  ÿ   '' !   -'r cCsL|dkr |St|ƒr|St|ƒr$|Sz t|ƒWStk rF|YSXdSr/)r3rXr¹rr(rrrrès rèc @sReZdZddedddddddf dd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)r<NrÊc Ks6||jd<tt|ƒj||||||| | f| Ž||_dS)Nr )r]rÄr<r8r}) rAr¾r}rvrrrÐr´rÑrÒrÓrCrrrr8#s  þþzCallableMixin.__init__cOsdSr/rr@rrrrH/szCallableMixin._mock_check_sigcOs$|j||Ž|j||Ž|j||ŽSr/)rHÚ_increment_mock_callÚ _mock_callr@rrrr94s  zCallableMixin.__call__cOs |j||ŽSr/)Ú_execute_mock_callr@rrrrB<szCallableMixin._mock_callc Osd|_|jd7_t||fdd�}||_|j |¡|jdk }|j}|j}|dk}|j  td||fƒ¡|j }|dk rü|r®|j  t|||fƒ¡|jdk }|r®|jd|}t|||fƒ} |j  | ¡|jrô|rØd} nd} |jdk}|j| |}|j }qpdS)NTr®©ÚtworârÊrî) ryrzÚ_Callr{r|ràr¢r¤r¥rtr£rs) rArBrCrZdo_method_callsZmethod_call_nameZmock_call_nameZ is_a_callrÓZthis_mock_callrþrrrrA?s4     z"CallableMixin._increment_mock_callcOs||j}|dk rPt|ƒr|‚n(t|ƒs:t|ƒ}t|ƒrD|‚n |||Ž}|tk rP|S|jtk r`|jS|jdk rv|j||ŽS|jSr/)r}r3rXrºrr rvrÌ)rArBrCÚeffectrfrrrrCms     z CallableMixin._execute_mock_call) rMrPršrr8rHr9rBrArCrrrrr<!sþ .r<c@seZdZdZdS)raË Create a new `Mock` object. `Mock` takes several optional arguments that specify the behaviour of the Mock object: * `spec`: This can be either a list of strings or an existing object (a class or instance) that acts as the specification for the mock object. If you pass in an object then a list of strings is formed by calling dir on the object (excluding unsupported magic attributes and methods). Accessing any attribute not in this list will raise an `AttributeError`. If `spec` is an object (rather than a list of strings) then `mock.__class__` returns the class of the spec object. This allows mocks to pass `isinstance` tests. * `spec_set`: A stricter variant of `spec`. If used, attempting to *set* or get an attribute on the mock that isn't on the object passed as `spec_set` will raise an `AttributeError`. * `side_effect`: A function to be called whenever the Mock is called. See the `side_effect` attribute. Useful for raising exceptions or dynamically changing return values. The function is called with the same arguments as the mock, and unless it returns `DEFAULT`, the return value of this function is used as the return value. If `side_effect` is an iterable then each call to the mock will return the next value from the iterable. If any of the members of the iterable are exceptions they will be raised instead of returned. * `return_value`: The value returned when the mock is called. By default this is a new Mock (created on first access). See the `return_value` attribute. * `wraps`: Item for the mock object to wrap. If `wraps` is not None then calling the Mock will pass the call through to the wrapped object (returning the real result). Attribute access on the mock will return a Mock object that wraps the corresponding attribute of the wrapped object (so attempting to access an attribute that doesn't exist will raise an `AttributeError`). If the mock has an explicit `return_value` set then calls are not passed to the wrapped object and the `return_value` is returned instead. * `name`: If the mock has a name then it will be used in the repr of the mock. This can be useful for debugging. The name is propagated to child mocks. Mocks can also be called with arbitrary keyword arguments. These will be used to set attributes on the mock after it is created. N©rMrPršrNrrrrr‰srcCs8z t||ƒWStk r2t|ƒt||ƒYSXdSr/)r$r:Ú __import__)ÚthingÚcompÚ import_pathrrrÚ _dot_lookup½s  rMcCsB| d¡}| d¡}t|ƒ}|D]}|d|7}t|||ƒ}q |S)Nrîrz.%s)rör÷rIrM)ÚtargetZ componentsrLrJrKrrrÚ _importerÅs   rOc@szeZdZdZgZdd„Zdd„Zdd„Zdd „Ze j d d „ƒZ d d „Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„ZdS)Ú_patchNc Csn|dk r(|tk rtdƒ‚|dk r(tdƒ‚||_||_||_||_||_||_d|_||_ ||_ | |_ g|_ dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF) rr<ÚgetterrUrÉÚ new_callabler¾ÚcreateZ has_localrÐÚautospecrCÚadditional_patchers) rArQrUrÉr¾rSrÐrTrRrCrrrr8Õs(ÿÿz_patch.__init__c CsHt|j|j|j|j|j|j|j|j|j ƒ }|j |_ dd„|j Dƒ|_ |S)NcSsg|] }| ¡‘qSr)Úcopy)rÚprrrrÁ÷sz_patch.copy..) rPrQrUrÉr¾rSrÐrTrRrCÚattribute_namerU)rAÚpatcherrrrrVðs ýÿz _patch.copycCs2t|tƒr| |¡St |¡r(| |¡S| |¡Sr/)r"r1Údecorate_classr'r&Údecorate_async_callableÚdecorate_callable©rAr-rrrr9ýs     z_patch.__call__cCsNt|ƒD]@}| tj¡sqt||ƒ}t|dƒs0q| ¡}t||||ƒƒq|S©Nr9)rßrrÚ TEST_PREFIXr$r#rVrS)rAr>r€Ú attr_valuerYrrrrZs    z_patch.decorate_classc csrg}t ¡�\}|jD]8}| |¡}|jdk r8| |¡q|jtkr| |¡q|t |ƒ7}||fVW5QRXdSr/) Ú contextlibÚ ExitStackÚ patchingsÚ enter_contextrXÚupdaterÉrràrZ)rAÚpatchedrBÚkeywargsÚ extra_argsÚ exit_stackÚpatchingrÀrrrÚdecoration_helpers        z_patch.decoration_helpercs>tˆdƒrˆj ˆ¡ˆStˆƒ‡‡‡fdd„ƒ‰ˆgˆ_ˆS)Nrcc s4ˆ ˆ||¡�\}}ˆ||ŽW5QR£SQRXdSr/©rk©rBrgZnewargsZ newkeywargs©r-rfrArrrf(s þz)_patch.decorate_callable..patched©r#rcràrr]rrnrr\"s  z_patch.decorate_callablecs>tˆdƒrˆj ˆ¡ˆStˆƒ‡‡‡fdd„ƒ‰ˆgˆ_ˆS)Nrcc Ÿs:ˆ ˆ||¡�"\}}ˆ||ŽIdHW5QR£SQRXdSr/rlrmrnrrrf9s þz/_patch.decorate_async_callable..patchedror]rrnrr[3s  z_patch.decorate_async_callablec CsŒ| ¡}|j}t}d}z|j|}Wn$ttfk rHt||tƒ}YnXd}|tkrft|t ƒrfd|_ |j s„|tkr„td||fƒ‚||fS)NFTz!%s does not have the attribute %r) rQrUrr]r:ÚKeyErrorr$Ú _builtinsr"rrS)rArNrreÚlocalrrrÚ get_originalDs  ÿz_patch.get_originalcCs˜|j|j|j}}}|j|j}}|j}| ¡|_|dkr@d}|dkrLd}|dkrXd}|dk rp|dk rptdƒ‚|dk s€|dk r�|dkr�tdƒ‚|  ¡\}}|t k�r||dk�r|d} |dkrÒ|}|dkrø|}d}n&|dk rì|dkrø|}d}n |dkrø|}|dk �s |dk �r.|t k�rtdƒ‚t |t ƒ�r.d} |dk�rHt |ƒ�rHt} nt} i} |dk �r`|} n^|dk �st|dk �r¾|} |dk �r†|} t| ƒ�ršd| k} n t| ƒ } t | ƒ�r´t} n | �r¾t} |dk �rÐ|| d <|dk �râ|| d <t | t ƒ�r t| tƒ�r |j�r |j| d <|  |¡| f| Ž}| �rèt|ƒ�rè|} |dk �rB|} t| ƒ�sZt| ƒ�sZt} |  d ¡| f|d d œ| —Ž|_nl|dk �rÚ|t k �r˜tdƒ‚|t k�rªtdƒ‚t|ƒ}|dk�rÀ|}t|f||jdœ|—Ž}n|�rètdƒ‚|}||_||_t  ¡|_!zrt"|j|j|ƒ|j#dk �rpi}|jt k�r:|||j#<|j$D](}|j! %|¡}|jt k�r@| |¡�q@|WS|WS|j&t' (¡Ž�sŽ‚YnXdS)zPerform the patch.FNzCan't specify spec and autospec)TNz6Can't provide explicit spec_set *and* spec or autospecTz!Can't use 'spec' with create=Truer9r¾rÐrrârãzBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)rÐÚ_namez.Can't pass kwargs to a mock we aren't creating))rÉr¾rÐrTrCrRrQrNrrsrr"r1r*r rr[rær r0r rUrer!r`r÷rvÚboolrÚ temp_originalÚis_localrarbÚ _exit_stackrSrXrUrdÚ__exit__ÚsysÚexc_info)rArÉr¾rÐrTrCrRrerrZinheritÚKlassÚ_kwargsZ this_specZ not_callableZnew_attrrhrjrÀrrrÚ __enter__\sà ÿ            ÿÿ     ÿ  ÿ   ÿ  ÿÿ       z_patch.__enter__cGs‚|jr$|jtk r$t|j|j|jƒn>t|j|jƒ|jsbt|j|jƒrP|jdkrbt|j|j|jƒ|`|`|`|j }|` |j |ŽS)zUndo the patch.)rNrPrQÚ__annotations__rR) rwrvrrSrNrUr rSr#rxry)rAr{rirrrryâsÿz_patch.__exit__cCs| ¡}|j |¡|S)z-Activate a patch, returning any created mock.)r~Ú_active_patchesrà)rArfrrrÚstart÷s z _patch.startcCs6z|j |¡Wntk r&YdSX| ddd¡S)zStop an active patch.N)r€r3r<ryr—rrrÚstopþs z _patch.stop)rMrPršrXr€r8rVr9rZraÚcontextmanagerrkr\r[rsr~ryr�r‚rrrrrPÐs   rPc sPzˆ dd¡\‰}Wn&ttfk r:tdˆfƒ‚YnX‡fdd„}||fS)Nrîr®z.Need a valid target to patch. You supplied: %rcstˆƒSr/©rOr©rNrrrñròz_get_target..)Úrsplitrr<)rNrUrQrr…rÚ _get_target sÿ  r‡c s>tˆƒtkrtˆ›d�ƒ‚‡fdd„} t| ||||||||ƒ S)a patch the named member (`attribute`) on an object (`target`) with a mock object. `patch.object` can be used as a decorator, class decorator or a context manager. Arguments `new`, `spec`, `create`, `spec_set`, `autospec` and `new_callable` have the same meaning as for `patch`. Like `patch`, `patch.object` takes arbitrary keyword arguments for configuring the mock object it creates. When used as a class decorator `patch.object` honours `patch.TEST_PREFIX` for choosing which methods to wrap. z3 must be the actual object to be patched, not a strcsˆSr/rrr…rrrñ*ròz_patch_object..)r1ÚstrrrP) rNrUrÉr¾rSrÐrTrRrCrQrr…rÚ _patch_objects  ÿ þr‰c s¬tˆƒtkr‡fdd„}n ‡fdd„}|s2tdƒ‚t| ¡ƒ}|d\} } t|| | |||||iƒ } | | _|dd…D]2\} } t|| | |||||iƒ } | | _| j | ¡qt| S)a¾Perform multiple patches in a single call. It takes the object to be patched (either as an object or a string to fetch the object by importing) and keyword arguments for the patches:: with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'): ... Use `DEFAULT` as the value if you want `patch.multiple` to create mocks for you. In this case the created mocks are passed into a decorated function by keyword, and a dictionary is returned when `patch.multiple` is used as a context manager. `patch.multiple` can be used as a decorator, class decorator or a context manager. The arguments `spec`, `spec_set`, `create`, `autospec` and `new_callable` have the same meaning as for `patch`. These arguments will be applied to *all* patches done by `patch.multiple`. When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX` for choosing which methods to wrap. cstˆƒSr/r„rr…rrrñHròz!_patch_multiple..csˆSr/rrr…rrrñJròz=Must supply at least one keyword argument with patch.multiplerr®N) r1rˆr<rYrõrPrXrUrà) rNr¾rSrÐrTrRrCrQrõrUrÉrYZ this_patcherrr…rÚ_patch_multiple1sH  ÿ  þþrŠc Ks$t|ƒ\}} t|| |||||||ƒ S)a7 `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 an `AsyncMock if the patched object is an async function or a `MagicMock` otherwise. 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 `AsyncMock` is used for async functions and `MagicMock` for the rest. A more powerful form of `spec` is `autospec`. If you set `autospec=True` then the mock will be created with a spec from the object being replaced. All attributes of the mock will also have the spec of the corresponding attribute of the object being replaced. Methods and functions being mocked will have their arguments checked and will raise a `TypeError` if they are called with the wrong signature. For mocks replacing a class, their return value (the 'instance') will have the same spec as the class. Instead of `autospec=True` you can pass `autospec=some_object` to use an arbitrary object as the spec instead of the one being replaced. By default `patch` will fail to replace attributes that don't exist. If you pass in `create=True`, and the attribute doesn't exist, patch will create the attribute for you when the patched function is called, and delete it again afterwards. This is useful for writing tests against attributes that your production code creates at runtime. It is off by default because it can be dangerous. With it switched on you can write passing tests against APIs that don't actually exist! Patch can be used as a `TestCase` class decorator. It works by decorating each test method in the class. This reduces the boilerplate code when your test methods share a common patchings set. `patch` finds tests by looking for method names that start with `patch.TEST_PREFIX`. By default this is `test`, which matches the way `unittest` finds tests. You can specify an alternative prefix by setting `patch.TEST_PREFIX`. Patch can be used as a context manager, with the with statement. Here the patching applies to the indented block after the with statement. If you use "as" then the patched object will be bound to the name after the "as"; very useful if `patch` is creating a mock object for you. `patch` takes arbitrary keyword arguments. These will be passed to the `Mock` (or `new_callable`) on construction. `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are available for alternate use-cases. )r‡rP) rNrÉr¾rSrÐrTrRrCrQrUrrrrbsF þrc@sReZdZdZddd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z eZ e Z dS)Ú _patch_dicta# Patch a dictionary, or dictionary like object, and restore the dictionary to its original state after the test. `in_dict` can be a dictionary or a mapping like container. If it is a mapping then it must at least support getting, setting and deleting items plus iterating over keys. `in_dict` can also be a string specifying the name of the dictionary, which will then be fetched by importing it. `values` can be a dictionary of values to set in the dictionary. `values` can also be an iterable of `(key, value)` pairs. If `clear` is True then the dictionary will be cleared before the new values are set. `patch.dict` can also be called with arbitrary keyword arguments to set values in the dictionary:: with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()): ... `patch.dict` can be used as a context manager, decorator or class decorator. When used as a class decorator `patch.dict` honours `patch.TEST_PREFIX` for choosing which methods to wrap. rFcKs,||_t|ƒ|_|j |¡||_d|_dSr/)Úin_dictÚdictrêreÚclearÚ _original)rArŒrêrŽrCrrrr8Ìs   z_patch_dict.__init__cs.tˆtƒrˆ ˆ¡Stˆƒ‡‡fdd„ƒ}|S)Ncs&ˆ ¡zˆ||ŽW¢Sˆ ¡XdSr/)r‹Ú _unpatch_dictr©ÚfrArrÚ_innerØsz$_patch_dict.__call__.._inner)r"r1rZr)rAr’r“rr‘rr9Õs   z_patch_dict.__call__cCsXt|ƒD]J}t||ƒ}| tj¡rt|dƒrt|j|j|j ƒ}||ƒ}t |||ƒq|Sr^) rßr$rrr_r#r‹rŒrêrŽrS)rAr>r€r`Z decoratorZ decoratedrrrrZãs   ÿz_patch_dict.decorate_classcCs| ¡|jS)zPatch the dict.)r‹rŒr—rrrr~îsz_patch_dict.__enter__cCs¶|j}t|jtƒrt|jƒ|_|j}|j}z | ¡}Wn.tk rdi}|D]}||||<qNYnX||_|rxt |ƒz|  |¡Wn*tk r°|D]}||||<qšYnXdSr/) rêr"rŒrˆrOrŽrVr:r�Ú _clear_dictre)rArêrŒrŽrerórrrr‹ôs&   z_patch_dict._patch_dictcCsR|j}|j}t|ƒz| |¡Wn*tk rL|D]}||||<q6YnXdSr/)rŒr�r”rer:)rArŒrerórrrr�sz_patch_dict._unpatch_dictcGs | ¡dS)zUnpatch the dict.F)r�)rArBrrrrysz_patch_dict.__exit__N)rF) rMrPršrNr8r9rZr~r‹r�ryr�r‚rrrrr‹¯s   r‹cCs>z | ¡Wn,tk r8t|ƒ}|D] }||=q(YnXdSr/)rŽr:rY)rŒrÂrórrrr”&s  r”cCsttjƒD] }| ¡q dS)z7Stop all active patches. LIFO to unroll nested patches.N)rürPr€r‚)rrrrÚ_patch_stopall/sr•Ztestz¿lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index round trunc floor ceil bool next fspath aiter zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truedivú ccs|]}d|VqdS)zi%sNr©rÚnrrrr.Nsr.ccs|]}d|VqdS)zr%sNrr—rrrr.OsÚ__get__Ú__set__Ú __delete__Ú __reversed__Ú __missing__r™Ú __reduce_ex__Z__getinitargs__Ú__getnewargs__Ú __getstate__Ú __setstate__Ú __getformat__Z __setformat__r˜rÚ__subclasses__Ú __format__Ú__getnewargs_ex__cs‡fdd„}||_|S)z:Turns a callable object (like a mock) into a real functioncsˆ|f|ž|ŽSr/r©rArBrÇr,rrÚmethod`sz_get_method..method)rM)rr-r§rr,rr ^s r cCsh|] }d|’qS)r�r)rr§rrrrfsÚ __aenter__Ú __aexit__Ú __anext__Ú __aiter__rŸrr8rÅÚ __prepare__Ú__instancecheck__Ú__subclasscheck__Ú__del__cCs t |¡Sr/)rÚ__hash__r—rrrrñ|ròrñcCs t |¡Sr/)rÚ__str__r—rrrrñ}ròcCs t |¡Sr/)rÚ __sizeof__r—rrrrñ~ròcCs"t|ƒj›d| ¡›dt|ƒ›�S)Nú/)r1rMrÿrér—rrrrñrò)r°r±r²Ú __fspath__r®yð?gð?) Ú__lt__Ú__gt__Ú__le__Ú__ge__Ú__int__r¯Ú__len__ryÚ __complex__Ú __float__Ú__bool__Ú __index__r©cs‡fdd„}|S)Ncs$ˆjj}|tk r|Sˆ|kr dStS©NT)Ú__eq__r rÚNotImplemented)ÚotherÚret_valr—rrrÀ”s z_get_eq..__eq__r)rArÀrr—rÚ_get_eq“s rÄcs‡fdd„}|S)Ncs ˆjjtk rtSˆ|krdStS©NF)Ú__ne__r rrÁ)rÂr—rrrÆžs  z_get_ne..__ne__r)rArÆrr—rÚ_get_ne�s rÇcs‡fdd„}|S)Ncs ˆjj}|tkrtgƒSt|ƒSr/)Ú__iter__r rr¹©rÃr—rrrȧsz_get_iter..__iter__r)rArÈrr—rÚ _get_iter¦s rÊcs‡fdd„}|S)Ncs(ˆjj}|tkrttgƒƒStt|ƒƒSr/)r«r rÚ_AsyncIteratorr¹rÉr—rrr«±s z"_get_async_iter..__aiter__r)rAr«rr—rÚ_get_async_iter°s rÌ)rÀrÆrÈr«cCsbt |t¡}|tk r||_dSt |¡}|dk rB||ƒ}||_dSt |¡}|dk r^||ƒ|_dSr/)Ú_return_valuesr^rrvÚ_calculate_return_valueÚ_side_effect_methodsr})r5r§rZfixedZreturn_calculatorrvZ side_effectorrrrÚ_set_return_valueÁs   rÐc@seZdZdd„Zdd„ZdS)Ú MagicMixincOs&| ¡tt|ƒj||Ž| ¡dSr/)Ú_mock_set_magicsrÄrÑr8r¦rrrr8ÔszMagicMixin.__init__cCs’ttB}|}t|ddƒdk rX| |j¡}tƒ}||}|D]}|t|ƒjkr:t||ƒq:|tt|ƒjƒ}t|ƒ}|D]}t ||t ||ƒƒqvdS)NrÝ) Ú_magicsr:r$Ú intersectionrÝrr1r]r rSÚ MagicProxy)rAZ orig_magicsZ these_magicsZ remove_magicsrðr=rrrrÒÚs  zMagicMixin._mock_set_magicsN)rMrPršr8rÒrrrrrÑÓsrÑc@seZdZdZddd„ZdS)r z-A version of `MagicMock` that isn't callable.FcCs| ||¡| ¡dSrשrÎrÒrØrrrrÙôs z"NonCallableMagicMock.mock_add_specN)F©rMrPršrNrÙrrrrr òsr c@seZdZdd„ZdS)ÚAsyncMagicMixincOs&| ¡tt|ƒj||Ž| ¡dSr/)rÒrÄrØr8r¦rrrr8ÿszAsyncMagicMixin.__init__N©rMrPršr8rrrrrØþsrØc@seZdZdZddd„ZdS)ra„ MagicMock is a subclass of Mock with default implementations of most of the magic methods. You can use MagicMock without having to configure the magic methods yourself. If you use the `spec` or `spec_set` arguments then *only* magic methods that exist in the spec will be created. Attributes and the return value of a `MagicMock` will also be `MagicMocks`. FcCs| ||¡| ¡dSr×rÖrØrrrrÙs zMagicMock.mock_add_specN)Fr×rrrrrs rc@s&eZdZdd„Zdd„Zddd„ZdS) rÕcCs||_||_dSr/©rr´)rArr´rrrr8szMagicProxy.__init__cCs8|j}|j}|j|||d�}t|||ƒt|||ƒ|S)N)rrÒrÓ)rr´rärSrÐ)rArðr´ÚmrrrÚ create_mocksÿ  zMagicProxy.create_mockNcCs| ¡Sr/)rÜ)rAr)r=rrrr™(szMagicProxy.__get__)N)rMrPršr8rÜr™rrrrrÕs rÕcs‚eZdZedƒZedƒZedƒZ‡fdd„Zdd„Zdd „Z d d „Z d d „Z dd„Z dd„Z ddd„Zdd„Z‡fdd„Z‡ZS)rÃr‹rŒr�cs\tƒj||Žtjj|jd<d|jd<d|jd<tƒ|jd<ttd�}t j |_ ||jd<dS)NrŠrZ_mock_await_countZ_mock_await_argsZ_mock_await_args_list©rÐr+) Úsuperr8r%r‰rŠr]rrr rr'Z CO_COROUTINEÚco_flags)rArBrCÚ code_mock©rårrr81s    zAsyncMockMixin.__init__cÏst||fdd�}|jd7_||_|j |¡|j}|dk rºt|ƒrL|‚nbt|ƒsˆz t|ƒ}Wnt k rxt ‚YnXt|ƒr®|‚n&t   |¡r¤|||ŽIdH}n |||Ž}|t k rº|S|jt k rÊ|jS|jdk rþt   |j¡rò|j||ŽIdHS|j||ŽS|jS)NTrDr®)rFr‹rŒr�ràr}r3rXrºÚ StopIterationÚStopAsyncIterationr%r&rr rvrÌ)rArBrCrrGrfrrrrCAs6         z!AsyncMockMixin._execute_mock_callcCs(|jdkr$d|jpd›d�}t|ƒ‚dS)zA Assert that the mock was awaited at least once. rú Expected r5z to have been awaited.N©r‹r¤rr rrrr‚is zAsyncMockMixin.assert_awaitedcCs0|jdks,d|jpd›d|j›d�}t|ƒ‚dS)z@ Assert that the mock was awaited exactly once. r®rär5ú$ to have been awaited once. Awaited ú times.Nrår rrrrƒqs z"AsyncMockMixin.assert_awaited_oncecszˆjdkr&ˆ ˆˆ¡}td|›d�ƒ‚‡‡‡fdd„}ˆ ˆˆf¡}ˆ ˆj¡}||krvt|tƒrf|nd}t|ƒƒ|‚dS)zN Assert that the last await was with the specified arguments. NzExpected await: z Not awaitedcsˆjˆˆdd�}|S)NÚawait)rr!r"r#rrr$‚sz:AsyncMockMixin.assert_awaited_with.._error_message)rŒrrrr"r%)rArBrCr&r$r'r(rr#rr„zs   z"AsyncMockMixin.assert_awaited_withcOs8|jdks,d|jpd›d|j›d�}t|ƒ‚|j||ŽS)zi Assert that the mock was awaited exactly once and with the specified arguments. r®rär5rærç)r‹r¤rr„r)rrrr…Œs z'AsyncMockMixin.assert_awaited_once_withcsZˆ ||f¡}‡fdd„ˆjDƒ}||krVt|tƒr8|nd}ˆ ||¡}td|ƒ|‚dS)zU Assert the mock has ever been awaited with the specified arguments. csg|]}ˆ |¡‘qSrr*r+r—rrrÁœsz3AsyncMockMixin.assert_any_await..Nz%s await not found)rr�r"r%rrr9rr—rr†—s ÿþzAsyncMockMixin.assert_any_awaitFc sð‡fdd„|Dƒ}tdd„|Dƒdƒ}t‡fdd„ˆjDƒƒ}|s�||krŒ|dkrXd}nd d d„|Dƒ¡}t|›d t|ƒ›d ˆj›�ƒ|‚dSt|ƒ}g}|D]2}z| |¡Wq tk rÐ| |¡Yq Xq |rìtd t |ƒfƒ|‚dS) a´ Assert the mock has been awaited with the specified calls. The :attr:`await_args_list` list is checked for the awaits. If `any_order` is False (the default) then the awaits must be sequential. There can be extra calls before or after the specified awaits. If `any_order` is True then the awaits can be in any order, but they must all appear in :attr:`await_args_list`. csg|]}ˆ |¡‘qSrr*r+r—rrrÁ°sz4AsyncMockMixin.assert_has_awaits..css|]}t|tƒr|VqdSr/r-rrrrr.±s z3AsyncMockMixin.assert_has_awaits..Nc3s|]}ˆ |¡VqdSr/r*r+r—rrr.²szAwaits not found.z,Error processing expected awaits. Errors: {}cSsg|]}t|tƒr|nd‘qSr/r-rrrrrÁºsÿr/z Actual: z%r not all found in await list) rºrrr�r1rrYr3r<ràrZ) rAr4r5r&r(Z all_awaitsr6r7r8rr—rr‡¤s> ÿþÿü ÿþz AsyncMockMixin.assert_has_awaitscCs0|jdkr,d|jpd›d|j›d�}t|ƒ‚dS)z9 Assert that the mock was never awaited. rrär5z# to not have been awaited. Awaited rçNrår rrrrˆÐs z!AsyncMockMixin.assert_not_awaitedcs&tƒj||Žd|_d|_tƒ|_dS)z0 See :func:`.Mock.reset_mock()` rN)rÞrur‹rŒrrr�r@rárrruÙszAsyncMockMixin.reset_mock)F)rMrPršr­r‹rŒr�r8rCr‚rƒr„r…r†r‡rˆruÚ __classcell__rrrárrÃ,s (   , rÃc@seZdZdZdS)r aa Enhance :class:`Mock` with features allowing to mock an async function. The :class:`AsyncMock` object will behave so the object is recognized as an async function, and the result of a call is an awaitable: >>> mock = AsyncMock() >>> asyncio.iscoroutinefunction(mock) True >>> inspect.isawaitable(mock()) True The result of ``mock()`` is an async function which will have the outcome of ``side_effect`` or ``return_value``: - if ``side_effect`` is a function, the async function will return the result of that function, - if ``side_effect`` is an exception, the async function will raise the exception, - if ``side_effect`` is an iterable, the async function will return the next value of the iterable, however, if the sequence of result is exhausted, ``StopIteration`` is raised immediately, - if ``side_effect`` is not defined, the async function will return the value defined by ``return_value``, hence, by default, the async function returns a new :class:`AsyncMock` object. If the outcome of ``side_effect`` or ``return_value`` is an async function, the mock async function obtained when the mock object is called will be this async function itself (and not an async function returning an async function). The test author can also specify a wrapped object with ``wraps``. In this case, the :class:`Mock` object behavior is the same as with an :class:`.Mock` object: the wrapped object may have methods defined as async function functions. Based on Martin Richard's asynctest project. NrHrrrrr ãsr c@s(eZdZdZdd„Zdd„Zdd„ZdS) Ú_ANYz2A helper object that compares equal to everything.cCsdSr¿r©rArÂrrrrÀ sz _ANY.__eq__cCsdSrÅrrërrrrÆ sz _ANY.__ne__cCsdS)Nzrr—rrrr˜ sz _ANY.__repr__N)rMrPršrNrÀrÆr˜rrrrrê srêcCs`d|}d}d dd„|Dƒ¡}d dd„| ¡Dƒ¡}|r@|}|rX|rP|d7}||7}||S)Nz%s(%%s)rÊz, cSsg|] }t|ƒ‘qSr)Úreprr¿rrrrÁ! sz*_format_call_signature..cSsg|]\}}d||f‘qS)z%s=%rr)rrór¨rrrrÁ" s)rýrõ)rrBrCrZformatted_argsZ args_stringZ kwargs_stringrrrr s ÿrc@sŠeZdZdZd!dd„Zd"d d „Zd d „ZejZd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zedd„ƒZedd„ƒZdd„Zdd „ZdS)#rFa£ 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. rrÊNFTc Cs¼d}i}t|ƒ}|dkr$|\}}}nr|dkrd|\} } t| tƒrX| }t| tƒrR| }qb| }q–| | }}n2|dkr–|\}t|tƒr‚|}nt|tƒr’|}n|}|rªt |||f¡St ||||f¡S)Nrér�r®)r°r"rˆrZrÅ) rÆr¨rr´rEÚ from_kallrBrCÚ_lenÚfirstÚsecondrrrrÅC s.      z _Call.__new__cCs||_||_||_dSr/)r¤r¢Ú_mock_from_kall)rAr¨rr´rErîrrrr8c sz_Call.__init__c Csh|tkr dSz t|ƒ}Wntk r.YdSXd}t|ƒdkrJ|\}}n |\}}}t|ddƒr|t|ddƒr||j|jkr|dSd}|dkr”di}}n°|dkr¨|\}}}nœ|d krî|\} t| tƒrÊ| }i}n"t| tƒrä| }di}}nd}| }nV|dk�r@|\} } t| tƒ�r4| }t| tƒ�r(| i}}n d| }}n | | }}ndS|�rX||k�rXdS||f||fkS) NTFrÊr�r¢rrrír®)rr°rr$r¢r"rZrˆ) rArÂZ len_otherZ self_nameZ self_argsZ self_kwargsZ other_nameZ other_argsZ other_kwargsr¨rðrñrrrrÀj sR     ÿ           z _Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)NrÊrâr’rÚ©r¤rFrrrrr9¤ s  z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rrîz%s.%s)rr´rîró)rAr€rrrrrŸ¬ s  z_Call.__getattr__cCs|tjkrt‚t ||¡Sr/)rZr]r:Ú__getattribute__)rAr€rrrrô³ s z_Call.__getattribute__cOs| d¡||ŽS)Nrï©rŸr@rrrrï¹ sz _Call.countcOs| d¡||ŽS)NÚindexrõr@rrrrö¼ sz _Call.indexcCs(t|ƒdkr|\}}n |\}}}||fS)Nr�)r°rrrrÚ_get_call_arguments¿ s   z_Call._get_call_argumentscCs | ¡dS©Nr©r÷r—rrrrBÇ sz _Call.argscCs | ¡dS)Nr®rùr—rrrrCË sz _Call.kwargscCs||js&|jpd}| d¡r"d|}|St|ƒdkr@d}|\}}n0|\}}}|sTd}n| d¡shd|}nd|}t|||ƒS)Nrrâzcall%sr�zcall.%s)ròr¤rr°r)rArrBrCrrrr˜Ï s       z_Call.__repr__cCs4g}|}|dk r(|jr | |¡|j}qtt|ƒƒS)z•For a call object that represents multiple calls, `call_list` returns a list of all the intermediate calls as well as the final call.N)ròràr¢rrrü)rAZvalsrJrrrÚ call_listä s z_Call.call_list)rrÊNFT)rNNFT)rMrPršrNrÅr8rÀrrÆr9rŸrôrïrör÷r¬rBrCr˜rúrrrrrF0 s*ÿ ÿ 7  rF)rîc Kslt|ƒrt|ƒ}t|tƒ}t|ƒ}d|i}|r8d|i}n |dkrDi}|rT|rTd|d<| |¡t} t |¡rri}n8|rˆ|r‚tdƒ‚t } n"t |ƒs–t } n|rª|rªt |ƒsªt } |  d|¡}|} |dkrÆd} | f||| |d œ|—Ž} t|tƒ�rt| |ƒ} |�rt| ƒnt|| ||ƒ|dk �r,|�s,| |j|<|�rV|�sVd |k�rVt||dd | d �| _t|ƒD�]} t| ƒ�rr�q^zt|| ƒ} Wntk �rœY�q^YnXd| i}|�r´d| i}t| tƒ�sÜt| || | |ƒ}|| j| <np| }t|tƒ�rò| j}t|| |ƒ}||d <t | ¡�rt }nt}|f|| | |dœ|—Ž}|| j| <t| ||d�t|tƒ�r^t| | |ƒ�q^| S)aICreate a mock object using another object as a spec. Attributes on the mock will use the corresponding attribute on the `spec` object as their spec. Functions or methods being mocked will have their arguments checked to check that they are called with the correct signature. If `spec_set` is True then attempting to set attributes that don't exist on the spec object will raise an `AttributeError`. If a class is used as a spec then the return value of the mock (the instance of the class) will have the same spec. You can use a class as the spec for an instance object by passing `instance=True`. The returned mock will only be callable if instances of the mock are callable. `create_autospec` also takes arbitrary keyword arguments that are passed to the constructor of the created mock.r¾rÐNTrÔzJInstance can not be True when create_autospec is mocking an async functionrrÊ)r´rÓrÒrrvrâ)rKrtr¶rÕ)r´rrÒrÓ)rJ)r[r1r"r.rerr'ZisdatadescriptorÚ RuntimeErrorr rXr r`r÷r6rirŽrLr~rrvrßr“r$r:rër5Ú _must_skipr%r&rS)r¾rÐrKr¶rtrCÚis_typeZ is_async_funcr}r|rÒr5rðrerÉr´rJZ child_klassrrrrô s–      ÿÿ    ÿ         ÿþ  rcCsxt|tƒs$|t|diƒkrdS|j}|jD]H}|j |t¡}|tkrFq*t|tt fƒrZdSt|t ƒrl|SdSq*|S)z[ Return whether we should skip the first argument on spec's `entry` attribute. r]F) r"r1r$rår\r]r^rrVrWr6)r¾rðrýr>rfrrrrüw s   rüc@seZdZddd„ZdS)rëFNcCs(||_||_||_||_||_||_dSr/)r¾ÚidsrÐr´rKr)rAr¾rÐr´rrþrKrrrr8• s z_SpecState.__init__)FNNNFrÙrrrrrë“ s ÿrëcCs"t|tƒrt |¡St |¡SdSr/)r"ÚbytesÚioÚBytesIOÚStringIO)Ú read_datarrrÚ _to_streamª s  rrÊcs&tˆƒ}|dg‰‡‡fdd„}‡‡fdd„}‡‡fdd„‰‡‡fdd „‰‡‡fd d „}tdkrˆd dl}ttt|jƒƒ tt|jƒƒ¡ƒa|dkrœt d t d�}t td�‰ˆˆj _ dˆj _ dˆj_ dˆj_ dˆj_ |ˆj_ˆƒˆd<ˆdˆj_|ˆj_ˆˆj_|ˆj_‡‡‡‡fdd„}||_ˆ|_ |S)a÷ A helper function to create a mock to replace the use of `open`. It works for `open` called directly or used as a context manager. The `mock` argument is the mock object to configure. If `None` (the default) then a `MagicMock` will be created for you, with the API limited to methods or attributes available on standard file handles. `read_data` is a string for the `read`, `readline` and `readlines` of the file handle to return. This is an empty string by default. Ncs$ˆjjdk rˆjjSˆdj||ŽSrø)Ú readlinesrvra©Ú_stateÚhandlerrÚ_readlines_side_effectÀ s z)mock_open.._readlines_side_effectcs$ˆjjdk rˆjjSˆdj||ŽSrø)ÚreadrvrarrrÚ_read_side_effectÅ s z$mock_open.._read_side_effectc?s$ˆƒEdHˆdj||ŽVq dSrø)Úreadlinera)Ú_iter_side_effectrrrÚ_readline_side_effectÊ s z(mock_open.._readline_side_effectc3s0ˆjjdk rˆjjVq ˆdD] }|Vq dSrø)r rv)Úlinerrrr Ï s   z$mock_open.._iter_side_effectcs ˆjjdk rˆjjStˆdƒSrø)r rvrºrrrrÚ_next_side_effectÖ s z$mock_open.._next_side_effectrÚopen)rr¾r½r®cs6tˆƒˆd<ˆjjˆdkr2ˆƒˆd<ˆdˆj_tS)Nrr®)rr r}rra)rrrrrrÚ reset_dataò s    zmock_open..reset_data)rÚ file_specÚ_iorYrrßÚ TextIOWrapperÚunionrrrr~rvÚwriter r rr}rÈr»)r5rZ _read_datar r rrrr)r rrrrrr ± s8 "    r c@s*eZdZdZdd„Zd dd„Zdd„ZdS) raW A mock intended to be used as a property, or other descriptor, on a class. `PropertyMock` provides `__get__` and `__set__` methods so you can specify a return value when it is fetched. Fetching a `PropertyMock` instance from an object calls the mock, with no args. Setting it calls the mock with the value being set. cKs tf|ŽSr/)r)rArCrrrrä szPropertyMock._get_child_mockNcCs|ƒSr/r)rAr)Zobj_typerrrr™ szPropertyMock.__get__cCs ||ƒdSr/r)rAr)rørrrrš szPropertyMock.__set__)N)rMrPršrNrär™ršrrrrrÿ s rc Cs^d|_t|ƒD]J}zt||ƒ}Wntk r8YqYnXt|tƒsFq|j|krt|ƒqdS)a˜Disable the automatic generation of child mocks. Given an input Mock, seals it to ensure no further mocks will be generated when accessing an attribute that was not already defined. The operation recursively seals the mock passed in, meaning that the mock itself, any mocks generated by accessing one of its attributes, and all assigned mocks without a name or spec will be sealed. TN)rËrßr$r:r"r r£r)r5r€rÛrrrr s     rc@s(eZdZdZdd„Zdd„Zdd„ZdS) rËz8 Wraps an iterator in an asynchronous iterator. cCs&||_ttd�}tj|_||jd<dS)NrÝr+)Úiteratorr rr'ZCO_ITERABLE_COROUTINErßr])rArràrrrr8+ s z_AsyncIterator.__init__cCs|Sr/rr—rrrr«1 sz_AsyncIterator.__aiter__cÃs*z t|jƒWStk r YnXt‚dSr/)rºrrârãr—rrrrª4 s  z_AsyncIterator.__anext__N)rMrPršrNr8r«rªrrrrrË' srË)F)F)NFNNN)FFNN)NrÊ)yÚ__all__Ú __version__r%rarr'r³rzÚbuiltinsÚtypesrrrZ unittest.utilrÚ functoolsrrrßrqr rÞrÄr*r.r!r3r7r=rLrGrXr[r`rirdrŽr“rr”r›rrÚMISSINGr ZDELETEDrìrªr­rYrrr·r¸r¼r rèr<rrMrOrPr‡r‰rŠrr‹r”r•r�ZmultipleZstopallr_Z magic_methodsZnumericsrýröZinplaceÚrightZ _non_defaultsr rÓr:Z_sync_async_magicsZ _async_magicsr;rûrrÎrÁrÍrÄrÇrÊrÌrÏrÐrÑr rØrrÕrÃr rêrrrZrFrrrürër1rÀr6rrr rrrËrrrrÚs~      1 ý h4 < ý ÿ 2þ Mw ÿÿû þ üüó    ü  8+ B ÿ ü N