Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/unittest/test/testmock/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/unittest/test/testmock/__pycache__/testasync.cpython-38.opt-1.pyc
U

@��gב�@svddlZddlZddlZddlZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
dd�ZGdd�d�ZGdd�d�Zd	d
�Zdd�Zd
d�ZGdd�de�Ze�d�Ze�d�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd �d ej �Z!Gd!d"�d"ej�Z"Gd#d$�d$ej�Z#Gd%d&�d&ej�Z$Gd'd(�d(ej�Z%dS))�N)	�ANY�call�	AsyncMock�patch�	MagicMock�Mock�create_autospec�sentinel�	_CallListcCst�d�dS�N)�asyncioZset_event_loop_policy�r
r
�?/opt/cppython/lib/python3.8/unittest/test/testmock/testasync.py�tearDownModule
src@s<eZdZdd�Zdd�Zdd�Zedd��Zed	d
��Z	dS)�
AsyncClasscCsdSrr
��selfr
r
r�__init__szAsyncClass.__init__c�sdSrr
rr
r
r�async_methodszAsyncClass.async_methodcCsdSrr
rr
r
r�
normal_methodszAsyncClass.normal_methodc�sdSrr
)�clsr
r
r�async_class_methodszAsyncClass.async_class_methodc�sdSrr
r
r
r
r�async_static_methodszAsyncClass.async_static_methodN)
�__name__�
__module__�__qualname__rrr�classmethodr�staticmethodrr
r
r
rrs
rc@seZdZdd�ZdS)�AwaitableClassccs
dVdSrr
rr
r
r�	__await__ szAwaitableClass.__await__N)rrrrr
r
r
rrsrc�sdSrr
r
r
r
r�
async_func#sr c�sdSrr
)�a�b�cr
r
r�async_func_args&sr$cCsdSrr
r
r
r
r�normal_func)sr%c@seZdZdd�ZdS)�NormalClasscCsdSrr
rr
r
rr!-sz
NormalClass.aN)rrrr!r
r
r
rr&,sr&z.AsyncClassz.NormalClassc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�AsyncPatchDecoratorTestcs"t�td��fdd��}|�dS)Nrcs��t�|��dSr)�
assertTruer�iscoroutinefunction��mock_methodrr
r�
test_async7szLAsyncPatchDecoratorTest.test_is_coroutine_function_patch.<locals>.test_async�r�objectr�rr,r
rr� test_is_coroutine_function_patch6s
z8AsyncPatchDecoratorTest.test_is_coroutine_function_patchcsBt�td��fdd��}tt�d���fdd��}|�|�dS)Nrcs$|�}��t�|��t�|�dSr�r(�inspect�isawaitabler�run�r+�mrr
rr,=sz?AsyncPatchDecoratorTest.test_is_async_patch.<locals>.test_asyncz
.async_methodcs$|�}��t�|��t�|�dSrr1r5rr
r�test_no_parent_attributeCszMAsyncPatchDecoratorTest.test_is_async_patch.<locals>.test_no_parent_attribute)rr.r�async_foo_name)rr,r7r
rr�test_is_async_patch<s
z+AsyncPatchDecoratorTest.test_is_async_patchcs"t�td��fdd��}|�dS)Nrcs��|t�dSr��assertIsInstancerr*rr
rr,MszCAsyncPatchDecoratorTest.test_is_AsyncMock_patch.<locals>.test_asyncr-r/r
rr�test_is_AsyncMock_patchLs
z/AsyncPatchDecoratorTest.test_is_AsyncMock_patchcs"t�td��fdd��}|�dS)Nrcs��|t�dSrr:r*rr
rr,TszPAsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethod.<locals>.test_asyncr-r/r
rr�$test_is_AsyncMock_patch_staticmethodSs
z<AsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethodcs"t�td��fdd��}|�dS)Nrcs��|t�dSrr:r*rr
rr,[szOAsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethod.<locals>.test_asyncr-r/r
rr�#test_is_AsyncMock_patch_classmethodZs
z;AsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethodcsPtt�d�dd�tt�d�dd��fdd���}t�|����t�t��dS)N�.async_func���return_value�.async_func_args�c�sh��|jd���|jd���tt���tt���t�IdHd���tdddd�IdHd�dS)Nr$r r@rD��r#)�assertEqualZ
_mock_namer;r rr$)Zfunc_args_mockZ	func_mockrr
rr,bsz@AsyncPatchDecoratorTest.test_async_def_patch.<locals>.test_async)rrrr4r(r2r)r r/r
rr�test_async_def_patchas

z,AsyncPatchDecoratorTest.test_async_def_patchN)	rrrr0r9r<r=r>rHr
r
r
rr'5sr'c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AsyncPatchCMTestcs�fdd�}|�dS)Nc	s,t�td��}��t�|��W5QRXdS�Nr)rr.rr(rr)r*rr
rr,tsz>AsyncPatchCMTest.test_is_async_function_cm.<locals>.test_asyncr
r/r
rr�test_is_async_function_cmssz*AsyncPatchCMTest.test_is_async_function_cmcs�fdd�}|�dS)Nc	s<t�td��&}|�}��t�|��t�|�W5QRXdSrJ)rr.rr(r2r3rr4r5rr
rr,{sz5AsyncPatchCMTest.test_is_async_cm.<locals>.test_asyncr
r/r
rr�test_is_async_cmzsz!AsyncPatchCMTest.test_is_async_cmcs�fdd�}|�dS)Nc	s(t�td��}��|t�W5QRXdSrJ)rr.rr;rr*rr
rr,�sz9AsyncPatchCMTest.test_is_AsyncMock_cm.<locals>.test_asyncr
r/r
rr�test_is_AsyncMock_cm�sz%AsyncPatchCMTest.test_is_AsyncMock_cmcs�fdd�}t�|��dS)Nc	�s>tt�d�t�����tt�W5QRX��t�t��dS)Nr?)rrrr;r r(r2r)r
rr
rr,�sz6AsyncPatchCMTest.test_async_def_cm.<locals>.test_async�rr4r/r
rr�test_async_def_cm�sz"AsyncPatchCMTest.test_async_def_cmN)rrrrKrLrMrOr
r
r
rrIrs	rIc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
AsyncMockTestcCst�}|�t�|��dSr)rr(rr)�r�mockr
r
r� test_iscoroutinefunction_default�sz.AsyncMockTest.test_iscoroutinefunction_defaultcCs4dd�}t|�}|�t�|��|�t�|��dS)Nc�sdSrr
r
r
r
r�foo��z<AsyncMockTest.test_iscoroutinefunction_function.<locals>.foo�rr(rr)r2�rrTrRr
r
r�!test_iscoroutinefunction_function�sz/AsyncMockTest.test_iscoroutinefunction_functioncCs:t�}|�}|�t�|��t�|�|�dt|��dS)N�assert_awaited)rr(r2r3rr4ZassertIn�dir�rrRr6r
r
r�test_isawaitable�s

zAsyncMockTest.test_isawaitablecCs4dd�}t|�}|�t�|��|�t�|��dS)NcSsdSrr
r
r
r
rrT�rUzCAsyncMockTest.test_iscoroutinefunction_normal_function.<locals>.foorVrWr
r
r�(test_iscoroutinefunction_normal_function�sz6AsyncMockTest.test_iscoroutinefunction_normal_functioncCsDt��}t�|�t��}|��|��t|�}|�|tj�dSr)rZnew_event_loopZset_event_loop�Future�stop�closerr;)rZloop�futrRr
r
r�test_future_isfuture�s
z"AsyncMockTest.test_future_isfutureN)rrrrSrXr\r]rbr
r
r
rrP�s
rPc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�AsyncAutospecTestcs@ttdd��fdd��}ttdd��fdd��}|�|�dS)NT�Zautospeccs��|jt���|t�dSr�r;rrrr*rr
rr,�sz=AsyncAutospecTest.test_is_AsyncMock_patch.<locals>.test_asynccs��|jt�dSr)r;rrr*rr
r�test_normal_method�szEAsyncAutospecTest.test_is_AsyncMock_patch.<locals>.test_normal_method�rr8)rr,rfr
rrr<�s

z)AsyncAutospecTest.test_is_AsyncMock_patchc	Cs&|�t��ttdd�W5QRXdS)NT)�instance)�assertRaises�RuntimeErrorrr rr
r
r�test_create_autospec_instance�sz/AsyncAutospecTest.test_create_autospec_instancecCs tt�d�}|�t|�t�dS�N��spec)rrr;r)rZawaitable_mockr
r
r�$test_create_autospec_awaitable_class�sz6AsyncAutospecTest.test_create_autospec_awaitable_classcs�tt�}|dddd���fdd�}|�|jd�|�|j�|�|jg�|��t�	|��|�
t�|��|�
t����|�|jd�|�|jt
dddd��|�|jt
dddd�g�|��|jdddd�|jdddd�|��dS)Nr@rDrErFc�s�IdHdSrr
r
��	awaitabler
r�main�sz4AsyncAutospecTest.test_create_autospec.<locals>.mainr)rr$rG�await_count�assertIsNone�
await_args�await_args_list�assert_not_awaitedrr4r(r)�iscoroutiner�assert_awaited_once�assert_awaited_once_with�assert_awaited_withrY)rrnrrr
rpr�test_create_autospec�s"z&AsyncAutospecTest.test_create_autospeccs�fdd�}t�|��dS)Nc	�sHtt�d�dd���}|dddd�}��|jt���t�|����t�|����t	�
|����|jd���|j
g���|j�|��|IdHW5QRX��|jd���|jtdddd����|j
tdddd�g�|��|jdddd�|jdddd�|��|����|jd���|j���|j
g�dS)	NrCTrdr@rDrErFr)rrr;rRrr(rr)rxr2r3rGrsrvrtrurwrryrzr{rY�
reset_mock)r+rqrr
rr,�s,z>AsyncAutospecTest.test_patch_with_autospec.<locals>.test_asyncrNr/r
rr�test_patch_with_autospec�sz*AsyncAutospecTest.test_patch_with_autospecN)rrrr<rkror|r~r
r
r
rrc�s

rcc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�
AsyncSpecTestc
sB�fdd�}ttfD](}��d|����||�W5QRXqdS)Ncs(|t�}��|jt���|jt�dSr)rr;rrrr)�	mock_typerRrr
r�
inner_testszCAsyncSpecTest.test_spec_normal_methods_on_class.<locals>.inner_testztest method types with �rr�subTest�rr�r�r
rr�!test_spec_normal_methods_on_classsz/AsyncSpecTest.test_spec_normal_methods_on_classcCs(tt�}|�|jt�|�|jt�dSr)rrr;rrrrQr
r
r�+test_spec_normal_methods_on_class_with_mocksz9AsyncSpecTest.test_spec_normal_methods_on_class_with_mockc
sD�fdd�}tttfD](}��d|����||�W5QRXqdS)Nc	sX|td�}��||���t����t�|���W5QRX|td�}��||�dSrl�r r;�assertWarns�RuntimeWarningr(r2r3r%�r��
async_mockZ	sync_mockrr
rr�s

z8AsyncSpecTest.test_spec_mock_type_kw.<locals>.inner_testztest spec kwarg with �rrrr�r�r
rr�test_spec_mock_type_kws
z$AsyncSpecTest.test_spec_mock_type_kwc
sD�fdd�}tttfD](}��d|����||�W5QRXqdS)Nc	sT|t�}��||���t����t�|���W5QRX|t�}��||�dSrr�r�rr
rr�%sz@AsyncSpecTest.test_spec_mock_type_positional.<locals>.inner_testztest spec positional with r�r�r
rr�test_spec_mock_type_positional$s
z,AsyncSpecTest.test_spec_mock_type_positionalcCs:ttd�}|�|t�|�}|�t�|��t�|�dSrl�rr%r;r(r2r3rr4r[r
r
r� test_spec_as_normal_kw_AsyncMock3s

z.AsyncSpecTest.test_spec_as_normal_kw_AsyncMockcCs8tt�}|�|t�|�}|�t�|��t�|�dSrr�r[r
r
r�(test_spec_as_normal_positional_AsyncMock:s
z6AsyncSpecTest.test_spec_as_normal_positional_AsyncMockcs&tjtddd��fdd��}|�dS)NrTrmcs��|t�dSrr:r*rr
rr,Bsz6AsyncSpecTest.test_spec_async_mock.<locals>.test_asyncr-r/r
rr�test_spec_async_mockAsz"AsyncSpecTest.test_spec_async_mockcs"ttdd��fdd��}|�dS)NTrmcs��|t���|jt�dSr)r;rrrr*rr
rr,IszIAsyncSpecTest.test_spec_parent_not_async_attribute_is.<locals>.test_asyncrgr/r
rr�'test_spec_parent_not_async_attribute_isHs
z5AsyncSpecTest.test_spec_parent_not_async_attribute_iscs(tjtdtjd��fdd��}|�dS)Nrrmcs0��|t���t�|����t�|��dSr)r;r�assertFalser2rxr3r*rr
r�test_async_attributeQszFAsyncSpecTest.test_target_async_spec_not.<locals>.test_async_attribute)rr.rr&r!)rr�r
rr�test_target_async_spec_notPsz(AsyncSpecTest.test_target_async_spec_notcs&tjtdtd��fdd��}|�dS)Nr!rmcs��|t�dSrr:)Zmock_async_funcrr
r� test_attribute_not_async_spec_isZszUAsyncSpecTest.test_target_not_async_spec_is.<locals>.test_attribute_not_async_spec_is)rr.r&r )rr�r
rr�test_target_not_async_spec_isYsz+AsyncSpecTest.test_target_not_async_spec_iscs"tttd��fdd��}|�dS)Nrmcs��|jt���|t�dSrre)ZMockNormalClassrr
r� test_async_attributes_coroutines`szRAsyncSpecTest.test_spec_async_attributes.<locals>.test_async_attributes_coroutines)r�normal_foo_namer)rr�r
rr�test_spec_async_attributes_s
z(AsyncSpecTest.test_spec_async_attributesN)rrrr�r�r�r�r�r�r�r�r�r�r�r
r
r
rrs
	rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AsyncSpecSetTestcs tjtddd��fdd��}dS)NrT�Zspec_setcs��|t�dSrr:)rrr
rr,jsz<AsyncSpecSetTest.test_is_AsyncMock_patch.<locals>.test_asyncr-r/r
rrr<isz(AsyncSpecSetTest.test_is_AsyncMock_patchcCs,ttjd�}|�t�|��|�|t�dS�Nr�)rrrr(rr)r;rQr
r
r�test_is_async_AsyncMocknsz(AsyncSpecSetTest.test_is_async_AsyncMockcCsZttd�}|�t�|j��|�t�|j��|�|jt	�|�|jt�|�|t�dSr�)
rrr(rr)rr�rr;rrQr
r
r�test_is_child_AsyncMockss
z(AsyncSpecSetTest.test_is_child_AsyncMockc	Cs>t�}tdd�d�|_t�|d��}|�|t�W5QRXdS)NcSs|Srr
��xr
r
r�<lambda>}rUz=AsyncSpecSetTest.test_magicmock_lambda_spec.<locals>.<lambda>rm�	mock_func)rr�rr.r;)rZmock_obj�cmr
r
r�test_magicmock_lambda_spec{sz+AsyncSpecSetTest.test_magicmock_lambda_specN)rrrr<r�r�r�r
r
r
rr�hsr�c@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�AsyncArgumentsc�s2dd�}t|dd�}|d�IdH}|�|d�dS)Nc�s|dS�Nr@r
)r�varr
r
r�addition�sz6AsyncArguments.test_add_return_value.<locals>.addition�
rA��rrG)rr�rR�outputr
r
r�test_add_return_value�sz$AsyncArguments.test_add_return_valuec	�s@dd�}t|td�d�}|�t��|d�IdHW5QRXdS)Nc�s|dSr�r
�r�r
r
rr��sz?AsyncArguments.test_add_side_effect_exception.<locals>.addition�err�Zside_effectr�)r�	Exceptionri)rr�rRr
r
r�test_add_side_effect_exception�sz-AsyncArguments.test_add_side_effect_exceptionc�s0dd�}t|d�}|d�IdH}|�|d�dS)Nc�s|dSr�r
r�r
r
rr��sz?AsyncArguments.test_add_side_effect_coroutine.<locals>.additionr�r��r��rr�rR�resultr
r
r�test_add_side_effect_coroutine�s
z-AsyncArguments.test_add_side_effect_coroutinec�s0dd�}t|d�}|d�IdH}|�|d�dS)NcSs|dSr�r
r�r
r
rr��szEAsyncArguments.test_add_side_effect_normal_function.<locals>.additionr�r�r�r�r�r
r
r�$test_add_side_effect_normal_function�s
z3AsyncArguments.test_add_side_effect_normal_functionc	�sXdddg}t|d�}|D]}|�|�IdH|�q|�t��}|�IdHW5QRXdS)Nr@rDrEr�)rrGri�StopAsyncIteration)r�valsrR�item�er
r
r�test_add_side_effect_iterable�s

z,AsyncArguments.test_add_side_effect_iterablec	�s`Gdd�dt�}d|d�g}t|d�}|�|�IdHd�|�|��}|�IdHW5QRXdS)Nc@seZdZdS)zOAsyncArguments.test_add_side_effect_exception_iterable.<locals>.SampleExceptionN)rrrr
r
r
r�SampleException�sr�r@rTr�)r�rrGri)rr�r�rRr�r
r
r�'test_add_side_effect_exception_iterable�s
z6AsyncArguments.test_add_side_effect_exception_iterablec�s0tdd�}t|d�}|�IdH}|�||�dS)Nr�rA)r�assertIs)r�valuerRr�r
r
r�test_return_value_AsyncMock�s

z*AsyncArguments.test_return_value_AsyncMockc�s:t��}|�d�t|d�}|�IdH}|�|tj�dS)NrA)rr^�
set_resultrr;�rrarRr�r
r
r�test_return_value_awaitable�s


z*AsyncArguments.test_return_value_awaitablec	�s^t��}|�d�t|gd�}|�IdH}|�|tj�|�t��|�IdHW5QRXdS)Nr�)rr^r�rr;rir�r�r
r
r�!test_side_effect_awaitable_values�s
z0AsyncArguments.test_side_effect_awaitable_valuesc�s0tdd�}t|d�}|�IdH}|�|d�dS)Nr�rAr�r�)rZeffectrRr�r
r
r�test_side_effect_is_AsyncMock�s

z,AsyncArguments.test_side_effect_is_AsyncMockc�sRt���d���fdd�}t|d�}|�IdH}|�|��|��|���dS)NFc�sd��S�NTr
r
�Zranr�r
r�inner�sz2AsyncArguments.test_wraps_coroutine.<locals>.inner��wraps)rr^rrGrYr(�rr�rRr�r
r�r�test_wraps_coroutine�s
z#AsyncArguments.test_wraps_coroutinec�sNd�d���fdd�}t|d�}|�IdH}|�|��|��|���dS)Nr@Fcsd��Sr�r
r
r�r
rr��sz8AsyncArguments.test_wraps_normal_function.<locals>.innerr�)rrGrYr(r�r
r�r�test_wraps_normal_function�s
z)AsyncArguments.test_wraps_normal_functionc�sxt�}|d�}|d�}|IdH|IdH|�td�td�g�|�|jtd�td�g�|�|jtd�td�g�dS)NrDr@)r�assert_has_awaitsrrGrv�call_args_list)rr�Zmock2Zmock1r
r
r�test_await_args_list_order�s

z)AsyncArguments.test_await_args_list_orderN)rrrr�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr��s		r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�AsyncMagicMethodscCsBt�}|�|jt�|�|jt�|�|jt�|�|jt�dSr)rr;�
__aenter__r�	__aexit__�	__anext__�	__aiter__�rZm_mockr
r
r�+test_async_magic_methods_return_async_mocks�s
z=AsyncMagicMethods.test_async_magic_methods_return_async_mockscCsBt�}|�|jt�|�|jt�|�|jt�|�|jt�dSr)rr;�	__enter__r�__exit__�__next__�__len__�r�a_mockr
r
r�*test_sync_magic_methods_return_magic_mockss
z<AsyncMagicMethods.test_sync_magic_methods_return_magic_mockscCs:t�}|�t|d��|�t|d��|�t|d��dS)Nr�r�r�)rr(�hasattrr�r
r
r�&test_magicmock_has_async_magic_methodssz8AsyncMagicMethods.test_magicmock_has_async_magic_methodscCsJt�}|�t|d��|�t|d��|�t|d��|�t|d��dS)Nr�r�r�r�)rr(r�r�r
r
r�%test_asyncmock_has_sync_magic_methodss
z7AsyncMagicMethods.test_asyncmock_has_sync_magic_methodscCsJt�}|�|jt�|�|jt�|�t�|j��|�t�|j��dSr)rr;r�rr�r(rr)r�r
r
r�&test_magic_methods_are_async_functionss
z8AsyncMagicMethods.test_magic_methods_are_async_functionsN)rrrr�r�r�r�r�r
r
r
rr��s
	r�c@s^eZdZGdd�d�ZGdd�d�ZGdd�d�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�AsyncContextManagerTestc@seZdZdd�Zdd�ZdS)z/AsyncContextManagerTest.WithAsyncContextManagerc�s
d|_|Sr�)Zentered�r�args�kwargsr
r
rr�&sz:AsyncContextManagerTest.WithAsyncContextManager.__aenter__c�s
d|_dSr�)Zexitedr�r
r
rr�*sz9AsyncContextManagerTest.WithAsyncContextManager.__aexit__N)rrrr�r�r
r
r
r�WithAsyncContextManager%sr�c@seZdZdd�Zdd�ZdS)z.AsyncContextManagerTest.WithSyncContextManagercOs|Srr
r�r
r
rr�.sz8AsyncContextManagerTest.WithSyncContextManager.__enter__cOsdSrr
r�r
r
rr�1sz7AsyncContextManagerTest.WithSyncContextManager.__exit__N)rrrr�r�r
r
r
r�WithSyncContextManager-sr�c@seZdZdd�Zdd�ZdS)z&AsyncContextManagerTest.ProductionCodecCs
d|_dSr)�sessionrr
r
rr6sz/AsyncContextManagerTest.ProductionCode.__init__c�sJ|j�d�4IdH�&}|��IdH}|W5QIdHR�SQIdHRXdS)Nzhttps://python.org)r��post�json)r�response�valr
r
rrr9sz+AsyncContextManagerTest.ProductionCode.mainN)rrrrrrr
r
r
r�ProductionCode4sr�c
sB�fdd�}ttfD](}��d|����||�W5QRXqdS)Ncsl���}tdd�|_|dd�}tdd�}tddid�|_||j_||jj_t�	|�
��}��|ddi�dS)NZsessionmock��nameZmagic_cmr�r��{rA)r�rr�rr�r�rBr�rr4rrrG)r�Zpcr�r�r�rr
rr�?s


zKAsyncContextManagerTest.test_set_return_value_of_aenter.<locals>.inner_testz%test set return value of aenter with r�r�r
rr�test_set_return_value_of_aenter>sz7AsyncContextManagerTest.test_set_return_value_of_aenterc
sB�fdd�}ttfD](}��d|����||�W5QRXqdS)Ncsxd����}||����fdd�}t�|��}�������jj����jj��j���j�����|�dS)NFc
�s&�4IdH�
}d�W5QIdHRX|Sr�r
�r���calledZcm_mockr
r�use_context_managerTszqAsyncContextManagerTest.test_mock_supports_async_context_manager.<locals>.inner_test.<locals>.use_context_manager)	r�rr4r(r�r�r�rYZassertIsNot)r�r�r�Z	cm_resultrr�rr�Os


zTAsyncContextManagerTest.test_mock_supports_async_context_manager.<locals>.inner_testz!test context manager magics with r�r�r
rr�(test_mock_supports_async_context_managerNsz@AsyncContextManagerTest.test_mock_supports_async_context_managercsB|��}t|��t�}|�j_�fdd�}|�t�|��|�dS)Nc�s4�4IdH�}|W5QIdHR�SQIdHRXdSrr
r���
mock_instancer
rr�nsz^AsyncContextManagerTest.test_mock_customize_async_context_manager.<locals>.use_context_manager)r�rr.r�rBr�rr4)rrhZexpected_resultr�r
r�r�)test_mock_customize_async_context_managergszAAsyncContextManagerTest.test_mock_customize_async_context_managercsld�d��fdd�}�fdd�}|��}t|��|�_|�_�fdd�}t�|��|���|���dS)NFc�sd�dSr�r
�r�)�enter_calledr
r�enter_coroutinexsziAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.enter_coroutinec�sd�dSr�r
r�)�exit_calledr
r�exit_coroutine|szhAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.exit_coroutinec
�s"�4IdH�W5QIdHRXdSrr
r
r�r
rr��szmAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.use_context_manager)r�rr�r�rr4r()rrrrhr�r
)r�rr�r�8test_mock_customize_async_context_manager_with_coroutinets
zPAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutinec	Cs@dd�}|��}t|�}|�t��t�||��W5QRXdS)Nc
�s(|4IdH�t��W5QIdHRXdSr)�	TypeError)Zcontext_managerr
r
r�raise_in�szYAsyncContextManagerTest.test_context_manager_raise_exception_by_default.<locals>.raise_in)r�rrirrr4)rrrhr�r
r
r�/test_context_manager_raise_exception_by_default�s
zGAsyncContextManagerTest.test_context_manager_raise_exception_by_defaultN)rrrr�r�r�r�r�r�rrr
r
r
rr�$s

r�c@s4eZdZGdd�de�Zdd�Zdd�Zdd�Zd	S)
�AsyncIteratorTestc@s$eZdZdd�Zdd�Zdd�ZdS)z#AsyncIteratorTest.WithAsyncIteratorcCsdddg|_dS)NrTZ	NormalFoo�baz)�itemsrr
r
rr�sz,AsyncIteratorTest.WithAsyncIterator.__init__cCs|Srr
rr
r
rr��sz-AsyncIteratorTest.WithAsyncIterator.__aiter__c�s*z|j��WStk
r YnXt�dSr)r	�pop�
IndexErrorr�rr
r
rr��s
z-AsyncIteratorTest.WithAsyncIterator.__anext__N)rrrrr�r�r
r
r
r�WithAsyncIterator�srcsFtdd��dddg�j_�fdd�}t�|��}|�|dddg�dS)NZtesterr�r@rDrEc�sdd��2�IdHS)Nc�sg|z3dHW}|�q6Srr
)�.0�ir
r
r�
<listcomp>�szOAsyncIteratorTest.test_aiter_set_return_value.<locals>.main.<locals>.<listcomp>r
r
�Z	mock_iterr
rrr�sz;AsyncIteratorTest.test_aiter_set_return_value.<locals>.main)rr�rBrr4rG)rrrr�r
rr�test_aiter_set_return_value�s

z-AsyncIteratorTest.test_aiter_set_return_valuec
sB�fdd�}ttfD](}��d|����||�W5QRXqdS)Ncs\���}||�}��t�|j����t�|j����t�|j����t�|j��dSr)rr�rr)r�r(r�)r�rhr�rr
rr��szIAsyncIteratorTest.test_mock_aiter_and_anext_asyncmock.<locals>.inner_testz%test aiter and anext corourtine with r�r�r
rr�#test_mock_aiter_and_anext_asyncmock�sz5AsyncIteratorTest.test_mock_aiter_and_anext_asyncmockc
s�dd��dddg���fdd�}���fdd	�}���fd
d�}ttfD]p}��d|����||�W5QRX��d
|����||�W5QRX��d|����||�W5QRXqHdS)Nc�s&g}|2z3dHW}|�|�q6|Sr)�append)�iteratorZaccumulatorr�r
r
r�iterate�sz6AsyncIteratorTest.test_mock_async_for.<locals>.iterateZFOOZBARZBAZcs&|����}��t��|��g�dSr)rrGrr4�r�r�)rrr
r�test_default�sz;AsyncIteratorTest.test_mock_async_for.<locals>.test_defaultcs6|����}�dd�|j_��t��|����dSr)rr�rBrGrr4r�Zexpectedrrr
r�test_set_return_value�szDAsyncIteratorTest.test_mock_async_for.<locals>.test_set_return_valuecs:|����}t�dd��|j_��t��|����dSr)r�iterr�rBrGrr4rrr
r�test_set_return_value_iter�szIAsyncIteratorTest.test_mock_async_for.<locals>.test_set_return_value_iterzdefault value with zset return_value with zset return_value iterator with r�)rrrrr�r
rr�test_mock_async_for�s
z%AsyncIteratorTest.test_mock_async_forN)rrrr.rrrrr
r
r
rr�src@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/S)0�AsyncMockAssertcCst�|_dSr)rrRrr
r
r�setUp�szAsyncMockAssert.setUpc�s|j||�IdHdSr)rRr�r
r
r�_runnable_test�szAsyncMockAssert._runnable_testc�s
|IdHSrr
)r�	coroutiner
r
r�_await_coroutine�sz AsyncMockAssert._await_coroutinec	Cs�tt�}|�t��|��W5QRX|�t�|j��|j��|j�	�|j�
�|�t��|�
�W5QRX|�t��|j�
�W5QRXdSr)rrr�r�rr(rr)�
assert_called�assert_called_once�assert_called_once_withri�AssertionErrorrYrQr
r
r�"test_assert_called_but_not_awaited�s


z2AsyncMockAssert.test_assert_called_but_not_awaitedc	Cs�tt�}|��}|j��|j��|j��|�t��|j��W5QRXt	�
|�|��|j��|j��|j��|j�
�dSr)rrrr"r#r$rir%rYrr4r!ryrz)rrRZmock_coroutiner
r
r�test_assert_called_then_awaited�s





z/AsyncMockAssert.test_assert_called_then_awaitedc	Csf|�t��|j��W5QRX|�t��|j��W5QRXt�|���|j��|j�	�dSr)
rir%rRrYr"rr4rr#ryrr
r
r�+test_assert_called_and_awaited_at_same_time
s
z;AsyncMockAssert.test_assert_called_and_awaited_at_same_timec	Cs�tt�}|��}|�t��|��W5QRX|�t��|j��W5QRX|j��t	�
|�|��|j��|j��dSr)
rrrr�r�rir%rYr"rr4r!ry�rrRr r
r
r�)test_assert_called_twice_and_awaited_onces

z9AsyncMockAssert.test_assert_called_twice_and_awaited_oncec	Cs^tt�}|��}|j��t�|�|��|�t��t�|�|��W5QRX|j�	�dSr)
rrrr#rr4r!rirjrYr)r
r
r�)test_assert_called_once_and_awaited_twice&s
z9AsyncMockAssert.test_assert_called_once_and_awaited_twicec	Cs�|�t��|j��W5QRX|�t��|j��W5QRX|�t��t�|�|j��W5QRX|�t��|j��W5QRX|�t��|j��W5QRXdSr)	rir%rRrYr"rrr4r!rr
r
r�"test_assert_awaited_but_not_called0sz2AsyncMockAssert.test_assert_awaited_but_not_calledc	Cs\td�g}|�t��|�d�W5QRX|j�|�|�t��|j�|�W5QRXdS�NrT)rr�r�rRZassert_has_callsrir%r�)rZkallsr
r
r� test_assert_has_calls_not_awaits>s
z0AsyncMockAssert.test_assert_has_calls_not_awaitsc	Cs�|�t��|��W5QRXddifg}|�|jj|�|�t��|�d�|�d�W5QRXt�td�td�g}|�|jj|�dS)N�r
rTr)r�r�rRrG�
mock_callsr)r�kalls_empty�
mock_kallsr
r
r�0test_assert_has_mock_calls_on_async_mock_no_specGs
z@AsyncMockAssert.test_assert_has_mock_calls_on_async_mock_no_specc	Cs�tt�}|�t��|��W5QRXddifg}|�|jj|�|�|jt��g�|�t��|jdddddd�W5QRXt�tdddddd�g}t��tjdddddd�g}|�|jj|�|�|j|�dS)	Nr/r
r@rDrE�r�)r!r")rrr�r�rrGr0r)rZa_class_mockr1Zmethod_kallsr2r
r
r�2test_assert_has_mock_calls_on_async_mock_with_specUszBAsyncMockAssert.test_assert_has_mock_calls_on_async_mock_with_specc	Cs�|�t��*|jjddd�|jjjdtjd�W5QRX|�|jjddddifdd	d
tjifgd�|�|jjjdd	d
tjifgd�dS)NrE)�fishr�)�cake�	something)rEr6zsomething_else.something)r�r7z#method calls not recorded correctly)	r�r�rRr8Zsomething_elser	ZCakerG�method_callsrr
r
r� test_async_method_calls_recordedfs
���z0AsyncMockAssert.test_async_method_calls_recordedc	s��fdd�}|�j���t��&�����dd��jdd�W5QRX�j��|�j�tt�}��t��|��|jddd�W5QRX|��||�dS)Ncs@d}|D]2}t||�}��|t���|t���|g�qdS)N)r�r9r0)�getattrr;r
�listrG)rR�namesr��attrrr
r�assert_attrsvs
z:AsyncMockAssert.test_async_arg_lists.<locals>.assert_attrsr@rDrE)r!)rRr�r�r}rrr)rr?r�r
rr�test_async_arg_listsus


z$AsyncMockAssert.test_async_arg_listsc	Cs<|�t��|j��W5QRXt�|���|j��dSr)rir%rRrYrr4rrr
r
r�test_assert_awaited�sz#AsyncMockAssert.test_assert_awaitedc	Csj|�t��|j��W5QRXt�|���|j��t�|���|�t��|j��W5QRXdSr)rir%rRryrr4rrr
r
r�test_assert_awaited_once�s
z(AsyncMockAssert.test_assert_awaited_oncec	Cs�d}|�t|��|j�d�W5QRXt�|���d}|�t|��|j�d�W5QRXt�|�d��|j�d�t�|�d��|�t��|j�d�W5QRXdS)NzNot awaitedrTzexpected await not found�
SomethingElse)�assertRaisesRegexr%rRr{rr4rri)r�msgr
r
r�test_assert_awaited_with�sz(AsyncMockAssert.test_assert_awaited_withc	Cst|�t��|j�d�W5QRXt�|�d��|j�d�t�|�d��|�t��|j�d�W5QRXdSr-)rir%rRrzrr4rrr
r
r�test_assert_awaited_once_with�sz-AsyncMockAssert.test_assert_awaited_once_withc	Cs�|�t��|j�d�W5QRXt�|�d��|�t��|j�d�W5QRXt�|�d��|j�d�t�|�d��|j�d�dS)NrTrrC)rir%rRZassert_any_awaitrr4rrr
r
r�test_assert_any_wait�sz$AsyncMockAssert.test_assert_any_waitc	Cs�td�td�g}|�t��}|j�|�W5QRX|�t|jj�d�t	�
|�d��|�t��|j�|�W5QRXt	�
|�d��|�t��|j�|�W5QRXt	�
|�d��|j�|�t	�
|�d��|j�|�dS)NrTrr@rC)rrir%rRr�rG�len�	exceptionr�rr4r)r�callsr�r
r
r�test_assert_has_awaits_no_order�sz/AsyncMockAssert.test_assert_has_awaits_no_orderc	Cs�td�td�g}|�t��|jj|dd�W5QRXt�|�d��|�t��|jj|dd�W5QRXt�|�d��|�t��|jj|dd�W5QRXt�|�d��|jj|dd�t�|�d��|jj|dd�dS)NrTrT)Z	any_orderZbamfZqux)rrir%rRr�rr4r)rrKr
r
r�test_assert_has_awaits_ordered�sz.AsyncMockAssert.test_assert_has_awaits_orderedc	Cs<|j��t�|���|�t��|j��W5QRXdSr)rRrwrr4rrir%rr
r
r�test_assert_not_awaited�s
z'AsyncMockAssert.test_assert_not_awaitedc	Cs�d	dd�}t|d�|_t�|�d��|�td�t�	d����}|j�
t�g�W5QRX|�|j
j�|�td�t�	d����}|j�
t�tdd�g�W5QRX|�|j
jt�dS)
Nc�sdSrr
r�r
r
r�f�rUzIAsyncMockAssert.test_assert_has_awaits_not_matching_spec_error.<locals>.frmr@z^{}$z6Awaits not found.
Expected: [call()]
Actual: [call(1)]z�Error processing expected awaits.
Errors: [None, TypeError('too many positional arguments')]
Expected: [call(), call(1, 2)]
Actual: [call(1)]rD)N)rrRrr4rrDr%�format�re�escaper�rrtrJ�	__cause__r;r)rrOr�r
r
r�.test_assert_has_awaits_not_matching_spec_error�s.
�����"z>AsyncMockAssert.test_assert_has_awaits_not_matching_spec_errorN)rrrrrr!r&r'r(r*r+r,r.r3r5r:r@rArBrFrGrHrLrMrNrTr
r
r
rr�s.
	r)&rr2rQZunittestZ
unittest.mockrrrrrrrr	r
rrrr r$r%r.r&rr8r�ZTestCaser'rIrPrcrr�ZIsolatedAsyncioTestCaser�r�r�rrr
r
r
r�<module>s0,

=!"Pc{&uL

F1le Man4ger