o =?h@sddlZddlZddlZddlZddlZddlmZddlmZmZddlm Z ddl m Z m Z m Z mZmZmZmZmZmZmZddZGdd d ZGd d d Zd d ZddZddZGdddeZedZedZeddZ Gdddej!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,ed.kre-dSdS)/N)contextmanager)runiscoroutinefunction)IsolatedAsyncioTestCase) ANYcall AsyncMockpatch MagicMockMockcreate_autospecsentinel _CallListsealcCstddSN)asyncioZset_event_loop_policyrrG/opt/alt/python310/lib64/python3.10/unittest/test/testmock/testasync.pytearDownModulerc@s<eZdZddZddZddZeddZed d Z d S) AsyncClasscCdSrrselfrrr__init__zAsyncClass.__init__cdSrrrrrr async_methodzAsyncClass.async_methodcCrrrrrrr normal_methodrzAsyncClass.normal_methodcrrr)clsrrrasync_class_methodzAsyncClass.async_class_methodcrrrrrrrasync_static_methodr"zAsyncClass.async_static_methodN) __name__ __module__ __qualname__rrr classmethodr! staticmethodr#rrrrrs rc@eZdZddZdS)AwaitableClassccs dVdSrrrrrr __await__s zAwaitableClass.__await__N)r$r%r&r+rrrrr* r*crrrrrrr async_func!rr-crrr)abcrrrasync_func_args#rr1cCrrrrrrr normal_func%rr2c@r)) NormalClasscCrrrrrrrr.(rz NormalClass.aN)r$r%r&r.rrrrr3'r,r3z .AsyncClassz .NormalClassccsB|tddVtWddS1swYdS)Nzwas never awaited$)ZassertWarnsRegexRuntimeWarninggcZcollect)testrrrassertNeverAwaited/s  "r7c@<eZdZddZddZddZddZd d Zd d Zd S)AsyncPatchDecoratorTestc"ttdfdd}|dS)Nrcst|dSr) assertTruer mock_methodrrr test_async:zLAsyncPatchDecoratorTest.test_is_coroutine_function_patch..test_asyncr objectrrr>rrr test_is_coroutine_function_patch9s  z8AsyncPatchDecoratorTest.test_is_coroutine_function_patchcsBttdfdd}ttdfdd}||dS)Nrc"|}t|t|dSrr;inspect isawaitablerr=mrrrr>@ z?AsyncPatchDecoratorTest.test_is_async_patch..test_asyncz .async_methodcrDrrErHrrrtest_no_parent_attributeFrJzMAsyncPatchDecoratorTest.test_is_async_patch..test_no_parent_attribute)r rArasync_foo_name)rr>rKrrrtest_is_async_patch?s   z+AsyncPatchDecoratorTest.test_is_async_patchcr:)Nrc|tdSrassertIsInstancerr<rrrr>PzCAsyncPatchDecoratorTest.test_is_AsyncMock_patch..test_asyncr@rBrrrtest_is_AsyncMock_patchO  z/AsyncPatchDecoratorTest.test_is_AsyncMock_patchcr:)Nr#crNrrOr<rrrr>WrQzPAsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethod..test_asyncr@rBrrr$test_is_AsyncMock_patch_staticmethodVrSz^rQzOAsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethod..test_asyncr@rBrrr#test_is_AsyncMock_patch_classmethod]rSz;AsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethodcsNttdddttdddfdd}t|ttdS)N .async_func return_value.async_func_argscsj|jd|jdtttttIdHdtddddIdHddS)Nr1r-rWr[r0) assertEqualZ _mock_namerPr-rr1)Zfunc_args_mockZ func_mockrrrr>es   z@AsyncPatchDecoratorTest.test_async_def_patch..test_async)r r$rr;rFrr-rBrrrtest_async_def_patchds  z,AsyncPatchDecoratorTest.test_async_def_patchN) r$r%r&rCrMrRrTrUr_rrrrr98s r9c@r8)AsyncPatchCMTestcfdd}|dS)Ncs@ttd}t|WddS1swYdSNr)r rArr;rr<rrrr>ws"z>AsyncPatchCMTest.test_is_async_function_cm..test_asyncrrBrrrtest_is_async_function_cmv  z*AsyncPatchCMTest.test_is_async_function_cmcra)NcsPttd}|}t|t|WddS1s!wYdSrb)r rArr;rFrGrrHrrrr>~s  "z5AsyncPatchCMTest.test_is_async_cm..test_asyncrrBrrrtest_is_async_cm}s  z!AsyncPatchCMTest.test_is_async_cmcra)Ncs>ttd}|tWddS1swYdSrb)r rArrPrr<rrrr>s"z9AsyncPatchCMTest.test_is_AsyncMock_cm..test_asyncrrBrrrtest_is_AsyncMock_cmrdz%AsyncPatchCMTest.test_is_AsyncMock_cmcfdd}t|dS)NcsTttdtttWdn1swYttdS)NrV)r r$rrPr-r;rFrrrrrr>s z6AsyncPatchCMTest.test_async_def_cm..test_asyncrrBrrrtest_async_def_cms z"AsyncPatchCMTest.test_async_def_cmcsBdditddifdd}t|t|dS)Nr.r/csdddSNr.r/)r^rfoorrrr>sz>AsyncPatchCMTest.test_patch_dict_async_def..test_async)r dictr;rrrBrrkrtest_patch_dict_async_defs z*AsyncPatchCMTest.test_patch_dict_async_defcs$ddifdd}t|dS)Nr.csHtddiddWddS1swYdSrj)r rmr^rrkrrr>s"zFAsyncPatchCMTest.test_patch_dict_async_def_context..test_asyncrhrBrrkr!test_patch_dict_async_def_contextsz2AsyncPatchCMTest.test_patch_dict_async_def_contextN) r$r%r&rcrerfrirnrorrrrr`us  r`c@4eZdZddZddZddZddZd d Zd S) AsyncMockTestcCst}|t|dSr)rr;rrmockrrr test_iscoroutinefunction_defaultsz.AsyncMockTest.test_iscoroutinefunction_defaultcC2dd}t|}|t||t|dS)Ncrrrrrrrrlrz.foorr;rrFrrlrsrrr!test_iscoroutinefunction_functionz/AsyncMockTest.test_iscoroutinefunction_functioncCs8t}|}|t|t||dt|dS)Nassert_awaited)rr;rFrGrZassertIndirrrsrIrrrtest_isawaitables zAsyncMockTest.test_isawaitablecCru)NcSrrrrrrrrlrzCAsyncMockTest.test_iscoroutinefunction_normal_function..foorvrwrrr(test_iscoroutinefunction_normal_functionryz6AsyncMockTest.test_iscoroutinefunction_normal_functioncCsDt}t|t}||t|}||tjdSr)rZnew_event_loopZset_event_loopFuturestopcloserrP)rZloopfutrsrrrtest_future_isfutures z"AsyncMockTest.test_future_isfutureN)r$r%r&rtrxr}r~rrrrrrqs  rqc@s>eZdZddZddZedddZdd Zd d Z d S) AsyncAutospecTestcs@ttddfdd}ttddfdd}||dS)NTZautospecc|jt|tdSrrPrrr r<rrrr>z=AsyncAutospecTest.test_is_AsyncMock_patch..test_asynccs|jtdSr)rPrr r<rrrtest_normal_methodr?zEAsyncAutospecTest.test_is_AsyncMock_patch..test_normal_methodr rL)rr>rrrrrRs   z)AsyncAutospecTest.test_is_AsyncMock_patchcCs<|tttddWddS1swYdS)NT)instance) assertRaises RuntimeErrorr r-rrrrtest_create_autospec_instances "z/AsyncAutospecTest.test_create_autospec_instancez3Broken test from https://bugs.python.org/issue37251cCs|tttdSr)rPr r*rrrrr$test_create_autospec_awaitable_classsz6AsyncAutospecTest.test_create_autospec_awaitable_classcs&tt}|ddddfdd}||jd||j||jg|t|| t || t ||jd||jt dddd||jt ddddg||jdddd|jdddd||t|jddWddS1swYdS) NrWr[r\r]csIdHdSrrr awaitablerrmainsz4AsyncAutospecTest.test_create_autospec..mainr)e)r r1r^ await_count assertIsNone await_argsawait_args_listassert_not_awaitedrr;rr iscoroutinerassert_awaited_onceassert_awaited_once_withassert_awaited_withrzrAssertionErrorassert_any_await)rspecrrrrtest_create_autospecs(    "z&AsyncAutospecTest.test_create_autospeccrg)Ncs\ttdddJ}|dddd}|jtt|t|t | |j d |j g|j||IdHWdn1sWwY |j d |jtdddd |j tddddg||jdddd|jdddd|| |j d|j |j gdS) NrZTrrWr[r\r]r)r r$rPrsrr;rrrrFrGr^rrrrrrrrrrz reset_mock)r=rrrrr>s0   z>AsyncAutospecTest.test_patch_with_autospec..test_asyncrhrBrrrtest_patch_with_autospecs z*AsyncAutospecTest.test_patch_with_autospecN) r$r%r&rRrunittestskiprrrrrrrrs   rc@sleZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdS) AsyncSpecTestc Vfdd}ttfD]}d| ||Wdn1s#wYq dS)Ncs(|t}|jt|jtdSr)rrPrrrr ) mock_typersrrr inner_testzCAsyncSpecTest.test_spec_normal_methods_on_class..inner_testztest method types with rr subTestrrrrrr!test_spec_normal_methods_on_classs   z/AsyncSpecTest.test_spec_normal_methods_on_classcCs(tt}||jt||jtdSr)r rrPrrrrrrrr+test_spec_normal_methods_on_class_with_mock(rz9AsyncSpecTest.test_spec_normal_methods_on_class_with_mockcCsvtt}t||t |jWdn1swY|t |jWddS1s4wYdSr)r rrrAttributeErrorrrrrrrr0test_spec_normal_methods_on_class_with_mock_seal-s  "z>AsyncSpecTest.test_spec_normal_methods_on_class_with_mock_sealc Xfdd}tttfD]}d| ||Wdn1s$wYq dS)Ncsj|td}||tt|Wdn1s#wY|td}||dSNrr-rPr7r;rFrGr2r async_mockZ sync_mockrrrr6s    z8AsyncSpecTest.test_spec_mock_type_kw..inner_testztest spec kwarg with rr r rrrrrtest_spec_mock_type_kw5   z$AsyncSpecTest.test_spec_mock_type_kwc r)Ncsf|t}||tt|Wdn1s"wY|t}||dSrrrrrrrDs  z@AsyncSpecTest.test_spec_mock_type_positional..inner_testztest spec positional with rrrrrtest_spec_mock_type_positionalCrz,AsyncSpecTest.test_spec_mock_type_positionalcCs8ttd}||t|}|t|t|dSrrr2rPr;rFrGrr|rrr test_spec_as_normal_kw_AsyncMockQs   z.AsyncSpecTest.test_spec_as_normal_kw_AsyncMockcCs6tt}||t|}|t|t|dSrrr|rrr(test_spec_as_normal_positional_AsyncMockXs   z6AsyncSpecTest.test_spec_as_normal_positional_AsyncMockc&tjtdddfdd}|dS)NrTrcrNrrOr<rrrr>`rQz6AsyncSpecTest.test_spec_async_mock..test_asyncr@rBrrrtest_spec_async_mock_s z"AsyncSpecTest.test_spec_async_mockcs"ttddfdd}|dS)NTrcs|t|jtdSr)rPr rrr<rrrr>gs zIAsyncSpecTest.test_spec_parent_not_async_attribute_is..test_asyncrrBrrr'test_spec_parent_not_async_attribute_isf  z5AsyncSpecTest.test_spec_parent_not_async_attribute_iscs(tjtdtjdfdd}|dS)Nrrcs0|tt|t|dSr)rPr assertFalserFrrGr<rrrtest_async_attributeos zFAsyncSpecTest.test_target_async_spec_not..test_async_attribute)r rArr3r.)rrrrrtest_target_async_spec_notns z(AsyncSpecTest.test_target_async_spec_notcs&tjtdtdfdd}|dS)Nr.rcrNrrO)Zmock_async_funcrrr test_attribute_not_async_spec_isxrQzUAsyncSpecTest.test_target_not_async_spec_is..test_attribute_not_async_spec_is)r rAr3r-)rrrrrtest_target_not_async_spec_isw z+AsyncSpecTest.test_target_not_async_spec_iscs"tttdfdd}|dS)Nrcrrr)ZMockNormalClassrrr test_async_attributes_coroutines~rzRAsyncSpecTest.test_spec_async_attributes..test_async_attributes_coroutines)r normal_foo_namer)rrrrrtest_spec_async_attributes}rz(AsyncSpecTest.test_spec_async_attributesN)r$r%r&rrrrrrrrrrrrrrrrrs  rc@s,eZdZddZddZddZddZd S) AsyncSpecSetTestcr)NrTZspec_setcrNrrO)rrrrr>rQz.test_asyncr@rBrrrrRrz(AsyncSpecSetTest.test_is_AsyncMock_patchcCs*ttjd}|t|||tdSNr)rrrr;rrPrrrrrtest_is_async_AsyncMocks z(AsyncSpecSetTest.test_is_async_AsyncMockcCsVttd}|t|j|t|j||jt||jt||tdSr) r rr;rrrrrPrrrrrrtest_is_child_AsyncMocks z(AsyncSpecSetTest.test_is_child_AsyncMockcCsTt}tddd|_t|d}||tWddS1s#wYdS)NcSs|Srrxrrrrz=AsyncSpecSetTest.test_magicmock_lambda_spec..r mock_func)r rr rArP)rZmock_objcmrrrtest_magicmock_lambda_specs "z+AsyncSpecSetTest.test_magicmock_lambda_specN)r$r%r&rRrrrrrrrrs  rc@steZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZdS)AsyncArgumentscs4dd}t|dd}|dIdH}||ddS)Ncrrr)rvarrrradditionrz6AsyncArguments.test_add_return_value..addition rXrr^)rrrsoutputrrrtest_add_return_values  z$AsyncArguments.test_add_return_valuecsXdd}t|tdd}|t|dIdHWddS1s%wYdS)Ncrrrrrrrrrz?AsyncArguments.test_add_side_effect_exception..additionerrZ side_effectr)r Exceptionr)rrrsrrrtest_add_side_effect_exceptions  "z-AsyncArguments.test_add_side_effect_exceptionc2dd}t|d}|dIdH}||ddS)Ncs |dSNrWrrrrrrsz?AsyncArguments.test_add_side_effect_coroutine..additionrrrrrrsresultrrrtest_add_side_effect_coroutine  z-AsyncArguments.test_add_side_effect_coroutinecr)NcSs|dSrrrrrrrszEAsyncArguments.test_add_side_effect_normal_function..additionrrrrrrrr$test_add_side_effect_normal_functionrz3AsyncArguments.test_add_side_effect_normal_functioncsngd}t|d}|D] }||IdH|q |t}|IdHWddS1s0wYdS)NrWr[r\r)rr^rStopAsyncIteration)rvalsrsitemrrrrtest_add_side_effect_iterables  "z,AsyncArguments.test_add_side_effect_iterablecsxGdddt}d|dg}t|d}||IdHd||}|IdHWddS1s5wYdS)Nc@s eZdZdS)zOAsyncArguments.test_add_side_effect_exception_iterable..SampleExceptionN)r$r%r&rrrrSampleExceptionsrrWrlr)rrr^r)rrrrsrrrr'test_add_side_effect_exception_iterables   "z6AsyncArguments.test_add_side_effect_exception_iterablecs2tdd}t|d}|IdH}|||dS)NrrX)rassertIs)rvaluersrrrrtest_return_value_AsyncMocks    z*AsyncArguments.test_return_value_AsyncMockcs<t}|dt|d}|IdH}||tjdS)NrX)rr set_resultrrPrrrsrrrrtest_return_value_awaitables    z*AsyncArguments.test_return_value_awaitablecsvt}|dt|gd}|IdH}||tj|t|IdHWddS1s4wYdS)Nr)rrrrrPrrrrrr!test_side_effect_awaitable_valuess    "z0AsyncArguments.test_side_effect_awaitable_valuescs2tdd}t|d}|IdH}||ddS)NrrXrr)rZeffectrsrrrrtest_side_effect_is_AsyncMocks    z,AsyncArguments.test_side_effect_is_AsyncMockcsTtdfdd}t|d}|IdH}||||dS)NFcs dSNTrrZranrrrinnersz2AsyncArguments.test_wraps_coroutine..innerwraps)rrrr^rzr;rrrsrrrrtest_wraps_coroutines   z#AsyncArguments.test_wraps_coroutinecsPddfdd}t|d}|IdH}||||dS)NrWFcsdSrrrrrrrsz8AsyncArguments.test_wraps_normal_function..innerr)rr^rzr;rrrrtest_wraps_normal_functions   z)AsyncArguments.test_wraps_normal_functioncszt}|d}|d}|IdH|IdH|tdtdg||jtdtdg||jtdtdgdS)Nr[rW)rassert_has_awaitsrr^rcall_args_list)rrZmock2Zmock1rrrtest_await_args_list_orders  z)AsyncArguments.test_await_args_list_orderN)r$r%r&rrrrrrrrrrrrrrrrrrs    rc@rp) AsyncMagicMethodscCsBt}||jt||jt||jt||jtdSr)r rP __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)rrP __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_aenterW   z7AsyncContextManagerTest.test_set_return_value_of_aenterc r)Ncsvd}||fdd}t|}jjjjjj|dS)NFc sD4IdH}dWdIdH|S1IdHswY|SrrrcalledZcm_mockrruse_context_managermszqAsyncContextManagerTest.test_mock_supports_async_context_manager..inner_test..use_context_manager)rrr;rr,rrzZ assertIsNot)rrr-Z cm_resultrr+rrhs    zTAsyncContextManagerTest.test_mock_supports_async_context_manager..inner_testz!test context manager magics with rrrrr(test_mock_supports_async_context_managergs   z@AsyncContextManagerTest.test_mock_supports_async_context_managercs@|}t|t}|j_fdd}|t||dS)Nc sB4IdH }|WdIdHS1IdHswYdSrrr* mock_instancerrr-s0z^AsyncContextManagerTest.test_mock_customize_async_context_manager..use_context_manager)rr rArrYrr)rrZexpected_resultr-rr/r)test_mock_customize_async_context_managers  zAAsyncContextManagerTest.test_mock_customize_async_context_managercsjddfdd}fdd}|}t||_|_fdd}t|||dS)NFc ddSrrr) enter_calledrrenter_coroutineziAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..enter_coroutinecr2rrr3) exit_calledrrexit_coroutiner6zhAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..exit_coroutinec s@4IdH WdIdHdS1IdHswYdSrrrr/rrr-s.zmAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine..use_context_manager)rr rrrr;)rr5r8rr-r)r4r7r0r8test_mock_customize_async_context_manager_with_coroutines     zPAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutinecCsTdd}|}t|}|tt||WddS1s#wYdS)Nc s0|4IdHt1IdHswYdSr) TypeError)Zcontext_managerrrrraise_inszYAsyncContextManagerTest.test_context_manager_raise_exception_by_default..raise_in)rr rr:r)rr;rr0rrr/test_context_manager_raise_exception_by_defaults  "zGAsyncContextManagerTest.test_context_manager_raise_exception_by_defaultN) r$r%r&rrr$r(r.r1r9r<rrrrrAs  rc@s4eZdZGdddeZddZddZddZd S) AsyncIteratorTestc@s$eZdZddZddZddZdS)z#AsyncIteratorTest.WithAsyncIteratorcCsgd|_dS)N)rlZ NormalFoobaz)itemsrrrrrrz,AsyncIteratorTest.WithAsyncIterator.__init__cCrrrrrrrr rz-AsyncIteratorTest.WithAsyncIterator.__aiter__crrrrrrrrrz-AsyncIteratorTest.WithAsyncIterator.__anext__N)r$r%r&rr rrrrrWithAsyncIterators r@cs@tddgdj_fdd}t|}||gddS)NZtesterr%rcsdd2IdHS)Ncsg|z3dHW}|q6Srr).0irrr szOAsyncIteratorTest.test_aiter_set_return_value..main..rrZ mock_iterrrrsz;AsyncIteratorTest.test_aiter_set_return_value..main)rr rYrr^)rrrrrDrtest_aiter_set_return_values    z-AsyncIteratorTest.test_aiter_set_return_valuec r)NcsT}||}t|jt|jt|jt|jdSr)r@rrr r;r)rrr0rrrrs zIAsyncIteratorTest.test_mock_aiter_and_anext_asyncmock..inner_testz%test aiter and anext corourtine with rrrrr#test_mock_aiter_and_anext_asyncmockr)z5AsyncIteratorTest.test_mock_aiter_and_anext_asyncmockc sddgdfdd}fdd}fdd }ttfD]V}d | ||Wdn1s.iterate)ZFOOZBARZBAZcs$|}t|gdSr)r@r^rrr0)rIrrr test_defaults z;AsyncIteratorTest.test_mock_async_for..test_defaultcs4|}dd|j_t|dSr)r@r rYr^rrJZexpectedrIrrrtest_set_return_values zDAsyncIteratorTest.test_mock_async_for..test_set_return_valuecs8|}tdd|j_t|dSr)r@iterr rYr^rrJrLrrtest_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)rrKrMrOrrrLrtest_mock_async_fors"    z%AsyncIteratorTest.test_mock_async_forN)r$r%r&rAr@rErFrPrrrrr=s  r=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)rrsrrrrsetUps zAsyncMockAssert.setUpcs|j|i|IdHdSr)rsrrrr_runnable_testszAsyncMockAssert._runnable_testcs |IdHSrr)r coroutinerrr_await_coroutines z AsyncMockAssert._await_coroutinecCstt}t| |Wdn1swY|t|j|j|j|j| t  | Wdn1sGwY| t |j WddS1sbwYdSr) rrr7rr;r assert_calledassert_called_onceassert_called_once_withrrrzrrrrr"test_assert_called_but_not_awaiteds         "z2AsyncMockAssert.test_assert_called_but_not_awaitedcCstt}|}|j|j|j|t |jWdn1s,wYt | ||j|j|j |j dSr) rrrrVrWrXrrrzrrUrr)rrsZmock_coroutinerrrtest_assert_called_then_awaiteds        z/AsyncMockAssert.test_assert_called_then_awaitedcCs|t |jWdn1swY|t |jWdn1s/wYt||j|jdSr) rrrsrzrVrrSrWrrrrr+test_assert_called_and_awaited_at_same_times      z;AsyncMockAssert.test_assert_called_and_awaited_at_same_timecCstt}|}t| |Wdn1swY|t |jWdn1s5wY|jt| ||j|j dSr) rrrr7rrrzrVrrUrrrsrTrrr)test_assert_called_twice_and_awaited_once*s      z9AsyncMockAssert.test_assert_called_twice_and_awaited_oncecCsntt}|}|jt|||tt||Wdn1s+wY|jdSr) rrrrWrrUrrrzr\rrr)test_assert_called_once_and_awaited_twice8s  z9AsyncMockAssert.test_assert_called_once_and_awaited_twicecCs|t |jWdn1swY|t |jWdn1s/wY|tt||jWdn1sLwY|t |jWdn1sfwY|t|jWddS1swYdSr)rrrsrzrVr:rrUrrrr"test_assert_awaited_but_not_calledBs         "z2AsyncMockAssert.test_assert_awaited_but_not_calledcCstdg}t| |dWdn1swY|j||t|j|WddS1s;wYdSNrl)rr7rsZassert_has_callsrrr)rZkallsrrr test_assert_has_calls_not_awaitsPs     "z0AsyncMockAssert.test_assert_has_calls_not_awaitscCst| |Wdn1swYddifg}||jj|t| |dWdn1s:wYt| |dWdn1sSwYttdtdg}||jj|dS)Nrrlr>)r7rsr^ mock_callsr)r kalls_empty mock_kallsrrr0test_assert_has_mock_calls_on_async_mock_no_specXs       z@AsyncMockAssert.test_assert_has_mock_calls_on_async_mock_no_speccCstt}t| |Wdn1swYddifg}||jj|||jtgt||jddddddWdn1sMwYttddddddg}ttjddddddg}||jj|||j|dS) NrbrrWr[r\r)r.r/)rrr7rr^rcr)rZ a_class_mockrdZ method_kallsrerrr2test_assert_has_mock_calls_on_async_mock_with_speces    zBAsyncMockAssert.test_assert_has_mock_calls_on_async_mock_with_speccCst||jjdddWdn1swYt||jjjdtjdWdn1s5wY||jjddddifdd d tjifgd ||jjjdd d tjifgd dS) Nr\)fishr)cake something)r\rizsomething_else.something)rrjz#method calls not recorded correctly)r7rsrkZsomething_elser ZCaker^ method_callsrrrr test_async_method_calls_recordedts     z0AsyncMockAssert.test_async_method_calls_recordedcsDfdd}|jt Wdn1swYtddWdn1s8wYtjddWdn1sRwYj|jtt}t |Wdn1sxwYt|jdddWdn1swY|||dS)Ncs@d}|D]}t||}|t|t|gqdS)N)rrlrc)getattrrPrlistr^)rsnamesr&attrrrr assert_attrss   z:AsyncMockAssert.test_async_arg_lists..assert_attrsrWr[r\)r.)rsr7rrrr)rrrrrrrtest_async_arg_listss,            z$AsyncMockAssert.test_async_arg_listscCsN|t |jWdn1swYt||jdSr)rrrsrzrrSrrrrtest_assert_awaiteds   z#AsyncMockAssert.test_assert_awaitedcCs|t |jWdn1swYt||jt||t|jWddS1sAwYdSr)rrrsrrrSrrrrtest_assert_awaited_onces       "z(AsyncMockAssert.test_assert_awaited_oncecCsd}|t||jdWdn1swYt|d}|t||jdWdn1s=wYt|d|jdt|d|t|jdWddS1smwYdS)Nz Not awaitedrlzexpected await not found SomethingElse)assertRaisesRegexrrsrrrSr)rmsgrrrtest_assert_awaited_withs   "z(AsyncMockAssert.test_assert_awaited_withcCs|t|jdWdn1swYt|d|jdt|d|t|jdWddS1sFwYdSr`)rrrsrrrSrrrrtest_assert_awaited_once_withs   "z-AsyncMockAssert.test_assert_awaited_once_withcCs|t|jdWdn1swYt|d|t|jdWdn1s8wYt|d|jdt|d|jddS)Nrlr>rv)rrrsrrrSrrrrtest_assert_any_waits   z$AsyncMockAssert.test_assert_any_waitcCstdtdg}|t}|j|Wdn1swY|t|jjdt | d|t|j|Wdn1sJwYt | d|t|j|Wdn1slwYt | d|j|t | d|j|dS)Nrlr>rWrv) rrrrsrr^len exceptionrrrS)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..FoocSrrrrotherrrr__eq__rz@AsyncMockAssert.test_awaits_asserts_with_any..Foo.__eq__Nr$r%r&rrrrrFoor,rrW)rrSrsrrrrr)rrrrrtest_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..FoocSrrrrrrrrrzIAsyncMockAssert.test_awaits_asserts_with_spec_and_any..Foo.__eq__Nrrrrrrr,rrcs|IdHdSrrr3Zmock_with_specrr_custom_mock_runnable_testszYAsyncMockAssert.test_awaits_asserts_with_spec_and_any.._custom_mock_runnable_testrW)rrrrrrr)rrrrrr%test_awaits_asserts_with_spec_and_anys   z5AsyncMockAssert.test_awaits_asserts_with_spec_and_anycCstdtdg}|t|jj|ddWdn1s wYt|d|t|jj|ddWdn1sDwYt|d|t|jj|ddWdn1shwYt|d|jj|ddt|d|jj|dddS)Nrlr>T)Z any_orderZbamfZqux)rrrrsrrrS)rr~rrrtest_assert_has_awaits_ordered s    z.AsyncMockAssert.test_assert_has_awaits_orderedcCsP|jt||t|jWddS1s!wYdSr)rsrrrSrrrrrrtest_assert_not_awaiteds    "z'AsyncMockAssert.test_assert_not_awaitedcCsd dd}t|d|_t|d|tdtd}|j t gWdn1s1wY| |j j |tdtd}|j t t ddgWdn1s`wY||j j tdS) Ncrrrrrrrf$rzIAsyncMockAssert.test_assert_has_awaits_not_matching_spec_error..frrWz^{}$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)]r[r)rrsrrSrwrformatreescaperrrr} __cause__rPr:)rrrrrr.test_assert_has_awaits_not_matching_spec_error#s2   z>AsyncMockAssert.test_assert_has_awaits_not_matching_spec_errorN)r$r%r&rRrSrUrYrZr[r]r^r_rarfrhrmrsrtruryrzr{rrrrrrrrrrrQs4        rQ__main__).rr5rFrr contextlibrrrrZ unittest.mockrrrr r r r r rrrrr*r-r1r2rAr3r$rLrr7ZTestCaser9r`rqrrrrrrr=rQrrrrrsH  0    =2"Tiy&rEI