+p# ddlZddlZddlZddlZddlZddlmZddlmZej dddlm Z m Z ddlm Z ddl mZmZmZmZmZmZmZmZmZmZd ZGd d ZGd d ZdZdZdZGddeZe dZ!e dZ"edZ#Gddej$Z%Gddej$Z&Gddej$Z'Gddej$Z(Gddej$Z)Gd d!ej$Z*Gd"d#e Z+Gd$d%ej$Z,Gd&d'ej$Z-Gd(d)ej$Z.Gd*d+ej$Z/e d,krej0dSdS)-N)contextmanager)supportT)module)runiscoroutinefunction)IsolatedAsyncioTestCase) ANYcall AsyncMockpatch MagicMockMockcreate_autospecsentinel _CallListsealc.tjddSN)asyncioset_event_loop_policyG/opt/alt/python311/lib64/python3.11/unittest/test/testmock/testasync.pytearDownModulers !$'''''rcLeZdZdZdZdZedZedZ dS) AsyncClasscdSrrselfs r__init__zAsyncClass.__init__rc KdSrrrs r async_methodzAsyncClass.async_method rcdSrrrs r normal_methodzAsyncClass.normal_methodr!rc KdSrr)clss rasync_class_methodzAsyncClass.async_class_methods '+trc KdSrrrrrasync_static_methodzAsyncClass.async_static_methods %)TrN) __name__ __module__ __qualname__r r#r& classmethodr) staticmethodr+rrrrrsQ&&&!!!++[+))\)))rrceZdZdZdS)AwaitableClassc#KdVdSrrrs r __await__zAwaitableClass.__await__"srN)r,r-r.r4rrrr2r2!srr2c KdSrrrrr async_funcr6$r$rc KdSrr)abcs rasync_func_argsr;&r$rcdSrrrrr normal_funcr=(r!rceZdZdZdS) NormalClasscdSrrrs rr8z NormalClass.a+r!rN)r,r-r.r8rrrr?r?*srr?z .AsyncClassz .NormalClassc#K|td5dVtjddddS#1swxYwYdS)Nzwas never awaited$)assertWarnsRegexRuntimeWarninggccollect)tests rassertNeverAwaitedrG2s  ~/C D D  sAA Ac2eZdZdZdZdZdZdZdZdS)AsyncPatchDecoratorTestcftjtdfd}|dS)Nr#cLt|dSr) assertTruer mock_methodrs r test_asynczLAsyncPatchDecoratorTest.test_is_coroutine_function_patch..test_async=s$ OO/ << = = = = =rr objectrrrOs` r test_is_coroutine_function_patchz8AsyncPatchDecoratorTest.test_is_coroutine_function_patch<sB j. 1 1 > > > > 2 1 > rctjtdfd}ttdfd}||dS)Nr#c|}tj|t|dSrrLinspect isawaitablerrNmrs rrOz?AsyncPatchDecoratorTest.test_is_async_patch..test_asyncC: A OOG/22 3 3 3 FFFFFrz .async_methodc|}tj|t|dSrrVrYs rtest_no_parent_attributezMAsyncPatchDecoratorTest.test_is_async_patch..test_no_parent_attributeIr[r)r rQrasync_foo_name)rrOr]s` rtest_is_async_patchz+AsyncPatchDecoratorTest.test_is_async_patchBs j. 1 1     2 1  ./// 0 0     1 0     """""rcftjtdfd}|dS)Nr#c>|tdSrassertIsInstancer rMs rrOzCAsyncPatchDecoratorTest.test_is_AsyncMock_patch..test_asyncS  ! !+y 9 9 9 9 9rrPrRs` rtest_is_AsyncMock_patchz/AsyncPatchDecoratorTest.test_is_AsyncMock_patchRsD j. 1 1 : : : : 2 1 :  rcftjtdfd}|dS)Nr+c>|tdSrrbrMs rrOzPAsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethod..test_asyncZrdrrPrRs` r$test_is_AsyncMock_patch_staticmethodz|tdSrrbrMs rrOzOAsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethod..test_asyncardrrPrRs` r#test_is_AsyncMock_patch_classmethodz;AsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethod`sE j"6 7 7 : : : : 8 7 :  rcttddttddfd}t|t jt dS)N .async_func return_value.async_func_argscK|jd|jdttt ttd{Vdt dddd{VddS)Nr;r6rnrrr:) assertEqual _mock_namercr6r r;)func_args_mock func_mockrs rrOz@AsyncPatchDecoratorTest.test_async_def_patch..test_asynchs   ^68I J J J   Y1< @ @ @  ! !*i 8 8 8  ! !/9 = = =   :<<////// 3 3 3   ?1a1#=#=#=======q A A A A Ar)r r,rrLrWrr6rRs` rtest_async_def_patchz,AsyncPatchDecoratorTest.test_async_def_patchgs ('''a 8 8 8 (,,,1 = = = B B B B > = 9 8 B JJLL 3J??@@@@@rN) r,r-r.rSr_rerhrkrzrrrrIrI;ss ### AAAAArrIc2eZdZdZdZdZdZdZdZdS)AsyncPatchCMTestc&fd}|dS)Nctjtd5}t |ddddS#1swxYwYdSNr#)r rQrrLrrMs rrOz>AsyncPatchCMTest.test_is_async_function_cm..test_asynczsj.99 B[ 3K @ @AAA B B B B B B B B B B B B B B B B B Bs#A  AArrRs` rtest_is_async_function_cmz*AsyncPatchCMTest.test_is_async_function_cmys2 B B B B B  rc&fd}|dS)Nctjtd5}|}t j|t |ddddS#1swxYwYdSr)r rQrrLrWrXrrYs rrOz5AsyncPatchCMTest.test_is_async_cm..test_asyncsj.99 [KMM 3A 6 6777A                  sAA**A.1A.rrRs` rtest_is_async_cmz!AsyncPatchCMTest.test_is_async_cms-       rc&fd}|dS)Nctjtd5}|tddddS#1swxYwYdSr)r rQrrcr rMs rrOz9AsyncPatchCMTest.test_is_AsyncMock_cm..test_asyncsj.99 >[%%k9=== > > > > > > > > > > > > > > > > > >sAA  A rrRs` rtest_is_AsyncMock_cmz%AsyncPatchCMTest.test_is_AsyncMock_cms- > > > > >  rc@fd}t|dS)NcKttdt5ttdddn #1swxYwYt jtdS)Nrm)r r,r rcr6rLrWrrsrrOz6AsyncPatchCMTest.test_async_def_cm..test_asyncs(///== = =%%j)<<< = = = = = = = = = = = = = = = OOG7 CC D D D D Ds!AAArrRs` rtest_async_def_cmz"AsyncPatchCMTest.test_async_def_cms= E E E E E JJLLrcdditjddifd}t|t |dS)Nr8r9cDKdddSNr8r9)rvfoorsrrOz>AsyncPatchCMTest.test_patch_dict_async_def..test_asyncs'   SXs + + + + +r)r dictrLrrrrOrs` @rtest_patch_dict_async_defz*AsyncPatchCMTest.test_patch_dict_async_defs}Cj C#s $ $ , , , , , % $ , +J77888 JJLLrcLddifd}t|dS)Nr8cKtjddi5ddddddS#1swxYwYdSr)r rrvrsrrOzFAsyncPatchCMTest.test_patch_dict_async_def_context..test_asyncsC#s,, 0 0  S3/// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0sAA  A rrs` @r!test_patch_dict_async_def_contextz2AsyncPatchCMTest.test_patch_dict_async_def_contextsGCj 0 0 0 0 0 0 JJLLrN) r,r-r.rrrrrrrrrr|r|xsnrr|c,eZdZdZdZdZdZdZdS) AsyncMockTestcft}|t|dSr)r rLrrmocks r test_iscoroutinefunction_defaultz.AsyncMockTest.test_iscoroutinefunction_defaults,{{ +D1122222rcd}t|}|t||tj|dS)Nc KdSrrrrrrz.foor$rr rLrrWrrrs r!test_iscoroutinefunction_functionz/AsyncMockTest.test_iscoroutinefunction_functionsT~~ +D11222 3D99:::::rct}|}|tj|t ||dt |dS)Nassert_awaited)r rLrWrXrassertIndirrrrZs rtest_isawaitablezAsyncMockTest.test_isawaitables_{{ DFF +A../// A &D 22222rcd}t|}|t||tj|dS)NcdSrrrrrrzCAsyncMockTest.test_iscoroutinefunction_normal_function..foor!rrrs r(test_iscoroutinefunction_normal_functionz6AsyncMockTest.test_iscoroutinefunction_normal_functionsR~~ +D11222 3D99:::::rctj}|}||t |}||tjdSr)rnew_event_loop create_futurestopcloser rcFuture)rloopfutrs rtest_future_isfuturez"AsyncMockTest.test_future_isfuturesd%''  ""  ~~ dGN33333rN)r,r-r.rrrrrrrrrrs_333;;; 333;;; 44444rrcXeZdZdZdZejddZdZdZ dS)AsyncAutospecTestcttdfd}ttdfd}||dS)NTautospecc~|jt|tdSrrcr#r r rMs rrOz=AsyncAutospecTest.test_is_AsyncMock_patch..test_asyncs8  ! !+":I F F F  ! !+y 9 9 9 9 9rcH|jtdSr)rcr&r rMs rtest_normal_methodzEAsyncAutospecTest.test_is_AsyncMock_patch..test_normal_methods"  ! !+";Y G G G G Grr r^)rrOrs` rrez)AsyncAutospecTest.test_is_AsyncMock_patchs ~ - - - : : : : . - : ~ - - - H H H H . - H  rc|t5ttdddddS#1swxYwYdS)NT)instance) assertRaises RuntimeErrorrr6rs rtest_create_autospec_instancez/AsyncAutospecTest.test_create_autospec_instances   | , , 7 7 J 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7s?AAz3Broken test from https://bugs.python.org/issue37251c`|tttdSr)rcrr2r rs r$test_create_autospec_awaitable_classz6AsyncAutospecTest.test_create_autospec_awaitable_classs& on==yIIIIIrctt}|dddfd}||jd||j||jg|t|| t|| tj ||jd||jtddd||jtdddg||ddd|ddd||t&5|dddddS#1swxYwYdS)NrnrrrtrucKd{VdSrr) awaitablesrmainz4AsyncAutospecTest.test_create_autospec..mainsOOOOOOOOOrr)e)rr;rv await_count assertIsNone await_argsawait_args_listassert_not_awaitedrrLrr iscoroutiner assert_awaited_onceassert_awaited_once_withassert_awaited_withrrAssertionErrorassert_any_await)rspecrrs @rtest_create_autospecz&AsyncAutospecTest.test_create_autospecs///DAOOO       )1--- $/*** -r222 !!! DDFF  +D11222 +I66777 )1--- $q!q///::: -QQ/@AAA   """ %%aa%000   A +++    ~ . . ' '  ! !A ! & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'sG55G9<G9c@fd}t|dS)NcKttdd5}|ddd}|jtt |tj|tj | |j d |j g|j||d{Vdddn #1swxYwY |j d |jt#ddd |j t#dddg||ddd|ddd|| |j d|j |j gdS) NrqTrrnrrrtrur)r r,rcrr rLrrrrWrXrvrrrrrr rrrr reset_mock)rNrrs rrOz>AsyncAutospecTest.test_patch_with_autospec..test_asyncs(444tDDD 'K1222 %%k&6 BBB 3K @ @AAA 3I > >??? 3I > >???  !8!<<<  ! > > > >< JJLLrN) r,r-r.rerunittestskiprrrrrrrrs}   777X]HIIJJJIJ'''6     rrcVeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd S) AsyncSpecTestcfd}ttfD]=}d|5||dddn #1swxYwY>dS)Nc|t}|jt|jt dSr)rrcr#r r&r ) mock_typerrs r inner_testzCAsyncSpecTest.test_spec_normal_methods_on_class..inner_test!sJ9Z((D  ! !$"3Y ? ? ?  ! !$"4i @ @ @ @ @rztest method types with r r subTestrrrs` r!test_spec_normal_methods_on_classz/AsyncSpecTest.test_spec_normal_methods_on_class s A A A A A $Y/ & &IC CCDD & & 9%%% & & & & & & & & & & & & & & & & & AA A ctt}||jt||jtdSr)rrrcr#r r&rs r+test_spec_normal_methods_on_class_with_mockz9AsyncSpecTest.test_spec_normal_methods_on_class_with_mock*sGJ d/;;; d0$77777rc2tt}t||t5|jdddn #1swxYwY|t5|jddddS#1swxYwYdSr)rrrrAttributeErrorr&r#rs r0test_spec_normal_methods_on_class_with_mock_sealz>AsyncSpecTest.test_spec_normal_methods_on_class_with_mock_seal/s J T   ~ . .                       ~ . .                       s#AAA7B  BBcfd}tttfD]=}d|5||dddn #1swxYwY>dS)NcP|t}||t5t j|dddn #1swxYwY|t }||dSNrr6rcrGrLrWrXr=r async_mock sync_mockrs rrz8AsyncSpecTest.test_spec_mock_type_kw..inner_test8s" 333J  ! !*i 8 8 8#D)) C C 3JJLL A ABBB C C C C C C C C C C C C C C C" {333I  ! !)Y 7 7 7 7 7s0A44A8;A8ztest spec kwarg with r r rrrs` rtest_spec_mock_type_kwz$AsyncSpecTest.test_spec_mock_type_kw7s 8 8 8 8 8$Y5 & &IAiAABB & & 9%%% & & & & & & & & & & & & & & & & & A  A A cfd}tttfD]=}d|5||dddn #1swxYwY>dS)NcL|t}||t5t j|dddn #1swxYwY|t }||dSrrrs rrz@AsyncSpecTest.test_spec_mock_type_positional..inner_testFs":..J  ! !*i 8 8 8#D)) C C 3JJLL A ABBB C C C C C C C C C C C C C C C" +..I  ! !)Y 7 7 7 7 7s0A33A7:A7ztest spec positional with rrs` rtest_spec_mock_type_positionalz,AsyncSpecTest.test_spec_mock_type_positionalEs 8 8 8 8 8$Y5 & &IF9FFGG & & 9%%% & & & & & & & & & & & & & & & & &rctt}||t|}|t j|t |dSrr r=rcrLrWrXrrs r test_spec_as_normal_kw_AsyncMockz.AsyncSpecTest.test_spec_as_normal_kw_AsyncMockSs_k*** dI... DFF +A../// Arctt}||t|}|t j|t |dSrrrs r(test_spec_as_normal_positional_AsyncMockz6AsyncSpecTest.test_spec_as_normal_positional_AsyncMockZs\%% dI... DFF +A../// Arcjtjtddfd}|dS)Nr#Trc>|tdSrrbrMs rrOz6AsyncSpecTest.test_spec_async_mock..test_asyncbrdrrPrRs` rtest_spec_async_mockz"AsyncSpecTest.test_spec_async_mockasI j.t < < < : : : : = < :  rc^ttdfd}|dS)NTrc~|t|jtdSr)rcr r#r rMs rrOzIAsyncSpecTest.test_spec_parent_not_async_attribute_is..test_asyncis8  ! !+y 9 9 9  ! !+":I F F F F FrrrRs` r'test_spec_parent_not_async_attribute_isz5AsyncSpecTest.test_spec_parent_not_async_attribute_ishsJ ~D ) ) ) G G G G * ) G  rc~tjtdtjfd}|dS)Nr#rc|ttj|tj|dSr)rcr assertFalserWrrXrMs rtest_async_attributezFAsyncSpecTest.test_target_async_spec_not..test_async_attributeqs]  ! !+y 9 9 9   W0== > > >   W0== > > > > >r)r rQrr?r8)rrs` rtest_target_async_spec_notz(AsyncSpecTest.test_target_async_spec_notpsR j.{} E E E ? ? ? ? F E ? rcttjtdtfd}|dS)Nr8rc>|tdSrrb)mock_async_funcrs r test_attribute_not_async_spec_iszUAsyncSpecTest.test_target_not_async_spec_is..test_attribute_not_async_spec_iszs  ! !/9 = = = = =r)r rQr?r6)rr s` rtest_target_not_async_spec_isz+AsyncSpecTest.test_target_not_async_spec_isysM k3Z 8 8 8 > > > > 9 8 >((*****rchtttfd}|dS)Nrc~|jt|tdSrr)MockNormalClassrs r test_async_attributes_coroutineszRAsyncSpecTest.test_spec_async_attributes..test_async_attributes_coroutiness8  ! !/"> J J J  ! !/9 = = = = =r)r normal_foo_namer)rrs` rtest_spec_async_attributesz(AsyncSpecTest.test_spec_async_attributessK Z 0 0 0 > > > > 1 0 > )(*****rN)r,r-r.rrrrrrrrrr rrrrrrrs&&&888  & & & & & &+++ +++++rrc&eZdZdZdZdZdZdS)AsyncSpecSetTestcjtjtddfd}|dS)Nr#Tspec_setc>|tdSrrb)r#rs rrOz.test_asyncs  ! !, : : : : :rrPrRs` rrez(AsyncSpecSetTest.test_is_AsyncMock_patchsH j.4 @ @ @ ; ; ; ; A @ ; rcttj}|t |||tdSNr)r rr#rLrrcrs rtest_is_async_AsyncMockz(AsyncSpecSetTest.test_is_async_AsyncMocksL*"9::: +D11222 dI.....rctt}|t|j|t|j||jt||jt||tdSr) r rrLrr#rr&rcr rs rtest_is_child_AsyncMockz(AsyncSpecSetTest.test_is_child_AsyncMocks*--- +D,=>>??? ,T-?@@AAA d/;;; d0)<<< dI.....rct}td|_tj|d5}||tddddS#1swxYwYdS)Nc|Srrxs rz=AsyncSpecSetTest.test_magicmock_lambda_spec..sarr mock_func)r r%r rQrc)rmock_objcms rtest_magicmock_lambda_specz+AsyncSpecSetTest.test_magicmock_lambda_specs;;&KK888 \(K 0 0 1B  ! !"i 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1sA##A'*A'N)r,r-r.rerrr(rrrrrsP /// ///11111rrc\eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdS)AsyncArgumentscKd}t|d}|dd{V}||ddS)Nc KdSrr)rvars radditionz6AsyncArguments.test_add_return_value..additionr$r ror rv)rr.routputs rtest_add_return_valuez$AsyncArguments.test_add_return_valuesV+++333tAww $$$$$rcKGddt}d}t||d}||d5|dd{VddddS#1swxYwYdS)NceZdZdS)BAsyncArguments.test_add_side_effect_exception..CustomErrorNr,r-r.rrr CustomErrorr6srr8c KdSrrr-s rr.z?AsyncArguments.test_add_side_effect_exception..additionr$rz side-effect side_effectr0) Exceptionr assertRaisesRegex)rr8r.rs rtest_add_side_effect_exceptionz-AsyncArguments.test_add_side_effect_exceptions*****)***%%%{{=/I/IJJJ  # #K ? ?  $q''MMMMMMM                  s A((A,/A,c~Kd}t|}|dd{V}||ddS)NcK|dzSNrnrr:s rr.z?AsyncArguments.test_add_side_effect_coroutine..additions7Nrr;r0r1rr.rresults rtest_add_side_effect_coroutinez-AsyncArguments.test_add_side_effect_coroutineZ   X...tAww #####rc~Kd}t|}|dd{V}||ddS)Nc |dzSrBrr:s rr.zEAsyncArguments.test_add_side_effect_normal_function..additions 7Nrr;r0rCr1rDs r$test_add_side_effect_normal_functionz3AsyncArguments.test_add_side_effect_normal_functionrGrc Kgd}t|}|D]&}||d{V|'|t5}|d{VddddS#1swxYwYdS)Nrnrrrtr;)r rvrStopAsyncIteration)rvalsritemrs rtest_add_side_effect_iterablez,AsyncArguments.test_add_side_effect_iterablesyyT*** 1 1D   4466\\\\\\4 0 0 0 0   1 2 2 a$&&LLLLLLL                  sA88A<?A<c.KGddt}d|dg}t|}||d{Vd||5}|d{VddddS#1swxYwYdS)NceZdZdS)OAsyncArguments.test_add_side_effect_exception_iterable..SampleExceptionNr7rrrSampleExceptionrSs DrrTrnrr;)r=r rvr)rrTrNrrs r'test_add_side_effect_exception_iterablez6AsyncArguments.test_add_side_effect_exception_iterables      i   ??5))*T*** ttvvq)))    / / 1$&&LLLLLLL                  s,B  BBcKtd}t|}|d{V}|||dS)Nr/ro)r assertIs)rvaluerrEs rtest_return_value_AsyncMockz*AsyncArguments.test_return_value_AsyncMocksWr***e,,,tvv fe$$$$$rcKtj}|dt|}|d{V}||tjdS)Nro)rr set_resultr rcrrrrEs rtest_return_value_awaitablez*AsyncArguments.test_return_value_awaitablesjn tc***tvv fgn55555rcbKtj}|dt|g}|d{V}||tj|t 5|d{VddddS#1swxYwYdS)Nr;)rrr[r rcrrMr\s r!test_side_effect_awaitable_valuesz0AsyncArguments.test_side_effect_awaitable_valuessn tcU+++tvv fgn555   1 2 2  $&&LLLLLLL                  sB$$B(+B(cKtd}t|}|d{V}||ddS)Nr/ror;r1)reffectrrEs rtest_side_effect_is_AsyncMockz,AsyncArguments.test_side_effect_is_AsyncMocksY+++V,,,tvv $$$$$rcKtjdfd}t|}|d{V}||||dS)NFcKdSNTrranrXsrinnerz2AsyncArguments.test_wraps_coroutine..innersCLrwraps)rrr rvrrLrrhrrErgrXs @@rtest_wraps_coroutinez#AsyncArguments.test_wraps_coroutines         u%%%tvv '''  rcKddfd}t|}|d{V}||||dS)NrnFc dSrerrfsrrhz8AsyncArguments.test_wraps_normal_function..inners CLrri)r rvrrLrks @@rtest_wraps_normal_functionz)AsyncArguments.test_wraps_normal_functions       u%%%tvv '''  rcKt}|d}|d}|d{V|d{V|tdtdg||jtdtdg||jtdtdgdS)Nrrrn)r assert_has_awaitsr rvrcall_args_list)rrmock2mock1s rtest_await_args_list_orderz)AsyncArguments.test_await_args_list_orders[[  1  1   $$d1ggtAww%7888 3d1ggtAww5GHHH 2T!WWd1gg4FGGGGGrN)r,r-r.r3r?rFrJrPrUrYr]r_rbrlrorurrrr*r*s%%%$$$$$$   %%% 666   %%%      HHHHHrr*c,eZdZdZdZdZdZdZdS)AsyncMagicMethodsc"t}||jt||jt||jt||jtdSr)r rc __aenter__r __aexit__ __anext__ __aiter__rm_mocks r+test_async_magic_methods_return_async_mocksz=AsyncMagicMethods.test_async_magic_methods_return_async_mockssw f/;;; f. ::: f. ::: f. :::::rc"t}||jt||jt||jt||jtdSr)r rc __enter__r __exit____next____len__ra_mocks r*test_sync_magic_methods_return_magic_mockszt}||jt||jt|t |j|t |jdSr)r rcryr rzrLrr}s r&test_magic_methods_are_async_functionsz8AsyncMagicMethods.test_magic_methods_are_async_functions<s f/;;; f. ::: +F,=>>??? +F,<==>>>>>rN)r,r-r.rrrrrrrrrwrws_;;;999666 444?????rrwczeZdZGddZGddZGddZdZdZd Zd Z d Z d S) AsyncContextManagerTestceZdZdZdZdS)/AsyncContextManagerTest.WithAsyncContextManagerc KdSrrrargskwargss rryz:AsyncContextManagerTest.WithAsyncContextManager.__aenter__Gr$rc KdSrrrs rrzz9AsyncContextManagerTest.WithAsyncContextManager.__aexit__Ir$rN)r,r-r.ryrzrrrWithAsyncContextManagerrFs"99988888rrceZdZdZdZdS).AsyncContextManagerTest.WithSyncContextManagercdSrrrs rrz8AsyncContextManagerTest.WithSyncContextManager.__enter__Lr!rcdSrrrs rrz7AsyncContextManagerTest.WithSyncContextManager.__exit__Nr!rN)r,r-r.rrrrrWithSyncContextManagerrKs"22211111rrceZdZdZdZdS)&AsyncContextManagerTest.ProductionCodecd|_dSr)sessionrs rr z/AsyncContextManagerTest.ProductionCode.__init__Rs DLLLrcK|jd4d{V}|d{V}|cdddd{VS#1d{VswxYwYdS)Nzhttps://python.org)rpostjson)rresponsevals rrz+AsyncContextManagerTest.ProductionCode.mainUs|(()=>>       ($MMOO++++++                              sA AAN)r,r-r.r rrrrProductionCoderPs2        rrcfd}ttfD]=}d|5||dddn #1swxYwY>dS)Ncl}td|_|d}td}tddi|_||j_||jj_t| } |ddidS)N sessionmocknamemagic_cmrr{ro) rr rr rryrprrrrv)rpcr'rrErs rrzKAsyncContextManagerTest.test_set_return_value_of_aenter..inner_test[s$$&&B" 666BJ +++B j111H%FC=AAAHM)1BM &+-BJO (^^F   Vfc] 3 3 3 3 3rz%test set return value of aenter with rrs` rtest_set_return_value_of_aenterz7AsyncContextManagerTest.test_set_return_value_of_aenterZs 4 4 4 4 4$Y/ & &IQiQQRR & & 9%%% & & & & & & & & & & & & & & & & &rcfd}ttfD]=}d|5||dddn #1swxYwY>dS)Ncd}||fd}t|}jjjjjj|dS)NFchK4d{V}ddddd{Vn#1d{VswxYwY|Srer)rEcalledcm_mocks ruse_context_managerzqAsyncContextManagerTest.test_mock_supports_async_context_manager..inner_test..use_context_managerps""""""""f!F""""""""""""""""""""""""""" s ! ++)rrrLryrrzr assertIsNot)rr'r cm_resultrrrs @@rrzTAsyncContextManagerTest.test_mock_supports_async_context_manager..inner_testksF--//BimmG       //1122I OOF # # # OOG.5 6 6 6 OOG-4 5 5 5   - - / / /   , , . . .   Wi 0 0 0 0 0rz!test context manager magics with rrs` r(test_mock_supports_async_context_managerz@AsyncContextManagerTest.test_mock_supports_async_context_managerjs 1 1 1 1 1($Y/ & &IM)MMNN & & 9%%% & & & & & & & & & & & & & & & & &rc|}t|t}|j_fd}|t ||dS)NchK4d{V}|cdddd{VS#1d{VswxYwYdSrr)rE mock_instances rrz^AsyncContextManagerTest.test_mock_customize_async_context_manager..use_context_managers$                                     s ! ++)rr rQryrprWr)rrexpected_resultrrs @r)test_mock_customize_async_context_managerzAAsyncContextManagerTest.test_mock_customize_async_context_managers|//11!(++  ((0?  -      c--//00/BBBBBrcddfd}fd}|}t||_|_fd}t |||dS)NFcKddSrer)r enter_calleds renter_coroutineziAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..enter_coroutinesLLLrcKddSrer)r exit_calleds rexit_coroutinezhAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..exit_coroutinesKKKrchK4d{V dddd{VdS#1d{VswxYwYdSrr)rsrrzmAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..use_context_managers$                                      s ! ++)rr ryrzrrL)rrrrrrrrs @@@r8test_mock_customize_async_context_manager_with_coroutinezPAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutines            //11!(++ #2  "0         ! !"""  %%%  $$$$$rcd}|}t|}|t5t ||ddddS#1swxYwYdS)NcZK|4d{Vt#1d{VswxYwYdSr) TypeError)context_managers rraise_inzYAsyncContextManagerTest.test_context_manager_raise_exception_by_default..raise_ins& " " " " " " " "kk! " " " " " " " " " " " " " " " "s  $$)rr rrr)rrrrs r/test_context_manager_raise_exception_by_defaultzGAsyncContextManagerTest.test_context_manager_raise_exception_by_defaults " " "//11!(++   y ) ) ) ) '' ( ( ( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )sA''A+.A+N) r,r-r.rrrrrrrrrrrrrDs99999999 22222222 &&& &&&4 C C C%%%4)))))rrc<eZdZGddeZdZdZdZdS)AsyncIteratorTestc eZdZdZdZdZdS)#AsyncIteratorTest.WithAsyncIteratorcgd|_dS)N)r NormalFoobaz)itemsrs rr z,AsyncIteratorTest.WithAsyncIterator.__init__s444DJJJrcdSrrrs rr|z-AsyncIteratorTest.WithAsyncIterator.__aiter__r!rc KdSrrrs rr{z-AsyncIteratorTest.WithAsyncIterator.__anext__r$rN)r,r-r.r r|r{rrrWithAsyncIteratorrs3 5 5 5 "!!'''''rrctdgdj_fd}t|}||gddS)NtesterrrLc,Kd2d{VS)Nc"Kg|3d{V}| 6Srr).0is r zOAsyncIteratorTest.test_aiter_set_return_value..main..s.////////A////sr) mock_itersrrz;AsyncIteratorTest.test_aiter_set_return_value..mains-//Y///////// /r)r r|rprrv)rrrErs @rtest_aiter_set_return_valuez-AsyncIteratorTest.test_aiter_set_return_valuesl8,,, +499 ( 0 0 0 0 0TTVV +++++rcfd}ttfD]=}d|5||dddn #1swxYwY>dS)Nc~}||}t|jt|jt|jt|jdSr)rrrr|rLr{)rrrrs rrzIAsyncIteratorTest.test_mock_aiter_and_anext_asyncmock..inner_tests--//H%Ih//M   01CDD E E E   01HII J J J OO/0BCC D D D OO/ 0GHH I I I I Irz%test aiter and anext corourtine with rrs` r#test_mock_aiter_and_anext_asyncmockz5AsyncIteratorTest.test_mock_aiter_and_anext_asyncmocks J J J J J$Y/ & &IQiQQRR & & 9%%% & & & & & & & & & & & & & & & & &rcdgdfd}fd}fd}ttfD]}d|5||dddn #1swxYwYd|5||dddn #1swxYwYd|5||dddn #1swxYwYdS) NcNKg}|23d{V}||6|Sr)append)iterator accumulatorrOs riteratez6AsyncIteratorTest.test_mock_async_for..iteratesWK& ) ) ) ) ) ) )d""4((((' s$)FOOBARBAZc|}t|gdSr)rrvr)rrrrs r test_defaultz;AsyncIteratorTest.test_mock_async_for..test_defaultsL%Id&<&<&>&>??M   S!7!788" = = = = =rc|}dd|j_t |dSr)rr|rprvrrrexpectedrrs rtest_set_return_valuezDAsyncIteratorTest.test_mock_async_for..test_set_return_values_%Id&<&<&>&>??M3;AAA;M # 0   S!7!788( C C C C Crc|}tdd|j_t |dSr)riterr|rprvrrs rtest_set_return_value_iterzIAsyncIteratorTest.test_mock_async_for..test_set_return_value_itersg%Id&<&<&>&>??M37 3D3DM # 0   S!7!788( C C C C Crzdefault value with zset return_value with zset return_value iterator with r)rrrrrrrs` @@rtest_mock_async_forz%AsyncIteratorTest.test_mock_async_fors:   )(( > > > > > >  D D D D D D D  D D D D D D D $Y/ 6 6I?I??@@ ( ( Y''' ( ( ( ( ( ( ( ( ( ( ( ( ( ( (ByBBCC 1 1%%i000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1K KKLL 6 6**9555 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s6 AA# &A#  BB !B = CC C N)r,r-r.rQrrrrrrrrrsk(((((F(((,,,&&&" 6 6 6 6 6rrceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdS)AsyncMockAssertc,t|_dSr)r rrs rsetUpzAsyncMockAssert.setUpsKK rc0K|j|i|d{VdSr)rrs r_runnable_testzAsyncMockAssert._runnable_tests5di((((((((((((rcK|d{VSrr)r coroutines r_await_coroutinez AsyncMockAssert._await_coroutinesrctt}t|5|dddn #1swxYwY|t |j|j|j|j| t5| dddn #1swxYwY| t5|j ddddS#1swxYwYdSr) r rrGr#rLr assert_calledassert_called_onceassert_called_once_withrrrrs r"test_assert_called_but_not_awaitedz2AsyncMockAssert.test_assert_called_but_not_awaiteds$$  % %                       +D,=>>??? ''))) ,,... 11333   ~ . . " "    ! ! ! " " " " " " " " " " " " " " "   ~ . . / /   , , . . . / / / / / / / / / / / / / / / / / /s5AA  A C==DD"E  E E ctt}|}|j|j|j|t5|jdddn #1swxYwYt| ||j|j|j |j dSr) r rr#rrrrrrrrrr)rrmock_coroutines rtest_assert_called_then_awaitedz/AsyncMockAssert.test_assert_called_then_awaitedsU$$**,, ''))) ,,... 11333   ~ . . / /   , , . . . / / / / / / / / / / / / / / / D ! !. 1 1222 ,,... ((*** --/// 2244444sB44B8;B8c|t5|jdddn #1swxYwY|t5|jdddn #1swxYwYt ||j|jdSr) rrrrrrrrrrs r+test_assert_called_and_awaited_at_same_timez;AsyncMockAssert.test_assert_called_and_awaited_at_same_time"sH   ~ . . ' ' I $ $ & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' '  ~ . . & & I # # % % % & & & & & & & & & & & & & & & D   ! !""" $$&&& %%'''''s#AAA&B  BBc<tt}|}t|5|dddn #1swxYwY|t 5|jdddn #1swxYwY|jt| ||j|j dSr) r rr#rGrrrrrrrrrrs r)test_assert_called_twice_and_awaited_oncez9AsyncMockAssert.test_assert_called_twice_and_awaited_once-sv$$%%''   % %                        ~ . . / /   , , . . . / / / / / / / / / / / / / / / ''))) D ! !) , ,--- ((*** --/////s#AA A>B$$B(+B(ctt}|}|jt |||t5t ||dddn #1swxYwY|jdSr) r rr#rrrrrrr s r)test_assert_called_once_and_awaited_twicez9AsyncMockAssert.test_assert_called_once_and_awaited_twice;s$$%%''  ,,... D ! !) , ,---   | , , 2 2 %%i00 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ((*****s>#B--B14B1c|t5|jdddn #1swxYwY|t5|jdddn #1swxYwY|t 5t ||jdddn #1swxYwY|t5|jdddn #1swxYwY|t5|jddddS#1swxYwYdSr)rrrrrrrrrs r"test_assert_awaited_but_not_calledz2AsyncMockAssert.test_assert_awaited_but_not_calledEs   ~ . . ' ' I $ $ & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' '   ~ . . & & I # # % % % & & & & & & & & & & & & & & &   y ) ) 2 2 %%di00 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2  ~ . . ' ' I $ $ & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' '   ~ . . & & I # # % % % & & & & & & & & & & & & & & & & & &sYAAA&B  BB1(C%%C),C) D00D47D4E<<FFcltdg}t|5|ddddn #1swxYwY|j||t 5|j|ddddS#1swxYwYdSNr)r rGrassert_has_callsrrrq)rkallss r test_assert_has_calls_not_awaitsz0AsyncMockAssert.test_assert_has_calls_not_awaitsSs(e   % %   IIe                   ""5)))   ~ . . / / I ' ' . . . / / / / / / / / / / / / / / / / / /s#AA AB))B-0B-cNt|5|dddn #1swxYwYddifg}||jj|t|5|ddddn #1swxYwYt|5|ddddn #1swxYwYt t dt dg}||jj|dS)Nrrr)rGrrv mock_callsr )r kalls_empty mock_kallss r0test_assert_has_mock_calls_on_async_mock_no_specz@AsyncMockAssert.test_assert_has_mock_calls_on_async_mock_no_spec[s  % %   IIKKK               B|n  -{;;;  % %   IIe                    % %   IIe                  vvtE{{DKK8  -z:::::s01551BBB-CCCctt}t|5|dddn #1swxYwYddifg}||jj|||jt jgt|5|ddddddddn #1swxYwYt t dddddg}t jt jdddddg}||jj|||j|dS) Nrrrnrrrtr0)r8r9)r rrGr#rvrr )r a_class_mockr method_kallsrs r2test_assert_has_mock_calls_on_async_mock_with_speczBAsyncMockAssert.test_assert_has_mock_calls_on_async_mock_with_spechs ,,  % % ( (  % % ' ' ' ( ( ( ( ( ( ( ( ( ( ( ( ( ( (B|n  2={KKK 043D3F3F2GHHH  % % 9 9  % %aAa % 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9Q1Q 7 7 78 '))4+&vx}.EFG> @ @ @ @ @s9==,B  BBcFfd}|jt5dddn #1swxYwYt5dddddn #1swxYwYt5ddddn #1swxYwYj|jtt}t5|dddn #1swxYwYt5|dddddn #1swxYwY|||dS)Ncd}|D]^}t||}|t|t|g_dS)N)rrr(r)getattrrcrlistrv)rnamesrattrrs r assert_attrsz:AsyncMockAssert.test_async_arg_lists..assert_attrssuDE + +tT**%%dI666%%dD111  r****  + +rrnrrrt)r8)rrGrr rr#)rr0rs` rtest_async_arg_listsz$AsyncMockAssert.test_async_arg_listss + + + + +  TY  % %   IIKKK                 % %   IIaOOO                 % %   IIINNN                 TY:&&  % % " "    ! ! ! " " " " " " " " " " " " " " "  % % ( (   Q  ' ' ' ( ( ( ( ( ( ( ( ( ( ( ( ( ( (  VsYAA A !BB BCCCD99D=D=E77E;>E;c|t5|jdddn #1swxYwYt ||jdSr)rrrrrrrs rtest_assert_awaitedz#AsyncMockAssert.test_assert_awaiteds   ~ . . ' ' I $ $ & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' D   ! !"""   """""sAAAc|t5|jdddn #1swxYwYt ||jt ||t5|jddddS#1swxYwYdSr)rrrrrrrs rtest_assert_awaited_oncez(AsyncMockAssert.test_assert_awaited_oncesU   ~ . . , , I ) ) + + + , , , , , , , , , , , , , , , D   ! !""" %%''' D   ! !"""   ~ . . , , I ) ) + + + , , , , , , , , , , , , , , , , , ,s#AAAC((C,/C,cd}|t|5|jddddn #1swxYwYt |d}|t|5|jddddn #1swxYwYt |d|jdt |d|t5|jdddddS#1swxYwYdS)Nz Not awaitedrzexpected await not found SomethingElse)r>rrrrrr)rmsgs rtest_assert_awaited_withz(AsyncMockAssert.test_assert_awaited_withs  # #NC 8 8 1 1 I ) )% 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 D   ! !"""(  # #NC 8 8 1 1 I ) )% 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 D   & &''' %%e,,, D   0 0111   ~ . . 1 1 I ) )% 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s5AA  A B55B9<B98E  E$'E$c|t5|jddddn #1swxYwYt |d|jdt |d|t5|jdddddS#1swxYwYdSr)rrrrrrrs rtest_assert_awaited_once_withz-AsyncMockAssert.test_assert_awaited_once_withs_   ~ . . 6 6 I . .u 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 D   & &''' **5111 D   & &'''   ~ . . 6 6 I . .u 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s#AA AC--C14C1cj|t5|jddddn #1swxYwYt |d|t5|jddddn #1swxYwYt |d|jdt |d|jddS)Nrrr7)rrrrrrrs rtest_assert_any_waitz$AsyncMockAssert.test_assert_any_waits   ~ . . . . I & &u - - - . . . . . . . . . . . . . . . D   & &'''   ~ . . . . I & &u - - - . . . . . . . . . . . . . . . D   & &''' ""5))) D   0 0111 ""5)))))s#AA A B00B47B4ctdtdg}|t5}|j|dddn #1swxYwY|t |jjdt| d|t5|j|dddn #1swxYwYt| d|t5|j|dddn #1swxYwYt| d|j|t| d|j|dS)Nrrrnr7) r rrrrqrvlen exceptionrrr)rcallsr's rtest_assert_has_awaits_no_orderz/AsyncMockAssert.test_assert_has_awaits_no_orders[ed5kk*   ~ . . /" I ' ' . . . / / / / / / / / / / / / / / / R\.//333 D   & &'''   ~ . . / / I ' ' . . . / / / / / / / / / / / / / / / D   & &'''   ~ . . / / I ' ' . . . / / / / / / / / / / / / / / / D   & &''' ##E*** D   0 0111 ##E*****s5A  A$'A$C;;C?C?E))E-0E-cRGdd}t||d|jt t dg|jt d|jt ddS)NceZdZdZdS)9AsyncMockAssert.test_awaits_asserts_with_any..FoocdSrrrothers r__eq__z@AsyncMockAssert.test_awaits_asserts_with_any..Foo.__eq__r!rNr,r-r.rIrrrFoorE ) ) ) ) )rrKrn)rrrrqr r rr)rrKs rtest_awaits_asserts_with_anyz,AsyncMockAssert.test_awaits_asserts_with_anys * * * * * * * * D  q ) )*** ##T#q\\N333 %%c1--- ""3*****rcLGdd}t|fd}t||dttdgtdtddS)NceZdZdZdS)BAsyncMockAssert.test_awaits_asserts_with_spec_and_any..FoocdSrrrGs rrIzIAsyncMockAssert.test_awaits_asserts_with_spec_and_any..Foo.__eq__r!rNrJrrrrKrPrLrrKrc"K|d{VdSrr)rmock_with_specs r_custom_mock_runnable_testzYAsyncMockAssert.test_awaits_asserts_with_spec_and_any.._custom_mock_runnable_tests, .$' ' ' ' ' ' ' ' ' 'rrn)r rrqr r rr)rrKrTrSs @r%test_awaits_asserts_with_spec_and_anyz5AsyncMockAssert.test_awaits_asserts_with_spec_and_anys * * * * * * * *#,,, ( ( ( ( ( & &ssuua 0 0111(($sA,,888**3222''Q/////rctdtdg}|t5|j|ddddn #1swxYwYt |d|t5|j|ddddn #1swxYwYt |d|t5|j|ddddn #1swxYwYt |d|j|dt |d|j|ddS)NrrT) any_orderbamfqux)r rrrrqrr)rrAs rtest_assert_has_awaits_orderedz.AsyncMockAssert.test_assert_has_awaits_ordered sVed5kk*   ~ . . ? ? I ' ' ' > > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? D   & &'''   ~ . . ? ? I ' ' ' > > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? D   ' '(((   ~ . . ? ? I ' ' ' > > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? D   & &''' ##ET#::: D   & &''' ##ET#:::::s5A""A&)A&)CCCEE Ec|jt||t 5|jddddS#1swxYwYdSr)rrrrrrrs rtest_assert_not_awaitedz'AsyncMockAssert.test_assert_not_awaiteds $$&&& D   ! !"""   ~ . . + + I ( ( * * * + + + + + + + + + + + + + + + + + +sA<<BBcdd}t||_t|d|t dtjd5}|j tgdddn #1swxYwY| |j j |t dtjd5}|j ttddgdddn #1swxYwY||j j tdS) Nc KdSrrr"s rfzIAsyncMockAssert.test_assert_has_awaits_not_matching_spec_error..f'r$rrrnz^{}$z6Awaits not found. Expected: [call()] Actual: [call(1)]zError processing expected awaits. Errors: [None, TypeError('too many positional arguments')] Expected: [call(), call(1, 2)] Actual: [call(1)]rrr)r rrrr>rformatreescaperqr rr@ __cause__rcr)rr_r's r.test_assert_has_awaits_not_matching_spec_errorz>AsyncMockAssert.test_assert_has_awaits_not_matching_spec_error&s!!!!1%%%  D   " "###  # # I2334455 2 9; I ' ' 1 1 1  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ",0111  # # I,--..// >35 I ' 'a(< = = = > > > > > > > > > > > > > > > bl4i@@@@@s$<(B00B47B47EE!$E!N)r,r-r.rrrrrr r rrrrr!r)r1r3r5r9r;r=rBrMrUrZr\rdrrrrrs   ))) / / /555 ( ( ( 0 0 0+++ & & &/// ; ; ; > > > @ @ @:### , , ,111" 6 6 6 * * *+++*+++ 0 0 0;;;&+++AAAAArr__main__)1rrDrWrar contextlibrrFrrequires_working_socketrrr unittest.mockr r r r r rrrrrrrr2r6r;r=rQr?r,r^rrGTestCaserIr|rrrrr*rwrrrrrrrrjsj  %%%%%%t,,,,,,,,,,,,,,,,,,GGGGGGGGGGGGGGGGGGGGGGGG((( * * * * * * * *+++&)))+++:A:A:A:A:Ah/:A:A:Az/////x(///d44444H%444BQQQQQ)QQQhf+f+f+f+f+H%f+f+f+R11111x(1118wHwHwHwHwH,wHwHwHt$?$?$?$?$?)$?$?$?Lo)o)o)o)o)h/o)o)o)dB6B6B6B6B6)B6B6B6JDADADADADAh'DADADAN  zHMOOOOOr