f _V@sddlZddlZddlZddlZddlZddlmZddlmZmZddlm Z ddl m Z m Z m Z mZmZmZmZmZmZddZGdd d ZGd d d Zd d ZddZddZGdddeZedZedZeddZGdddej Z!Gdddej Z"Gdddej Z#Gdddej Z$Gd d!d!ej Z%Gd"d#d#ej Z&Gd$d%d%e Z'Gd&d'd'ej Z(Gd(d)d)ej Z)Gd*d+d+ej Z*Gd,d-d-ej Z+dS).N)contextmanager)runiscoroutinefunction)IsolatedAsyncioTestCase) ANYcall AsyncMockpatch MagicMockMockcreate_autospecsentinel _CallListcCstddSN)asyncioZset_event_loop_policyrr9/usr/lib64/python3.10/unittest/test/testmock/testasync.pytearDownModulesrc@s<eZdZddZddZddZeddZed d Z d S) AsyncClasscCsdSrrselfrrr__init__zAsyncClass.__init__csdSrrrrrr async_methodrzAsyncClass.async_methodcCsdSrrrrrr normal_methodrzAsyncClass.normal_methodcsdSrr)clsrrrasync_class_methodszAsyncClass.async_class_methodcsdSrrrrrrasync_static_methodszAsyncClass.async_static_methodN) __name__ __module__ __qualname__rrr classmethodr staticmethodrrrrrrs rc@seZdZddZdS)AwaitableClassccs dVdSrrrrrr __await__rzAwaitableClass.__await__N)rrr r$rrrrr#sr#csdSrrrrrr async_func!rr%csdSrr)abcrrrasync_func_args#rr)cCsdSrrrrrr normal_func%rr*c@seZdZddZdS) NormalClasscCsdSrrrrrrr&(rz NormalClass.aN)rrr r&rrrrr+'sr+z .AsyncClassz .NormalClassccs>|tddVtWdn1s00YdS)Nzwas never awaited$)ZassertWarnsRegexRuntimeWarninggcZcollect)testrrrassertNeverAwaited/sr/c@s<eZdZddZddZddZddZd d Zd d Zd S)AsyncPatchDecoratorTestcs"ttdfdd}|dS)Nrcst|dSr) assertTruer mock_methodrrr test_async:szLAsyncPatchDecoratorTest.test_is_coroutine_function_patch..test_asyncr objectrrr4rrr test_is_coroutine_function_patch9s z8AsyncPatchDecoratorTest.test_is_coroutine_function_patchcsBttdfdd}ttdfdd}||dS)Nrcs"|}t|t|dSrr1inspect isawaitablerr3mrrrr4@sz?AsyncPatchDecoratorTest.test_is_async_patch..test_asyncz .async_methodcs"|}t|t|dSrr9r<rrrtest_no_parent_attributeFszMAsyncPatchDecoratorTest.test_is_async_patch..test_no_parent_attribute)r r6rasync_foo_name)rr4r>rrrtest_is_async_patch?s   z+AsyncPatchDecoratorTest.test_is_async_patchcs"ttdfdd}|dS)Nrcs|tdSrassertIsInstancerr2rrrr4PszCAsyncPatchDecoratorTest.test_is_AsyncMock_patch..test_asyncr5r7rrrtest_is_AsyncMock_patchOs z/AsyncPatchDecoratorTest.test_is_AsyncMock_patchcs"ttdfdd}|dS)Nrcs|tdSrrAr2rrrr4WszPAsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethod..test_asyncr5r7rrr$test_is_AsyncMock_patch_staticmethodVs z.test_asyncr5r7rrr#test_is_AsyncMock_patch_classmethod]s z;AsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethodcsNttdddttdddfdd}t|ttdS)N .async_func return_value.async_func_argscsh|jd|jdtttttIdHdtddddIdHddS)Nr)r%rGrKr() assertEqualZ _mock_namerBr%rr))Zfunc_args_mockZ func_mockrrrr4es   z@AsyncPatchDecoratorTest.test_async_def_patch..test_async)r rrr1r:rr%r7rrrtest_async_def_patchds  z,AsyncPatchDecoratorTest.test_async_def_patchN) rrr r8r@rCrDrErOrrrrr08s r0c@s,eZdZddZddZddZddZd S) AsyncPatchCMTestcsfdd}|dS)Ncs>ttd}t|Wdn1s00YdSNr)r r6rr1rr2rrrr4wsz>AsyncPatchCMTest.test_is_async_function_cm..test_asyncrr7rrrtest_is_async_function_cmvs z*AsyncPatchCMTest.test_is_async_function_cmcsfdd}|dS)NcsNttd.}|}t|t|Wdn1s@0YdSrQ)r r6rr1r:r;rr<rrrr4~sz5AsyncPatchCMTest.test_is_async_cm..test_asyncrr7rrrtest_is_async_cm}s z!AsyncPatchCMTest.test_is_async_cmcsfdd}|dS)Ncs<ttd}|tWdn1s.0YdSrQ)r r6rrBrr2rrrr4sz9AsyncPatchCMTest.test_is_AsyncMock_cm..test_asyncrr7rrrtest_is_AsyncMock_cms z%AsyncPatchCMTest.test_is_AsyncMock_cmcsfdd}t|dS)NcsRttdtttWdn1s40YttdS)NrF)r rrrBr%r1r:rrrrrr4s*z6AsyncPatchCMTest.test_async_def_cm..test_asyncrr7rrrtest_async_def_cms z"AsyncPatchCMTest.test_async_def_cmN)rrr rRrSrTrVrrrrrPus rPc@s4eZdZddZddZddZddZd d Zd S) AsyncMockTestcCst}|t|dSr)rr1rrmockrrr test_iscoroutinefunction_defaultsz.AsyncMockTest.test_iscoroutinefunction_defaultcCs2dd}t|}|t||t|dS)NcsdSrrrrrrfoorz.foorr1rr:rr[rYrrr!test_iscoroutinefunction_functionsz/AsyncMockTest.test_iscoroutinefunction_functioncCs8t}|}|t|t||dt|dS)Nassert_awaited)rr1r:r;rZassertIndirrrYr=rrrtest_isawaitables zAsyncMockTest.test_isawaitablecCs2dd}t|}|t||t|dS)NcSsdSrrrrrrr[rzCAsyncMockTest.test_iscoroutinefunction_normal_function..foor\r]rrr(test_iscoroutinefunction_normal_functionsz6AsyncMockTest.test_iscoroutinefunction_normal_functioncCsDt}t|t}||t|}||tjdSr)rZnew_event_loopZset_event_loopFuturestopcloserrB)rZloopfutrYrrrtest_future_isfutures z"AsyncMockTest.test_future_isfutureN)rrr rZr^rbrcrhrrrrrWs rWc@s4eZdZddZddZddZddZd d Zd S) AsyncAutospecTestcs@ttddfdd}ttddfdd}||dS)NTZautospeccs|jt|tdSrrBrrr r2rrrr4sz=AsyncAutospecTest.test_is_AsyncMock_patch..test_asynccs|jtdSr)rBrr r2rrrtest_normal_methodszEAsyncAutospecTest.test_is_AsyncMock_patch..test_normal_methodr r?)rr4rlrrrrCs   z)AsyncAutospecTest.test_is_AsyncMock_patchcCs:|tttddWdn1s,0YdS)NT)instance) assertRaises RuntimeErrorr r%rrrrtest_create_autospec_instances z/AsyncAutospecTest.test_create_autospec_instancecCs ttd}|t|tdSNspec)r r#rBr)rZawaitable_mockrrr$test_create_autospec_awaitable_classs z6AsyncAutospecTest.test_create_autospec_awaitable_classcs&tt}|ddddfdd}||jd||j||jg|t|| t || t ||jd||jt dddd||jt ddddg||jdddd|jdddd||t|jddWdn1s0YdS) NrGrKrLrMcsIdHdSrrr awaitablerrmainsz4AsyncAutospecTest.test_create_autospec..mainr)e)r r)rN await_count assertIsNone await_argsawait_args_listassert_not_awaitedrr1rr iscoroutinerassert_awaited_onceassert_awaited_once_withassert_awaited_withr_roAssertionErrorassert_any_await)rrtrxrrvrtest_create_autospecs&    z&AsyncAutospecTest.test_create_autospeccsfdd}t|dS)NcsZttddd}|dddd}|jtt|t|t | |j d |j g|j||IdHWdn1s0Y |j d |jtdddd |j tddddg||jdddd|jdddd|| |j d|j |j gdS) NrJTrjrGrKrLrMr)r rrBrYrr1rrrr:r;rNrzr}r{r|r~rrrrr_ reset_mock)r3rwrrrr4s, ( z>AsyncAutospecTest.test_patch_with_autospec..test_asyncrUr7rrrtest_patch_with_autospecs z*AsyncAutospecTest.test_patch_with_autospecN)rrr rCrqrurrrrrrris  ric@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS) AsyncSpecTestc sVfdd}ttfD]<}d|||Wdq1sF0YqdS)Ncs(|t}|jt|jtdSr)rrBrrrr ) mock_typerYrrr inner_testszCAsyncSpecTest.test_spec_normal_methods_on_class..inner_testztest method types with rr subTestrrrrrr!test_spec_normal_methods_on_class s  z/AsyncSpecTest.test_spec_normal_methods_on_classcCs(tt}||jt||jtdSr)r rrBrrrrXrrr+test_spec_normal_methods_on_class_with_mocksz9AsyncSpecTest.test_spec_normal_methods_on_class_with_mockc sXfdd}tttfD]<}d|||Wdq1sH0YqdS)Ncsj|td}||t"t|Wdn1sF0Y|td}||dSrrr%rBr/r1r:r;r*r async_mockZ sync_mockrrrrs    0 z8AsyncSpecTest.test_spec_mock_type_kw..inner_testztest spec kwarg with rr r rrrrrtest_spec_mock_type_kws z$AsyncSpecTest.test_spec_mock_type_kwc sXfdd}tttfD]<}d|||Wdq1sH0YqdS)Ncsf|t}||t"t|Wdn1sD0Y|t}||dSrrrrrrr+s   0z@AsyncSpecTest.test_spec_mock_type_positional..inner_testztest spec positional with rrrrrtest_spec_mock_type_positional*s z,AsyncSpecTest.test_spec_mock_type_positionalcCs8ttd}||t|}|t|t|dSrrrr*rBr1r:r;rrarrr test_spec_as_normal_kw_AsyncMock8s   z.AsyncSpecTest.test_spec_as_normal_kw_AsyncMockcCs6tt}||t|}|t|t|dSrrrarrr(test_spec_as_normal_positional_AsyncMock?s  z6AsyncSpecTest.test_spec_as_normal_positional_AsyncMockcs&tjtdddfdd}|dS)NrTrscs|tdSrrAr2rrrr4Gsz6AsyncSpecTest.test_spec_async_mock..test_asyncr5r7rrrtest_spec_async_mockFsz"AsyncSpecTest.test_spec_async_mockcs"ttddfdd}|dS)NTrscs|t|jtdSr)rBr rrr2rrrr4Ns zIAsyncSpecTest.test_spec_parent_not_async_attribute_is..test_asyncrmr7rrr'test_spec_parent_not_async_attribute_isMs z5AsyncSpecTest.test_spec_parent_not_async_attribute_iscs(tjtdtjdfdd}|dS)Nrrscs0|tt|t|dSr)rBr assertFalser:rr;r2rrrtest_async_attributeVs zFAsyncSpecTest.test_target_async_spec_not..test_async_attribute)r r6rr+r&)rrrrrtest_target_async_spec_notUsz(AsyncSpecTest.test_target_async_spec_notcs&tjtdtdfdd}|dS)Nr&rscs|tdSrrA)Zmock_async_funcrrr test_attribute_not_async_spec_is_szUAsyncSpecTest.test_target_not_async_spec_is..test_attribute_not_async_spec_is)r r6r+r%)rrrrrtest_target_not_async_spec_is^sz+AsyncSpecTest.test_target_not_async_spec_iscs"tttdfdd}|dS)Nrscs|jt|tdSrrk)ZMockNormalClassrrr test_async_attributes_coroutineseszRAsyncSpecTest.test_spec_async_attributes..test_async_attributes_coroutines)r normal_foo_namer)rrrrrtest_spec_async_attributesds z(AsyncSpecTest.test_spec_async_attributesN)rrr rrrrrrrrrrrrrrrr s  rc@s,eZdZddZddZddZddZd S) AsyncSpecSetTestcs&tjtdddfdd}|dS)NrTZspec_setcs|tdSrrA)rrrrr4osz.test_asyncr5r7rrrrCnsz(AsyncSpecSetTest.test_is_AsyncMock_patchcCs*ttjd}|t|||tdSNr)rrrr1rrBrXrrrtest_is_async_AsyncMockts z(AsyncSpecSetTest.test_is_async_AsyncMockcCsVttd}|t|j|t|j||jt||jt||tdSr) r rr1rrrrrBrrXrrrtest_is_child_AsyncMockys  z(AsyncSpecSetTest.test_is_child_AsyncMockcCsRt}tddd|_t|d}||tWdn1sD0YdS)NcSs|Srrxrrrrz=AsyncSpecSetTest.test_magicmock_lambda_spec..rs mock_func)r rr r6rB)rZmock_objcmrrrtest_magicmock_lambda_specsz+AsyncSpecSetTest.test_magicmock_lambda_specN)rrr rCrrrrrrrrmsrc@steZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZdS)AsyncArgumentscs2dd}t|dd}|dIdH}||ddS)NcsdSrr)rvarrrradditionrz6AsyncArguments.test_add_return_value..addition rHrrN)rrrYoutputrrrtest_add_return_values z$AsyncArguments.test_add_return_valuecsTdd}t|tdd}|t|dIdHWdn1sF0YdS)NcsdSrrrrrrrrz?AsyncArguments.test_add_side_effect_exception..additionerrZ side_effectr)r Exceptionro)rrrYrrrtest_add_side_effect_exceptions z-AsyncArguments.test_add_side_effect_exceptioncs0dd}t|d}|dIdH}||ddS)Ncs|dSNrGrrrrrrsz?AsyncArguments.test_add_side_effect_coroutine..additionrrrrrrYresultrrrtest_add_side_effect_coroutines z-AsyncArguments.test_add_side_effect_coroutinecs0dd}t|d}|dIdH}||ddS)NcSs|dSrrrrrrrszEAsyncArguments.test_add_side_effect_normal_function..additionrrrrrrrr$test_add_side_effect_normal_functions z3AsyncArguments.test_add_side_effect_normal_functioncsjgd}t|d}|D]}||IdH|q|t}|IdHWdn1s\0YdS)NrGrKrLr)rrNroStopAsyncIteration)rvalsrYitemryrrrtest_add_side_effect_iterables   z,AsyncArguments.test_add_side_effect_iterablecstGdddt}d|dg}t|d}||IdHd||}|IdHWdn1sf0YdS)Nc@s eZdZdS)zOAsyncArguments.test_add_side_effect_exception_iterable..SampleExceptionN)rrr rrrrSampleExceptionsrrGr[r)rrrNro)rrrrYryrrr'test_add_side_effect_exception_iterables    z6AsyncArguments.test_add_side_effect_exception_iterablecs0tdd}t|d}|IdH}|||dS)NrrH)rassertIs)rvaluerYrrrrtest_return_value_AsyncMocks   z*AsyncArguments.test_return_value_AsyncMockcs:t}|dt|d}|IdH}||tjdS)NrH)rrd set_resultrrBrrgrYrrrrtest_return_value_awaitables    z*AsyncArguments.test_return_value_awaitablecsrt}|dt|gd}|IdH}||tj|t|IdHWdn1sd0YdS)Nr)rrdrrrBrorrrrr!test_side_effect_awaitable_valuess    z0AsyncArguments.test_side_effect_awaitable_valuescs0tdd}t|d}|IdH}||ddS)NrrHrr)rZeffectrYrrrrtest_side_effect_is_AsyncMocks   z,AsyncArguments.test_side_effect_is_AsyncMockcsRtdfdd}t|d}|IdH}||||dS)NFcsdSNTrrZranrrrinnersz2AsyncArguments.test_wraps_coroutine..innerwraps)rrdrrNr_r1rrrYrrrrtest_wraps_coroutines   z#AsyncArguments.test_wraps_coroutinecsNddfdd}t|d}|IdH}||||dS)NrGFcsdSrrrrrrrsz8AsyncArguments.test_wraps_normal_function..innerr)rrNr_r1rrrrtest_wraps_normal_functions   z)AsyncArguments.test_wraps_normal_functioncsxt}|d}|d}|IdH|IdH|tdtdg||jtdtdg||jtdtdgdS)NrKrG)rassert_has_awaitsrrNr}call_args_list)rrZmock2Zmock1rrrtest_await_args_list_orders  z)AsyncArguments.test_await_args_list_orderN)rrr rrrrrrrrrrrrrrrrrrs   rc@s4eZdZddZddZddZddZd d Zd S) AsyncMagicMethodscCsBt}||jt||jt||jt||jtdSr)r rB __aenter__r __aexit__ __anext__ __aiter__rZm_mockrrr+test_async_magic_methods_return_async_mockss z=AsyncMagicMethods.test_async_magic_methods_return_async_mockscCsBt}||jt||jt||jt||jtdSr)rrB __enter__r __exit____next____len__ra_mockrrr*test_sync_magic_methods_return_magic_mocks s z.inner_testz%test set return value of aenter with rrrrrtest_set_return_value_of_aenter>s z7AsyncContextManagerTest.test_set_return_value_of_aenterc sVfdd}ttfD]<}d|||Wdq1sF0YqdS)Ncsvd}||fdd}t|}jjjjjj|dS)NFc s@4IdH}dWdIdHq<1IdHs20Y|SrrrcalledZcm_mockrruse_context_managerTs.zqAsyncContextManagerTest.test_mock_supports_async_context_manager..inner_test..use_context_manager)rrr1rrrr_Z assertIsNot)rrrZ cm_resultrrrrOs    zTAsyncContextManagerTest.test_mock_supports_async_context_manager..inner_testz!test context manager magics with rrrrr(test_mock_supports_async_context_managerNs  z@AsyncContextManagerTest.test_mock_supports_async_context_managercs@|}t|t}|j_fdd}|t||dS)Nc s@4IdH}|WdIdHS1IdHs20YdSrrr mock_instancerrrosz^AsyncContextManagerTest.test_mock_customize_async_context_manager..use_context_manager)rr r6rrIrr)rrnZexpected_resultrrrr)test_mock_customize_async_context_managerhs  zAAsyncContextManagerTest.test_mock_customize_async_context_managercsjddfdd}fdd}|}t||_|_fdd}t|||dS)NFcsddSrrr) enter_calledrrenter_coroutineysziAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..enter_coroutinecsddSrrr) exit_calledrrexit_coroutine}szhAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..exit_coroutinec s<4IdHWdIdHq81IdHs.0YdSrrrrrrrszmAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..use_context_manager)rr rrrr1)rrr rnrr)rrrr8test_mock_customize_async_context_manager_with_coroutineus     zPAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutinecCsRdd}|}t|}|tt||Wdn1sD0YdS)Nc sB|4IdHtWdIdHq>1IdHs40YdSr) TypeError)Zcontext_managerrrrraise_inszYAsyncContextManagerTest.test_context_manager_raise_exception_by_default..raise_in)rr ror r)rr rnrrrr/test_context_manager_raise_exception_by_defaults  zGAsyncContextManagerTest.test_context_manager_raise_exception_by_defaultN) rrr rrrrrrr r rrrrr(s  rc@s4eZdZGdddeZddZddZddZd S) AsyncIteratorTestc@s$eZdZddZddZddZdS)z#AsyncIteratorTest.WithAsyncIteratorcCsgd|_dS)N)r[Z NormalFoobaz)itemsrrrrrsz,AsyncIteratorTest.WithAsyncIterator.__init__cCsdSrrrrrrrrz-AsyncIteratorTest.WithAsyncIterator.__aiter__csdSrrrrrrrrz-AsyncIteratorTest.WithAsyncIterator.__anext__N)rrr rrrrrrrWithAsyncIteratorsrcs@tddgdj_fdd}t|}||gddS)NZtesterrrcsdd2IdHS)Ncsg|z3dHW}|q6Srr).0irrr rzOAsyncIteratorTest.test_aiter_set_return_value..main..rrZ mock_iterrrrxsz;AsyncIteratorTest.test_aiter_set_return_value..main)rrrIrrN)rrxrrrrtest_aiter_set_return_values     z-AsyncIteratorTest.test_aiter_set_return_valuec sVfdd}ttfD]<}d|||Wdq1sF0YqdS)NcsT}||}t|jt|jt|jt|jdSr)rrrrr1r)rrnrrrrrs zIAsyncIteratorTest.test_mock_aiter_and_anext_asyncmock..inner_testz%test aiter and anext corourtine with rrrrr#test_mock_aiter_and_anext_asyncmocks z5AsyncIteratorTest.test_mock_aiter_and_anext_asyncmockc sddgdfdd}fdd}fdd }ttfD]}d |||Wdn1sx0Yd |||Wdn1s0Yd |||WdqF1s0YqFdS) Ncs&g}|2z3dHW}||q6|Sr)append)iteratorZ accumulatorrrrriteratesz6AsyncIteratorTest.test_mock_async_for..iterate)ZFOOZBARZBAZcs$|}t|gdSr)rrNrrr)rrrr test_defaults z;AsyncIteratorTest.test_mock_async_for..test_defaultcs4|}dd|j_t|dSr)rrrIrNrrZexpectedrrrrtest_set_return_values zDAsyncIteratorTest.test_mock_async_for..test_set_return_valuecs8|}tdd|j_t|dSr)riterrrIrNrrrrrtest_set_return_value_iters zIAsyncIteratorTest.test_mock_async_for..test_set_return_value_iterzdefault value with zset return_value with zset return_value iterator with r)rrrr rrrrtest_mock_async_fors &&z%AsyncIteratorTest.test_mock_async_forN)rrr r6rrrr!rrrrrsrc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3S)4AsyncMockAssertcCs t|_dSr)rrYrrrrsetUpszAsyncMockAssert.setUpcs|j|i|IdHdSr)rYrrrr_runnable_testszAsyncMockAssert._runnable_testcs |IdHSrr)r coroutinerrr_await_coroutinesz AsyncMockAssert._await_coroutinecCstt}t||Wdn1s.0Y|t|j|j|j|j| t | Wdn1s0Y| t |j Wdn1s0YdSr) rrr/rr1r assert_calledassert_called_onceassert_called_once_withrorr_rXrrr"test_assert_called_but_not_awaiteds &    & z2AsyncMockAssert.test_assert_called_but_not_awaitedcCstt}|}|j|j|j|t|jWdn1sX0Yt | ||j|j|j |j dSr) rrrr'r(r)rorr_rr&rr)rrYZmock_coroutinerrrtest_assert_called_then_awaiteds    (   z/AsyncMockAssert.test_assert_called_then_awaitedcCs|t|jWdn1s*0Y|t|jWdn1s^0Yt||j|jdSr) rorrYr_r'rr$r(rrrrr+test_assert_called_and_awaited_at_same_times ( (  z;AsyncMockAssert.test_assert_called_and_awaited_at_same_timecCstt}|}t||Wdn1s60Y|t|jWdn1sj0Y|jt| ||j|j dSr) rrrr/rorr_r'rr&rrrYr%rrr)test_assert_called_twice_and_awaited_onces & (  z9AsyncMockAssert.test_assert_called_twice_and_awaited_oncecCsntt}|}|jt|||tt||Wdn1sV0Y|jdSr) rrrr(rr&rorpr_r-rrr)test_assert_called_once_and_awaited_twices  ,z9AsyncMockAssert.test_assert_called_once_and_awaited_twicecCs|t|jWdn1s*0Y|t|jWdn1s^0Y|t t||jWdn1s0Y|t|jWdn1s0Y|t|jWdn1s0YdSr)rorrYr_r'r rr&rrrr"test_assert_awaited_but_not_called)s ( ( . ( z2AsyncMockAssert.test_assert_awaited_but_not_calledcCstdg}t||dWdn1s20Y|j||t|j|Wdn1st0YdSNr[)rr/rYZassert_has_callsrorr)rZkallsrrr test_assert_has_calls_not_awaits7s   (  z0AsyncMockAssert.test_assert_has_calls_not_awaitscCst||Wdn1s&0Yddifg}||jj|t||dWdn1st0Yt||dWdn1s0Yttdtdg}||jj|dS)Nrr[r)r/rYrN mock_callsr)r kalls_empty mock_kallsrrr0test_assert_has_mock_calls_on_async_mock_no_spec?s &  ( (z@AsyncMockAssert.test_assert_has_mock_calls_on_async_mock_no_speccCstt}t||Wdn1s.0Yddifg}||jj|||jtgt|$|jddddddWdn1s0Yttddddddg}ttjddddddg}||jj|||j|dS) Nr3rrGrKrLr)r&r')rrr/rrNr4r)rZ a_class_mockr5Z method_kallsr6rrr2test_assert_has_mock_calls_on_async_mock_with_specLs &  2zBAsyncMockAssert.test_assert_has_mock_calls_on_async_mock_with_speccCst| |jjdddWdn1s.0Yt|$|jjjdtjdWdn1sj0Y||jjddddifdd d tjifgd ||jjjdd d tjifgd dS) NrL)fishr)cake something)rLr:zsomething_else.something)rr;z#method calls not recorded correctly)r/rYr<Zsomething_elser ZCakerN method_callsrrrr test_async_method_calls_recorded[s . 2   z0AsyncMockAssert.test_async_method_calls_recordedcsFfdd}|jtWdn1s<0YtddWdn1sp0YtjddWdn1s0Yj|jtt}t|Wdn1s0Yt|jdddWdn1s(0Y|||dS)Ncs@d}|D]2}t||}|t|t|gqdS)N)rr=r4)getattrrBrlistrN)rYnamesrattrrrr assert_attrsks    z:AsyncMockAssert.test_async_arg_lists..assert_attrsrGrKrL)r&)rYr/rrrr)rrCrrrrtest_async_arg_listsjs"   & * *   & .z$AsyncMockAssert.test_async_arg_listscCsN|t|jWdn1s*0Yt||jdSr)rorrYr_rr$rrrrtest_assert_awaiteds ( z#AsyncMockAssert.test_assert_awaitedcCs|t|jWdn1s*0Yt||jt||t|jWdn1s0YdSr)rorrYrrr$rrrrtest_assert_awaited_onces (    z(AsyncMockAssert.test_assert_awaited_oncecCsd}|t||jdWdn1s20Yt|d}|t||jdWdn1sz0Yt|d|jdt|d|t|jdWdn1s0YdS)Nz Not awaitedr[zexpected await not found SomethingElse)assertRaisesRegexrrYrrr$ro)rmsgrrrtest_assert_awaited_withs* *  z(AsyncMockAssert.test_assert_awaited_withcCs|t|jdWdn1s,0Yt|d|jdt|d|t|jdWdn1s0YdSr1)rorrYrrr$rrrrtest_assert_awaited_once_withs *  z-AsyncMockAssert.test_assert_awaited_once_withcCs|t|jdWdn1s,0Yt|d|t|jdWdn1sp0Yt|d|jdt|d|jddS)Nr[rrG)rorrYrrr$rrrrtest_assert_any_waits * * z$AsyncMockAssert.test_assert_any_waitcCstdtdg}|t}|j|Wdn1s<0Y|t|jjdt | d|t|j|Wdn1s0Yt | d|t|j|Wdn1s0Yt | d|j|t | d|j|dS)Nr[rrGrG) rrorrYrrNlen exceptionrrr$)rcallsrrrrtest_assert_has_awaits_no_orders * * * z/AsyncMockAssert.test_assert_has_awaits_no_ordercCsTGddd}t||d|jttdg|jtd|jtddS)Nc@seZdZddZdS)z9AsyncMockAssert.test_awaits_asserts_with_any..FoocSsdSrrrotherrrr__eq__rz@AsyncMockAssert.test_awaits_asserts_with_any..Foo.__eq__Nrrr rSrrrrFoosrUrG)rr$rYrrrrr)rrUrrrtest_awaits_asserts_with_anys z,AsyncMockAssert.test_awaits_asserts_with_anycsbGddd}t|dfdd}t||dttdgtdtddS)Nc@seZdZddZdS)zBAsyncMockAssert.test_awaits_asserts_with_spec_and_any..FoocSsdSrrrQrrrrSrzIAsyncMockAssert.test_awaits_asserts_with_spec_and_any..Foo.__eq__NrTrrrrrUsrUrscs|IdHdSrrrZmock_with_specrr_custom_mock_runnable_testszYAsyncMockAssert.test_awaits_asserts_with_spec_and_any.._custom_mock_runnable_testrG)rrrrrrr)rrUrXrrWr%test_awaits_asserts_with_spec_and_anys   z5AsyncMockAssert.test_awaits_asserts_with_spec_and_anycCstdtdg}|t |jj|ddWdn1s@0Yt|d|t |jj|ddWdn1s0Yt|d|t |jj|ddWdn1s0Yt|d|jj|ddt|d|jj|dddS)Nr[rT)Z any_orderZbamfZqux)rrorrYrrr$)rrOrrrtest_assert_has_awaits_ordereds . . .z.AsyncMockAssert.test_assert_has_awaits_orderedcCsN|jt||t|jWdn1s@0YdSr)rYr~rr$rorrrrrtest_assert_not_awaiteds   z'AsyncMockAssert.test_assert_not_awaitedcCsd dd}t|d|_t|d|tdtd }|j t gWdn1sb0Y| |j j |tdtd(}|j t t ddgWdn1s0Y||j j tdS) NcsdSrrrrrrf rzIAsyncMockAssert.test_assert_has_awaits_not_matching_spec_error..frsrGz^{}$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)]rK)N)rrYrr$rHrformatreescaperrr{rN __cause__rBr )rr\rrrr.test_assert_has_awaits_not_matching_spec_error s.  .6z>AsyncMockAssert.test_assert_has_awaits_not_matching_spec_errorN)rrr r#r$r&r*r+r,r.r/r0r2r7r9r>rDrErFrJrKrLrPrVrYrZr[rarrrrr"s2       r"),rr-r:r^Zunittest contextlibrrrrZ unittest.mockrrrr r r r r rrrr#r%r)r*r6r+rr?rr/ZTestCaser0rPrWrirrrrrrr"rrrrs<  ,    =!"Tay&rE