f _Vc@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.pytearDownModulerc@s<eZdZddZddZddZeddZed d Z d S) AsyncClasscCdSrrselfrrr__init__zAsyncClass.__init__crrrrrrr async_methodrzAsyncClass.async_methodcCrrrrrrr normal_methodrzAsyncClass.normal_methodcrrr)Zclsrrrasync_class_methodrzAsyncClass.async_class_methodcrrrrrrrasync_static_methodrzAsyncClass.async_static_methodN) __name__ __module__ __qualname__rrrZ classmethodrZ staticmethodrrrrrrs rc@eZdZddZdS)AwaitableClassccs dVdSrrrrrr __await__rzAwaitableClass.__await__N)rrr r#rrrrr"r"crrrrrrr async_func!rr%crrr)abcrrrasync_func_args#rr)cCrrrrrrr normal_func%rr*c@r!) NormalClasscCrrrrrrrr&(rz NormalClass.aN)rrr r&rrrrr+'r$r+z .AsyncClassz .NormalClassccs>|tddVtWdn1s00YdS)Nzwas never awaited$)ZassertWarnsRegexZRuntimeWarninggcZcollect)ZtestrrrassertNeverAwaited/sr-c@s<eZdZddZddZddZddZd d Zd d Zd S)AsyncPatchDecoratorTestc"ttdfdd}|dS)Nrcst|dSr) assertTruer mock_methodrrr test_async:zLAsyncPatchDecoratorTest.test_is_coroutine_function_patch..test_asyncrobjectrrr3rrr test_is_coroutine_function_patch9s z8AsyncPatchDecoratorTest.test_is_coroutine_function_patchcsBttdfdd}ttdfdd}||dS)Nrc"|}t|t|dSrr0inspect isawaitablerr2mrrrr3@z?AsyncPatchDecoratorTest.test_is_async_patch..test_asyncz .async_methodcr9rr:r=rrrtest_no_parent_attributeFr?zMAsyncPatchDecoratorTest.test_is_async_patch..test_no_parent_attribute)rr6rasync_foo_name)rr3r@rrrtest_is_async_patch?s   z+AsyncPatchDecoratorTest.test_is_async_patchcr/)Nrc|tdSrassertIsInstancerr1rrrr3Pr4zCAsyncPatchDecoratorTest.test_is_AsyncMock_patch..test_asyncr5r7rrrtest_is_AsyncMock_patchO z/AsyncPatchDecoratorTest.test_is_AsyncMock_patchcr/)NrcrCrrDr1rrrr3Wr4zPAsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethod..test_asyncr5r7rrr$test_is_AsyncMock_patch_staticmethodVrGz.test_asyncr5r7rrr#test_is_AsyncMock_patch_classmethod]rGz;AsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethodcsNttdddttdddfdd}t|ttdS)N .async_func return_value.async_func_argscsh|jd|jdtttttIdHdtddddIdHddS)Nr)r%rKrOr() assertEqualZ _mock_namerEr%rr))Zfunc_args_mockZ func_mockrrrr3es   z@AsyncPatchDecoratorTest.test_async_def_patch..test_async)rrrr0r;rr%r7rrrtest_async_def_patchds  z,AsyncPatchDecoratorTest.test_async_def_patchN) rrr r8rBrFrHrIrSrrrrr.8s r.c@,eZdZddZddZddZddZd S) AsyncPatchCMTestcfdd}|dS)Ncs>ttd}t|Wdn1s00YdSNr)rr6rr0rr1rrrr3wz>AsyncPatchCMTest.test_is_async_function_cm..test_asyncrr7rrrtest_is_async_function_cmv z*AsyncPatchCMTest.test_is_async_function_cmcrV)NcsNttd.}|}t|t|Wdn1s@0YdSrW)rr6rr0r;r<rr=rrrr3~sz5AsyncPatchCMTest.test_is_async_cm..test_asyncrr7rrrtest_is_async_cm}s z!AsyncPatchCMTest.test_is_async_cmcrV)Ncs<ttd}|tWdn1s.0YdSrW)rr6rrErr1rrrr3rXz9AsyncPatchCMTest.test_is_AsyncMock_cm..test_asyncrr7rrrtest_is_AsyncMock_cmrZz%AsyncPatchCMTest.test_is_AsyncMock_cmcfdd}t|dS)NcsRttdtttWdn1s40YttdS)NrJ)rrrrEr%r0r;rrrrrr3s*z6AsyncPatchCMTest.test_async_def_cm..test_asyncrr7rrrtest_async_def_cms z"AsyncPatchCMTest.test_async_def_cmN)rrr rYr[r\r_rrrrrUus rUc@4eZdZddZddZddZddZd d Zd S) AsyncMockTestcCst}|t|dSr)rr0rrmockrrr test_iscoroutinefunction_defaultsz.AsyncMockTest.test_iscoroutinefunction_defaultcC2dd}t|}|t||t|dS)Ncrrrrrrrfoorz.foorr0rr;rrfrcrrr!test_iscoroutinefunction_functionz/AsyncMockTest.test_iscoroutinefunction_functioncCs8t}|}|t|t||dt|dS)Nassert_awaited)rr0r;r<rZassertInZdirrrcr>rrrtest_isawaitables zAsyncMockTest.test_isawaitablecCre)NcSrrrrrrrrfrzCAsyncMockTest.test_iscoroutinefunction_normal_function..foorgrhrrr(test_iscoroutinefunction_normal_functionrjz6AsyncMockTest.test_iscoroutinefunction_normal_functioncCsDt}t|t}||t|}||tjdSr)rZnew_event_loopZset_event_loopFutureZstopZcloserrE)rZloopfutrcrrrtest_future_isfutures z"AsyncMockTest.test_future_isfutureN)rrr rdrirmrnrqrrrrras rac@r`) AsyncAutospecTestcs@ttddfdd}ttddfdd}||dS)NTZautospecc|jt|tdSrrErrr r1rrrr3z=AsyncAutospecTest.test_is_AsyncMock_patch..test_asynccs|jtdSr)rErr r1rrrtest_normal_methodr4zEAsyncAutospecTest.test_is_AsyncMock_patch..test_normal_methodrrA)rr3rwrrrrFs   z)AsyncAutospecTest.test_is_AsyncMock_patchcCs:|tttddWdn1s,0YdS)NT)instance) assertRaises RuntimeErrorr r%rrrrtest_create_autospec_instance z/AsyncAutospecTest.test_create_autospec_instancecCs ttd}|t|tdSNspec)r r"rEr)rZawaitable_mockrrr$test_create_autospec_awaitable_classr}z6AsyncAutospecTest.test_create_autospec_awaitable_classcs&tt}|ddddfdd}||jd||j||jg|t|| t || t ||jd||jt dddd||jt ddddg||jdddd|jdddd||t|jddWdn1s0YdS) NrKrOrPrQcsIdHdSrrr awaitablerrmainrz4AsyncAutospecTest.test_create_autospec..mainr)e)r r)rR await_count assertIsNone await_argsawait_args_listassert_not_awaitedrr0rr iscoroutinerassert_awaited_onceassert_awaited_once_withassert_awaited_withrkrzAssertionErrorassert_any_await)rrrrrrtest_create_autospecs&    z&AsyncAutospecTest.test_create_autospeccr])NcsZttddd}|dddd}|jtt|t|t | |j d |j g|j||IdHWdn1s0Y |j d |jtdddd |j tddddg||jdddd|jdddd|| |j d|j |j gdS) NrNTrsrKrOrPrQr)rrrErcrr0rrrr;r<rRrrrrrrrrrrk reset_mock)r2rrrrr3s, ( z>AsyncAutospecTest.test_patch_with_autospec..test_asyncr^r7rrrtest_patch_with_autospecs z*AsyncAutospecTest.test_patch_with_autospecN)rrr rFr|rrrrrrrrrs  rrc@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS) AsyncSpecTestc Vfdd}ttfD]<}d|||Wdq1sF0YqdS)Ncs(|t}|jt|jtdSr)rrErrrr ) mock_typercrrr inner_testzCAsyncSpecTest.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 rrErrrrbrrr+test_spec_normal_methods_on_class_with_mockrz9AsyncSpecTest.test_spec_normal_methods_on_class_with_mockc Xfdd}tttfD]<}d|||Wdq1sH0YqdS)Ncsj|td}||t"t|Wdn1sF0Y|td}||dSr~r%rEr-r0r;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_kw z$AsyncSpecTest.test_spec_mock_type_kwc r)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*rz,AsyncSpecTest.test_spec_mock_type_positionalcCs8ttd}||t|}|t|t|dSr~rr*rEr0r;r<rrlrrr test_spec_as_normal_kw_AsyncMock8s   z.AsyncSpecTest.test_spec_as_normal_kw_AsyncMockcCs6tt}||t|}|t|t|dSrrrlrrr(test_spec_as_normal_positional_AsyncMock?s  z6AsyncSpecTest.test_spec_as_normal_positional_AsyncMockc&tjtdddfdd}|dS)NrTrcrCrrDr1rrrr3Gr4z6AsyncSpecTest.test_spec_async_mock..test_asyncr5r7rrrtest_spec_async_mockFsz"AsyncSpecTest.test_spec_async_mockcs"ttddfdd}|dS)NTrcs|t|jtdSr)rEr rrr1rrrr3Ns zIAsyncSpecTest.test_spec_parent_not_async_attribute_is..test_asyncrxr7rrr'test_spec_parent_not_async_attribute_isM z5AsyncSpecTest.test_spec_parent_not_async_attribute_iscs(tjtdtjdfdd}|dS)Nrrcs0|tt|t|dSr)rEr assertFalser;rr<r1rrrtest_async_attributeVs zFAsyncSpecTest.test_target_async_spec_not..test_async_attribute)rr6rr+r&)rrrrrtest_target_async_spec_notUsz(AsyncSpecTest.test_target_async_spec_notcs&tjtdtdfdd}|dS)Nr&rcrCrrD)Zmock_async_funcrrr test_attribute_not_async_spec_is_r4zUAsyncSpecTest.test_target_not_async_spec_is..test_attribute_not_async_spec_is)rr6r+r%)rrrrrtest_target_not_async_spec_is^z+AsyncSpecTest.test_target_not_async_spec_iscs"tttdfdd}|dS)Nrcrtrru)ZMockNormalClassrrr test_async_attributes_coroutineservzRAsyncSpecTest.test_spec_async_attributes..test_async_attributes_coroutines)rnormal_foo_namer)rrrrrtest_spec_async_attributesdrz(AsyncSpecTest.test_spec_async_attributesN)rrr rrrrrrrrrrrrrrrr s  rc@rT) AsyncSpecSetTestcr)NrTZspec_setcrCrrD)rrrrr3or4z.test_asyncr5r7rrrrFnrz(AsyncSpecSetTest.test_is_AsyncMock_patchcCs*ttjd}|t|||tdSNr)rrrr0rrErbrrrtest_is_async_AsyncMockts z(AsyncSpecSetTest.test_is_async_AsyncMockcCsVttd}|t|j|t|j||jt||jt||tdSr) r rr0rrrrrErrbrrrtest_is_child_AsyncMockys  z(AsyncSpecSetTest.test_is_child_AsyncMockcCsRt}tddd|_t|d}||tWdn1sD0YdS)NcSs|SrrZxrrrZrz=AsyncSpecSetTest.test_magicmock_lambda_spec..r mock_func)r rrr6rE)rZmock_objcmrrrtest_magicmock_lambda_specsz+AsyncSpecSetTest.test_magicmock_lambda_specN)rrr rFrrrrrrrrmsrc@steZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZdS)AsyncArgumentscs2dd}t|dd}|dIdH}||ddS)Ncrrr)rvarrrradditionrz6AsyncArguments.test_add_return_value..addition rLrrR)rrrcZoutputrrrtest_add_return_values z$AsyncArguments.test_add_return_valuecsTdd}t|tdd}|t|dIdHWdn1sF0YdS)Ncrrrrrrrrrz?AsyncArguments.test_add_side_effect_exception..additionZerrZ side_effectr)r Exceptionrz)rrrcrrrtest_add_side_effect_exceptions z-AsyncArguments.test_add_side_effect_exceptionc0dd}t|d}|dIdH}||ddS)Nc|dSNrKrrrrrrrz?AsyncArguments.test_add_side_effect_coroutine..additionrrrrrrcresultrrrtest_add_side_effect_coroutine z-AsyncArguments.test_add_side_effect_coroutinecr)NcSrrrrrrrrrzEAsyncArguments.test_add_side_effect_normal_function..additionrrrrrrrr$test_add_side_effect_normal_functionrz3AsyncArguments.test_add_side_effect_normal_functioncsjgd}t|d}|D]}||IdH|q|t}|IdHWdn1s\0YdS)NrKrOrPr)rrRrzStopAsyncIteration)rvalsrcitemrrrrtest_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 rrrrSampleExceptionr$rrKrfr)rrrRrz)rrrrcrrrr'test_add_side_effect_exception_iterables    z6AsyncArguments.test_add_side_effect_exception_iterablecs0tdd}t|d}|IdH}|||dS)NrrL)rassertIs)rvaluercrrrrtest_return_value_AsyncMocks   z*AsyncArguments.test_return_value_AsyncMockcs:t}|dt|d}|IdH}||tjdS)NrL)rro set_resultrrErrprcrrrrtest_return_value_awaitables    z*AsyncArguments.test_return_value_awaitablecsrt}|dt|gd}|IdH}||tj|t|IdHWdn1sd0YdS)Nr)rrorrrErzrrrrr!test_side_effect_awaitable_valuess    z0AsyncArguments.test_side_effect_awaitable_valuescs0tdd}t|d}|IdH}||ddS)NrrLrr)rZeffectrcrrrrtest_side_effect_is_AsyncMocks   z,AsyncArguments.test_side_effect_is_AsyncMockcsRtdfdd}t|d}|IdH}||||dS)NFcdSNTrrZranrrrinnerz2AsyncArguments.test_wraps_coroutine..innerZwraps)rrorrRrkr0rrrcrrrrtest_wraps_coroutines   z#AsyncArguments.test_wraps_coroutinecsNddfdd}t|d}|IdH}||||dS)NrKFcrrrrrrrrrz8AsyncArguments.test_wraps_normal_function..innerr)rrRrkr0rrrrtest_wraps_normal_functions   z)AsyncArguments.test_wraps_normal_functioncsxt}|d}|d}|IdH|IdH|tdtdg||jtdtdg||jtdtdgdS)NrOrK)rassert_has_awaitsrrRrcall_args_list)rrZmock2Zmock1rrrtest_await_args_list_orders  z)AsyncArguments.test_await_args_list_orderN)rrr rrrrrrrrrrrrrrrrrrs   rc@r`) AsyncMagicMethodscCsBt}||jt||jt||jt||jtdSr)r rE __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)rrE __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> z7AsyncContextManagerTest.test_set_return_value_of_aenterc r)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)rrr0rrrrkZ 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_instancerrrorXz^AsyncContextManagerTest.test_mock_customize_async_context_manager..use_context_manager)rr r6rrMrr)rryZexpected_resultrrrr)test_mock_customize_async_context_managerhs  zAAsyncContextManagerTest.test_mock_customize_async_context_managercsjddfdd}fdd}|}t||_|_fdd}t|||dS)NFcddSrrr) enter_calledrrenter_coroutineyr4ziAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..enter_coroutinecrrrr) exit_calledrrexit_coroutine}r4zhAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..exit_coroutinec s<4IdHWdIdHq81IdHs.0YdSrrrrrrrrXzmAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..use_context_manager)rr rrrr0)rrrryrr)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_inrXzYAsyncContextManagerTest.test_context_manager_raise_exception_by_default..raise_in)rr rzrr)rr ryrrrr/test_context_manager_raise_exception_by_defaults  zGAsyncContextManagerTest.test_context_manager_raise_exception_by_defaultN) rrr rrr rrrrr!rrrrr(s  rc@s4eZdZGdddeZddZddZddZd S) AsyncIteratorTestc@s$eZdZddZddZddZdS)z#AsyncIteratorTest.WithAsyncIteratorcCsgd|_dS)N)rfZ NormalFoobaz)Zitemsrrrrrrz,AsyncIteratorTest.WithAsyncIterator.__init__cCrrrrrrrrrz-AsyncIteratorTest.WithAsyncIterator.__aiter__crrrrrrrrrz-AsyncIteratorTest.WithAsyncIterator.__anext__N)rrr rrrrrrrWithAsyncIteratorsr$cs@tddgdj_fdd}t|}||gddS)NZtesterr rcsdd2IdHS)Ncsg|z3dHW}|q6Srr)Z.0ZirrrZ rzOAsyncIteratorTest.test_aiter_set_return_value..main..rrZ mock_iterrrrrz;AsyncIteratorTest.test_aiter_set_return_value..main)rrrMrrR)rrrrr%rtest_aiter_set_return_values     z-AsyncIteratorTest.test_aiter_set_return_valuec r)NcsT}||}t|jt|jt|jt|jdSr)r$rrrr0r)rryrrrrrs zIAsyncIteratorTest.test_mock_aiter_and_anext_asyncmock..inner_testz%test aiter and anext corourtine with rrrrr#test_mock_aiter_and_anext_asyncmockrz5AsyncIteratorTest.test_mock_aiter_and_anext_asyncmockc sddgdfdd}fdd}fdd }ttfD]}d |||Wdn1sx0Yd |||Wdn1s0Yd |||WdqF1s0YqFdS) Ncs&g}|2z3dHW}||q6|Sr)Zappend)ZiteratorZ accumulatorrrrriteratesz6AsyncIteratorTest.test_mock_async_for..iterate)ZFOOZBARZBAZcs$|}t|gdSr)r$rRrrr)r(rrr test_defaultr}z;AsyncIteratorTest.test_mock_async_for..test_defaultcs4|}dd|j_t|dSr)r$rrMrRrr)Zexpectedr(rrrtest_set_return_values zDAsyncIteratorTest.test_mock_async_for..test_set_return_valuecs8|}tdd|j_t|dSr)r$ZiterrrMrRrr)r+rrtest_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)rr*r,r-rrr+rtest_mock_async_fors &&z%AsyncIteratorTest.test_mock_async_forN)rrr r6r$r&r'r.rrrrr"sr"c@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)rrcrrrrsetUprzAsyncMockAssert.setUpcs|j|i|IdHdSr)rcrrrr_runnable_testrzAsyncMockAssert._runnable_testcs |IdHSrr)r coroutinerrr_await_coroutinerz AsyncMockAssert._await_coroutinecCstt}t||Wdn1s.0Y|t|j|j|j|j| t | Wdn1s0Y| t |j Wdn1s0YdSr) rrr-rr0r assert_calledassert_called_onceassert_called_once_withrzrrkrbrrr"test_assert_called_but_not_awaiteds &    & z2AsyncMockAssert.test_assert_called_but_not_awaitedcCstt}|}|j|j|j|t|jWdn1sX0Yt | ||j|j|j |j dSr) rrrr4r5r6rzrrkrr3rr)rrcZmock_coroutinerrrtest_assert_called_then_awaiteds    (   z/AsyncMockAssert.test_assert_called_then_awaitedcCs|t|jWdn1s*0Y|t|jWdn1s^0Yt||j|jdSr) rzrrcrkr4rr1r5rrrrr+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-rzrrkr4rr3rrrcr2rrr)test_assert_called_twice_and_awaited_onces & (  z9AsyncMockAssert.test_assert_called_twice_and_awaited_oncecCsntt}|}|jt|||tt||Wdn1sV0Y|jdSr) rrrr5rr3rzr{rkr: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)rzrrcrkr4rrr3rrrr"test_assert_awaited_but_not_called)s ( ( . ( z2AsyncMockAssert.test_assert_awaited_but_not_calledcCstdg}t||dWdn1s20Y|j||t|j|Wdn1st0YdSNrf)rr-rcZassert_has_callsrzrr)rZkallsrrr test_assert_has_calls_not_awaits7s   (  z0AsyncMockAssert.test_assert_has_calls_not_awaitscCst||Wdn1s&0Yddifg}||jj|t||dWdn1st0Yt||dWdn1s0Yttdtdg}||jj|dS)Nrrfr#)r-rcrR 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) Nr@rrKrOrPir)r&r')rrr-rrRrAr)rZ a_class_mockrBZ method_kallsrCrrr2test_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) NrP)fishr)cake something)rPrFzsomething_else.something)rrGz#method calls not recorded correctly)r-rcrHZsomething_elser ZCakerR 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)rrIrA)ZgetattrrEr ZlistrR)rcZnamesr Zattrrrr assert_attrsks    z:AsyncMockAssert.test_async_arg_lists..assert_attrsrKrOrP)r&)rcr-rrrr)rrKrrrrtest_async_arg_listsjs"   & * *   & .z$AsyncMockAssert.test_async_arg_listscCsN|t|jWdn1s*0Yt||jdSr)rzrrcrkrr1rrrrtest_assert_awaiteds ( z#AsyncMockAssert.test_assert_awaitedcCs|t|jWdn1s*0Yt||jt||t|jWdn1s0YdSr)rzrrcrrr1rrrrtest_assert_awaited_onces (    z(AsyncMockAssert.test_assert_awaited_oncecCsd}|t||jdWdn1s20Yt|d}|t||jdWdn1sz0Yt|d|jdt|d|t|jdWdn1s0YdS)Nz Not awaitedrfzexpected await not found SomethingElse)assertRaisesRegexrrcrrr1rz)rZmsgrrrtest_assert_awaited_withs* *  z(AsyncMockAssert.test_assert_awaited_withcCs|t|jdWdn1s,0Yt|d|jdt|d|t|jdWdn1s0YdSr>)rzrrcrrr1rrrrtest_assert_awaited_once_withs *  z-AsyncMockAssert.test_assert_awaited_once_withcCs|t|jdWdn1s,0Yt|d|t|jdWdn1sp0Yt|d|jdt|d|jddS)Nrfr#rO)rzrrcrrr1rrrrtest_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)Nrfr#rKrO) rrzrrcrrRZlen exceptionrrr1)rcallsrrrrtest_assert_has_awaits_no_orders * * * z/AsyncMockAssert.test_assert_has_awaits_no_ordercCsTGddd}t||d|jttdg|jtd|jtddS)Nc@r!)z9AsyncMockAssert.test_awaits_asserts_with_any..FoocSrrrrZotherrrr__eq__rz@AsyncMockAssert.test_awaits_asserts_with_any..Foo.__eq__Nrrr rXrrrrFoor$rZrK)rr1rcrrrrr)rrZrrrtest_awaits_asserts_with_anys z,AsyncMockAssert.test_awaits_asserts_with_anycsbGddd}t|dfdd}t||dttdgtdtddS)Nc@r!)zBAsyncMockAssert.test_awaits_asserts_with_spec_and_any..FoocSrrrrWrrrrXrzIAsyncMockAssert.test_awaits_asserts_with_spec_and_any..Foo.__eq__NrYrrrrrZr$rZrcs|IdHdSrrrZmock_with_specrr_custom_mock_runnable_testrzYAsyncMockAssert.test_awaits_asserts_with_spec_and_any.._custom_mock_runnable_testrK)rrrrrrr)rrZr]rr\r%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)Nrfr#T)Z any_orderZbamfZqux)rrzrrcrrr1)rrUrrrtest_assert_has_awaits_ordereds . . .z.AsyncMockAssert.test_assert_has_awaits_orderedcCsN|jt||t|jWdn1s@0YdSr)rcrrr1rzrrrrrtest_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) Ncrrrrrrrf rzIAsyncMockAssert.test_assert_has_awaits_not_matching_spec_error..frrKz^{}$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)]rOr)rrcrr1rPrZformatreZescaperrrrTZ __cause__rEr)rrarrrr.test_assert_has_awaits_not_matching_spec_error s.  .6z>AsyncMockAssert.test_assert_has_awaits_not_matching_spec_errorN)rrr r0r1r3r7r8r9r;r<r=r?rDrErJrLrMrNrQrRrSrVr[r^r_r`rcrrrrr/s2       r/),rr,r;rbZunittestZ contextlibrrrrZ unittest.mockrrrrr r r r r rrr"r%r)r*r6r+rrArr-ZTestCaser.rUrarrrrrrrr"r/rrrrZs<  ,    =!"Tay&rE