Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/unittest/test/testmock/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/unittest/test/testmock/__pycache__/testasync.cpython-39.opt-1.pyc

a

��gV��@s�ddlZddlZddlZddlZddlZddlmZddlmZmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZmZdd�ZGdd	�d	�ZGd
d�d�Zdd
�Zdd�Zdd�ZGdd�de�Ze�d�Ze�d�Zedd��ZGdd�dej �Z!Gdd�dej �Z"Gdd�dej �Z#Gdd�dej �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)�run�iscoroutinefunction)�IsolatedAsyncioTestCase)	�ANY�call�	AsyncMock�patch�	MagicMock�Mock�create_autospec�sentinel�	_CallListcCst�d�dS�N)�asyncioZset_event_loop_policy�rr�</usr/local/lib/python3.9/unittest/test/testmock/testasync.py�tearDownModulesrc@s<eZdZdd�Zdd�Zdd�Zedd��Zed	d
��Z	dS)�
AsyncClasscCsdSrr��selfrrr�__init__�zAsyncClass.__init__c�sdSrrrrrr�async_methodrzAsyncClass.async_methodcCsdSrrrrrr�
normal_methodrzAsyncClass.normal_methodc�sdSrr)�clsrrr�async_class_methodszAsyncClass.async_class_methodc�sdSrrrrrr�async_static_methodszAsyncClass.async_static_methodN)
�__name__�
__module__�__qualname__rrr�classmethodr�staticmethodrrrrrrs
rc@seZdZdd�ZdS)�AwaitableClassccs
dVdSrrrrrr�	__await__rzAwaitableClass.__await__N)rrr r$rrrrr#sr#c�sdSrrrrrr�
async_func!rr%c�sdSrr)�a�b�crrr�async_func_args#rr)cCsdSrrrrrr�normal_func%rr*c@seZdZdd�ZdS)�NormalClasscCsdSrrrrrrr&(rz
NormalClass.aN)rrr r&rrrrr+'sr+z.AsyncClassz.NormalClassccs>|�td��dVt��Wd�n1s00YdS)Nzwas never awaited$)ZassertWarnsRegex�RuntimeWarning�gcZcollect)�testrrr�assertNeverAwaited/sr/c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�AsyncPatchDecoratorTestcs"t�td��fdd��}|�dS)Nrcs��t|��dSr)�
assertTruer��mock_methodrrr�
test_async:szLAsyncPatchDecoratorTest.test_is_coroutine_function_patch.<locals>.test_async�r	�objectr�rr4rrr� test_is_coroutine_function_patch9s
z8AsyncPatchDecoratorTest.test_is_coroutine_function_patchcsBt�td��fdd��}tt�d���fdd��}|�|�dS)Nrcs"|�}��t�|��t|�dSr�r1�inspect�isawaitabler�r3�mrrrr4@sz?AsyncPatchDecoratorTest.test_is_async_patch.<locals>.test_asyncz
.async_methodcs"|�}��t�|��t|�dSrr9r<rrr�test_no_parent_attributeFszMAsyncPatchDecoratorTest.test_is_async_patch.<locals>.test_no_parent_attribute)r	r6r�async_foo_name)rr4r>rrr�test_is_async_patch?s
z+AsyncPatchDecoratorTest.test_is_async_patchcs"t�td��fdd��}|�dS)Nrcs��|t�dSr��assertIsInstancerr2rrrr4PszCAsyncPatchDecoratorTest.test_is_AsyncMock_patch.<locals>.test_asyncr5r7rrr�test_is_AsyncMock_patchOs
z/AsyncPatchDecoratorTest.test_is_AsyncMock_patchcs"t�td��fdd��}|�dS)Nrcs��|t�dSrrAr2rrrr4WszPAsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethod.<locals>.test_asyncr5r7rrr�$test_is_AsyncMock_patch_staticmethodVs
z<AsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethodcs"t�td��fdd��}|�dS)Nrcs��|t�dSrrAr2rrrr4^szOAsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethod.<locals>.test_asyncr5r7rrr�#test_is_AsyncMock_patch_classmethod]s
z;AsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethodcsNtt�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%rGrK��r()�assertEqualZ
_mock_namerBr%rr))Zfunc_args_mockZ	func_mockrrrr4esz@AsyncPatchDecoratorTest.test_async_def_patch.<locals>.test_async)r	rrr1r:rr%r7rrr�test_async_def_patchds


z,AsyncPatchDecoratorTest.test_async_def_patchN)	rrr r8r@rCrDrErOrrrrr08sr0c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AsyncPatchCMTestcs�fdd�}|�dS)Ncs>t�td��}��t|��Wd�n1s00YdS�Nr)r	r6rr1rr2rrrr4wsz>AsyncPatchCMTest.test_is_async_function_cm.<locals>.test_asyncrr7rrr�test_is_async_function_cmvsz*AsyncPatchCMTest.test_is_async_function_cmcs�fdd�}|�dS)NcsNt�td��.}|�}��t�|��t|�Wd�n1s@0YdSrQ)r	r6rr1r:r;rr<rrrr4~sz5AsyncPatchCMTest.test_is_async_cm.<locals>.test_asyncrr7rrr�test_is_async_cm}sz!AsyncPatchCMTest.test_is_async_cmcs�fdd�}|�dS)Ncs<t�td��}��|t�Wd�n1s.0YdSrQ)r	r6rrBrr2rrrr4�sz9AsyncPatchCMTest.test_is_AsyncMock_cm.<locals>.test_asyncrr7rrr�test_is_AsyncMock_cm�sz%AsyncPatchCMTest.test_is_AsyncMock_cmcs�fdd�}t|��dS)Nc�sRtt�d�t�����tt�Wd�n1s40Y��t�t��dS)NrF)r	rrrBr%r1r:rrrrrr4�s*z6AsyncPatchCMTest.test_async_def_cm.<locals>.test_async�rr7rrr�test_async_def_cm�sz"AsyncPatchCMTest.test_async_def_cmN)rrr rRrSrTrVrrrrrPus	rPc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
AsyncMockTestcCst�}|�t|��dSr)rr1r�r�mockrrr� test_iscoroutinefunction_default�sz.AsyncMockTest.test_iscoroutinefunction_defaultcCs2dd�}t|�}|�t|��|�t�|��dS)Nc�sdSrrrrrr�foo�rz<AsyncMockTest.test_iscoroutinefunction_function.<locals>.foo�rr1rr:�rr[rYrrr�!test_iscoroutinefunction_function�sz/AsyncMockTest.test_iscoroutinefunction_functioncCs8t�}|�}|�t�|��t|�|�dt|��dS)N�assert_awaited)rr1r:r;rZassertIn�dir�rrYr=rrr�test_isawaitable�s
zAsyncMockTest.test_isawaitablecCs2dd�}t|�}|�t|��|�t�|��dS)NcSsdSrrrrrrr[�rzCAsyncMockTest.test_iscoroutinefunction_normal_function.<locals>.foor\r]rrr�(test_iscoroutinefunction_normal_function�sz6AsyncMockTest.test_iscoroutinefunction_normal_functioncCsDt��}t�|�t��}|��|��t|�}|�|tj�dSr)rZnew_event_loopZset_event_loop�Future�stop�closerrB)rZloop�futrYrrr�test_future_isfuture�s
z"AsyncMockTest.test_future_isfutureN)rrr rZr^rbrcrhrrrrrW�s
rWc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�AsyncAutospecTestcs@ttdd��fdd��}ttdd��fdd��}|�|�dS)NT�Zautospeccs��|jt���|t�dSr�rBrrr
r2rrrr4�sz=AsyncAutospecTest.test_is_AsyncMock_patch.<locals>.test_asynccs��|jt�dSr)rBrr
r2rrr�test_normal_method�szEAsyncAutospecTest.test_is_AsyncMock_patch.<locals>.test_normal_method�r	r?)rr4rlrrrrC�s

z)AsyncAutospecTest.test_is_AsyncMock_patchcCs:|�t��ttdd�Wd�n1s,0YdS)NT)�instance)�assertRaises�RuntimeErrorrr%rrrr�test_create_autospec_instance�sz/AsyncAutospecTest.test_create_autospec_instancecCs tt�d�}|�t|�t�dS�N��spec)rr#rBr)rZawaitable_mockrrr�$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�|��|�t��|jdd�Wd�n1�s0YdS)	NrGrKrLrMc�s�IdHdSrrr��	awaitablerr�main�sz4AsyncAutospecTest.test_create_autospec.<locals>.mainr)�e)rr)rN�await_count�assertIsNone�
await_args�await_args_list�assert_not_awaitedrr1rr�iscoroutiner�assert_awaited_once�assert_awaited_once_with�assert_awaited_withr_ro�AssertionError�assert_any_await)rrtrxrrvr�test_create_autospec�s&
z&AsyncAutospecTest.test_create_autospeccs�fdd�}t|��dS)Nc�sZtt�d�dd���}|dddd�}��|jt���t|����t�|����t	�
|����|jd���|j
g���|j�|��|IdHWd�n1s�0Y��|jd���|jtdddd����|j
tdddd�g�|��|jdddd�|jdddd�|��|����|jd���|j���|j
g�dS)	NrJTrjrGrKrLrMr)r	rrBrYrr1rrrr:r;rNrzr}r{r|r~rr�r�r�r_�
reset_mock)r3rwrrrr4�s,(z>AsyncAutospecTest.test_patch_with_autospec.<locals>.test_asyncrUr7rrr�test_patch_with_autospec�sz*AsyncAutospecTest.test_patch_with_autospecN)rrr rCrqrur�r�rrrrri�s

ric@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�
AsyncSpecTestc	sV�fdd�}ttfD]<}��d|����||�Wd�q1sF0YqdS)Ncs(|t�}��|jt���|jt�dSr)rrBrrrr
)�	mock_typerYrrr�
inner_testszCAsyncSpecTest.test_spec_normal_methods_on_class.<locals>.inner_testztest method types with �rr
�subTest�rr�r�rrr�!test_spec_normal_methods_on_class
sz/AsyncSpecTest.test_spec_normal_methods_on_classcCs(tt�}|�|jt�|�|jt�dSr)rrrBrrrrXrrr�+test_spec_normal_methods_on_class_with_mocksz9AsyncSpecTest.test_spec_normal_methods_on_class_with_mockc	sX�fdd�}tttfD]<}��d|����||�Wd�q1sH0YqdS)Ncsj|td�}��||�t���"��t�|���Wd�n1sF0Y|td�}��||�dSrr�r%rBr/r1r:r;r*�r��
async_mockZ	sync_mockrrrr�s

0
z8AsyncSpecTest.test_spec_mock_type_kw.<locals>.inner_testztest spec kwarg with �rr
rr�r�rrr�test_spec_mock_type_kws	z$AsyncSpecTest.test_spec_mock_type_kwc	sX�fdd�}tttfD]<}��d|����||�Wd�q1sH0YqdS)Ncsf|t�}��||�t���"��t�|���Wd�n1sD0Y|t�}��||�dSrr�r�rrrr�+s
0z@AsyncSpecTest.test_spec_mock_type_positional.<locals>.inner_testztest spec positional with r�r�rrr�test_spec_mock_type_positional*s	z,AsyncSpecTest.test_spec_mock_type_positionalcCs8ttd�}|�|t�|�}|�t�|��t|�dSrr�rr*rBr1r:r;rrarrr� test_spec_as_normal_kw_AsyncMock8s

z.AsyncSpecTest.test_spec_as_normal_kw_AsyncMockcCs6tt�}|�|t�|�}|�t�|��t|�dSrr�rarrr�(test_spec_as_normal_positional_AsyncMock?s
z6AsyncSpecTest.test_spec_as_normal_positional_AsyncMockcs&tjtddd��fdd��}|�dS)NrTrscs��|t�dSrrAr2rrrr4Gsz6AsyncSpecTest.test_spec_async_mock.<locals>.test_asyncr5r7rrr�test_spec_async_mockFsz"AsyncSpecTest.test_spec_async_mockcs"ttdd��fdd��}|�dS)NTrscs��|t���|jt�dSr)rBr
rrr2rrrr4NszIAsyncSpecTest.test_spec_parent_not_async_attribute_is.<locals>.test_asyncrmr7rrr�'test_spec_parent_not_async_attribute_isMs
z5AsyncSpecTest.test_spec_parent_not_async_attribute_iscs(tjtdtjd��fdd��}|�dS)Nrrscs0��|t���t�|����t�|��dSr)rBr
�assertFalser:rr;r2rrr�test_async_attributeVszFAsyncSpecTest.test_target_async_spec_not.<locals>.test_async_attribute)r	r6rr+r&)rr�rrr�test_target_async_spec_notUsz(AsyncSpecTest.test_target_async_spec_notcs&tjtdtd��fdd��}|�dS)Nr&rscs��|t�dSrrA)Zmock_async_funcrrr� test_attribute_not_async_spec_is_szUAsyncSpecTest.test_target_not_async_spec_is.<locals>.test_attribute_not_async_spec_is)r	r6r+r%)rr�rrr�test_target_not_async_spec_is^sz+AsyncSpecTest.test_target_not_async_spec_iscs"tttd��fdd��}|�dS)Nrscs��|jt���|t�dSrrk)ZMockNormalClassrrr� test_async_attributes_coroutineseszRAsyncSpecTest.test_spec_async_attributes.<locals>.test_async_attributes_coroutines)r	�normal_foo_namer)rr�rrr�test_spec_async_attributesds
z(AsyncSpecTest.test_spec_async_attributesN)rrr r�r�r�r�r�r�r�r�r�r�r�rrrrr�s
	r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AsyncSpecSetTestcs&tjtddd��fdd��}|�dS)NrT�Zspec_setcs��|t�dSrrA)rrrrr4osz<AsyncSpecSetTest.test_is_AsyncMock_patch.<locals>.test_asyncr5r7rrrrCnsz(AsyncSpecSetTest.test_is_AsyncMock_patchcCs*ttjd�}|�t|��|�|t�dS�Nr�)rrrr1rrBrXrrr�test_is_async_AsyncMocktsz(AsyncSpecSetTest.test_is_async_AsyncMockcCsVttd�}|�t|j��|�t|j��|�|jt�|�|jt�|�|t�dSr�)	r
rr1rrr�rrBrrXrrr�test_is_child_AsyncMockys
z(AsyncSpecSetTest.test_is_child_AsyncMockcCsRt�}tdd�d�|_t�|d��}|�|t�Wd�n1sD0YdS)NcSs|Srr��xrrr�<lambda>�rz=AsyncSpecSetTest.test_magicmock_lambda_spec.<locals>.<lambda>rs�	mock_func)r
r�r	r6rB)rZmock_obj�cmrrr�test_magicmock_lambda_spec�sz+AsyncSpecSetTest.test_magicmock_lambda_specN)rrr rCr�r�r�rrrrr�msr�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�sdSrr)r�varrrr�addition�rz6AsyncArguments.test_add_return_value.<locals>.addition�
rH��rrN)rr�rY�outputrrr�test_add_return_value�sz$AsyncArguments.test_add_return_valuec�sTdd�}t|td�d�}|�t��|d�IdHWd�n1sF0YdS)Nc�sdSrr�r�rrrr��rz?AsyncArguments.test_add_side_effect_exception.<locals>.addition�err�Zside_effectr�)r�	Exceptionro)rr�rYrrr�test_add_side_effect_exception�sz-AsyncArguments.test_add_side_effect_exceptionc�s0dd�}t|d�}|d�IdH}|�|d�dS)Nc�s|dS�NrGrr�rrrr��sz?AsyncArguments.test_add_side_effect_coroutine.<locals>.additionr�r��r��rr�rY�resultrrr�test_add_side_effect_coroutine�s
z-AsyncArguments.test_add_side_effect_coroutinec�s0dd�}t|d�}|d�IdH}|�|d�dS)NcSs|dSr�rr�rrrr��szEAsyncArguments.test_add_side_effect_normal_function.<locals>.additionr�r�r�r�r�rrr�$test_add_side_effect_normal_function�s
z3AsyncArguments.test_add_side_effect_normal_functionc�sjgd�}t|d�}|D]}|�|�IdH|�q|�t��}|�IdHWd�n1s\0YdS)N�rGrKrLr�)rrNro�StopAsyncIteration)r�valsrY�itemryrrr�test_add_side_effect_iterable�s
z,AsyncArguments.test_add_side_effect_iterablec�stGdd�dt�}d|d�g}t|d�}|�|�IdHd�|�|��}|�IdHWd�n1sf0YdS)Nc@seZdZdS)zOAsyncArguments.test_add_side_effect_exception_iterable.<locals>.SampleExceptionN)rrr rrrr�SampleException�sr�rGr[r�)r�rrNro)rr�r�rYryrrr�'test_add_side_effect_exception_iterable�s
z6AsyncArguments.test_add_side_effect_exception_iterablec�s0tdd�}t|d�}|�IdH}|�||�dS)Nr�rH)r�assertIs)r�valuerYr�rrr�test_return_value_AsyncMock�s

z*AsyncArguments.test_return_value_AsyncMockc�s:t��}|�d�t|d�}|�IdH}|�|tj�dS)NrH)rrd�
set_resultrrB�rrgrYr�rrr�test_return_value_awaitable�s


z*AsyncArguments.test_return_value_awaitablec�srt��}|�d�t|gd�}|�IdH}|�|tj�|�t��|�IdHWd�n1sd0YdS)Nr�)rrdr�rrBror�r�rrr�!test_side_effect_awaitable_values�s
z0AsyncArguments.test_side_effect_awaitable_valuesc�s0tdd�}t|d�}|�IdH}|�|d�dS)Nr�rHr�r�)rZeffectrYr�rrr�test_side_effect_is_AsyncMock�s

z,AsyncArguments.test_side_effect_is_AsyncMockc�sRt���d���fdd�}t|d�}|�IdH}|�|��|��|���dS)NFc�sd��S�NTrr�Zranr�rr�inner�sz2AsyncArguments.test_wraps_coroutine.<locals>.inner��wraps)rrdrrNr_r1�rr�rYr�rr�r�test_wraps_coroutine�s
z#AsyncArguments.test_wraps_coroutinec�sNd�d���fdd�}t|d�}|�IdH}|�|��|��|���dS)NrGFcsd��Sr�rrr�rrr��sz8AsyncArguments.test_wraps_normal_function.<locals>.innerr�)rrNr_r1r�rr�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)NrKrG)r�assert_has_awaitsrrNr}�call_args_list)rr�Zmock2Zmock1rrr�test_await_args_list_order�s

z)AsyncArguments.test_await_args_list_orderN)rrr r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��s	r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�AsyncMagicMethodscCsBt�}|�|jt�|�|jt�|�|jt�|�|jt�dSr)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�|�|jt�dSr)rrB�	__enter__r
�__exit__�__next__�__len__�r�a_mockrrr�*test_sync_magic_methods_return_magic_mockss
z<AsyncMagicMethods.test_sync_magic_methods_return_magic_mockscCs:t�}|�t|d��|�t|d��|�t|d��dS)Nr�r�r�)r
r1�hasattrr�rrr�&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�)rr1r�r�rrr�%test_asyncmock_has_sync_magic_methodss
z7AsyncMagicMethods.test_asyncmock_has_sync_magic_methodscCsFt�}|�|jt�|�|jt�|�t|j��|�t|j��dSr)r
rBr�rr�r1rr�rrr�&test_magic_methods_are_async_functions s
z8AsyncMagicMethods.test_magic_methods_are_async_functionsN)rrr r�r�r�r�r�rrrrr�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�sdSrr�r�args�kwargsrrrr�+rz:AsyncContextManagerTest.WithAsyncContextManager.__aenter__c�sdSrrr�rrrr�-rz9AsyncContextManagerTest.WithAsyncContextManager.__aexit__N)rrr r�r�rrrr�WithAsyncContextManager*sr�c@seZdZdd�Zdd�ZdS)z.AsyncContextManagerTest.WithSyncContextManagercOsdSrrr�rrrr�0rz8AsyncContextManagerTest.WithSyncContextManager.__enter__cOsdSrrr�rrrr�2rz7AsyncContextManagerTest.WithSyncContextManager.__exit__N)rrr r�r�rrrr�WithSyncContextManager/sr�c@seZdZdd�Zdd�ZdS)z&AsyncContextManagerTest.ProductionCodecCs
d|_dSr)�sessionrrrrr6sz/AsyncContextManagerTest.ProductionCode.__init__c	�sV|j�d�4IdH�(}|��IdH}|Wd�IdHS1IdHsH0YdS)Nzhttps://python.org)r��post�json)r�response�valrrrrx9sz+AsyncContextManagerTest.ProductionCode.mainN)rrr rrxrrrr�ProductionCode4sr�c	sV�fdd�}ttfD]<}��d|����||�Wd�q1sF0YqdS)Ncsj���}tdd�|_|dd�}tdd�}tddid�|_||j_||jj_t|�	��}��
|ddi�dS)NZsessionmock��nameZmagic_cmr�r��{rH)r�r
r�rr�r�rIr�rrxrN)r�Zpcr�r�r�rrrr�?s


zKAsyncContextManagerTest.test_set_return_value_of_aenter.<locals>.inner_testz%test set return value of aenter with r�r�rrr�test_set_return_value_of_aenter>sz7AsyncContextManagerTest.test_set_return_value_of_aenterc	sV�fdd�}ttfD]<}��d|����||�Wd�q1sF0YqdS)Ncsvd����}||����fdd�}t|��}�������jj����jj��j���j�����|�dS)NFc	�s@�4IdH�}d�Wd�IdHq<1IdHs20Y|Sr�r�r���calledZcm_mockrr�use_context_managerTs.zqAsyncContextManagerTest.test_mock_supports_async_context_manager.<locals>.inner_test.<locals>.use_context_manager)r�rr1r�r�r�r_ZassertIsNot)r�r�rZ	cm_resultrr�rr�Os



zTAsyncContextManagerTest.test_mock_supports_async_context_manager.<locals>.inner_testz!test context manager magics with r�r�rrr�(test_mock_supports_async_context_managerNsz@AsyncContextManagerTest.test_mock_supports_async_context_managercs@|��}t|��t�}|�j_�fdd�}|�t|��|�dS)Nc	�s@�4IdH�}|Wd�IdHS1IdHs20YdSrrr���
mock_instancerrrosz^AsyncContextManagerTest.test_mock_customize_async_context_manager.<locals>.use_context_manager)r�r
r6r�rIr�r)rrnZexpected_resultrrrr�)test_mock_customize_async_context_managerhszAAsyncContextManagerTest.test_mock_customize_async_context_managercsjd�d��fdd�}�fdd�}|��}t|��|�_|�_�fdd�}t|��|���|���dS)NFc�sd�dSr�r�r�)�enter_calledrr�enter_coroutineysziAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.enter_coroutinec�sd�dSr�rr)�exit_calledrr�exit_coroutine}szhAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.exit_coroutinec	�s<�4IdH�Wd�IdHq81IdHs.0YdSrrrrrrr�szmAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.use_context_manager)r�r
r�r�rr1)rrr	rnrr)rrrr�8test_mock_customize_async_context_manager_with_coroutineus

zPAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutinecCsRdd�}|��}t|�}|�t��t||��Wd�n1sD0YdS)Nc	�sB|4IdH�t��Wd�IdHq>1IdHs40YdSr)�	TypeError)Zcontext_managerrrr�raise_in�szYAsyncContextManagerTest.test_context_manager_raise_exception_by_default.<locals>.raise_in)r�r
rorr)rrrnrrrr�/test_context_manager_raise_exception_by_default�s
zGAsyncContextManagerTest.test_context_manager_raise_exception_by_defaultN)rrr r�r�r�r�rrr
r
rrrrr�(s

r�c@s4eZdZGdd�de�Zdd�Zdd�Zdd�Zd	S)
�AsyncIteratorTestc@s$eZdZdd�Zdd�Zdd�ZdS)z#AsyncIteratorTest.WithAsyncIteratorcCsgd�|_dS)N)r[Z	NormalFoo�baz)�itemsrrrrr�sz,AsyncIteratorTest.WithAsyncIterator.__init__cCsdSrrrrrrr��rz-AsyncIteratorTest.WithAsyncIterator.__aiter__c�sdSrrrrrrr��rz-AsyncIteratorTest.WithAsyncIterator.__anext__N)rrr rr�r�rrrr�WithAsyncIterator�srcs@tdd��gd��j_�fdd�}t|��}|�|gd��dS)NZtesterr�r�c�sdd��2�IdHS)Nc�sg|z3dHW}|�q6Srr)�.0�irrr�
<listcomp>�rzOAsyncIteratorTest.test_aiter_set_return_value.<locals>.main.<locals>.<listcomp>rr�Z	mock_iterrrrx�sz;AsyncIteratorTest.test_aiter_set_return_value.<locals>.main)rr�rIrrN)rrxr�rrr�test_aiter_set_return_value�s


z-AsyncIteratorTest.test_aiter_set_return_valuec	sV�fdd�}ttfD]<}��d|����||�Wd�q1sF0YqdS)NcsT���}||�}��t|j����t|j����t|j����t|j��dSr)rr�rr�r1r�)r�rnrrrrr��szIAsyncIteratorTest.test_mock_aiter_and_anext_asyncmock.<locals>.inner_testz%test aiter and anext corourtine with r�r�rrr�#test_mock_aiter_and_anext_asyncmock�sz5AsyncIteratorTest.test_mock_aiter_and_anext_asyncmockc	s�dd��gd����fdd�}���fdd�}���fdd	�}ttfD]�}��d
|����||�Wd�n1sx0Y��d|����||�Wd�n1s�0Y��d|����||�Wd�qF1s�0YqFdS)
Nc�s&g}|2z3dHW}|�|�q6|Sr)�append)�iteratorZaccumulatorr�rrr�iterate�sz6AsyncIteratorTest.test_mock_async_for.<locals>.iterate)ZFOOZBARZBAZcs$|����}��t�|��g�dSr)rrNr�r�r)rrrr�test_default�sz;AsyncIteratorTest.test_mock_async_for.<locals>.test_defaultcs4|����}�dd�|j_��t�|����dSr)rr�rIrNrr�Zexpectedrrrr�test_set_return_value�szDAsyncIteratorTest.test_mock_async_for.<locals>.test_set_return_valuecs8|����}t�dd��|j_��t�|����dSr)r�iterr�rIrNrrrrr�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�)rrrr r�rrr�test_mock_async_for�s&&z%AsyncIteratorTest.test_mock_async_forN)rrr r6rrrr!rrrrr�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/d0�Zd1d2�Zd3S)4�AsyncMockAssertcCst�|_dSr)rrYrrrr�setUp�szAsyncMockAssert.setUpc�s|j|i|��IdHdSr)rYr�rrr�_runnable_test�szAsyncMockAssert._runnable_testc�s
|IdHSrr)r�	coroutinerrr�_await_coroutine�sz AsyncMockAssert._await_coroutinecCs�tt�}t|��|��Wd�n1s.0Y|�t|j��|j��|j��|j��|�	t
��|��Wd�n1s�0Y|�	t
��|j��Wd�n1s�0YdSr)rrr/rr1r�
assert_called�assert_called_once�assert_called_once_withror�r_rXrrr�"test_assert_called_but_not_awaited�s
&


&z2AsyncMockAssert.test_assert_called_but_not_awaitedcCs�tt�}|��}|j��|j��|j��|�t��|j��Wd�n1sX0Yt	|�
|��|j��|j��|j��|j��dSr)
rrrr'r(r)ror�r_rr&r�r�)rrYZmock_coroutinerrr�test_assert_called_then_awaited�s


(


z/AsyncMockAssert.test_assert_called_then_awaitedcCs�|�t��|j��Wd�n1s*0Y|�t��|j��Wd�n1s^0Yt|���|j��|j��dSr)	ror�rYr_r'rr$r(r�rrrr�+test_assert_called_and_awaited_at_same_times((
z;AsyncMockAssert.test_assert_called_and_awaited_at_same_timecCs�tt�}|��}t|��|��Wd�n1s60Y|�t��|j��Wd�n1sj0Y|j��t|�	|��|j��|j�
�dSr)rrrr/ror�r_r'rr&r��rrYr%rrr�)test_assert_called_twice_and_awaited_onces
&(

z9AsyncMockAssert.test_assert_called_twice_and_awaited_oncecCsntt�}|��}|j��t|�|��|�t��t|�|��Wd�n1sV0Y|j��dSr)	rrrr(rr&rorpr_r-rrr�)test_assert_called_once_and_awaited_twices
,z9AsyncMockAssert.test_assert_called_once_and_awaited_twicecCs|�t��|j��Wd�n1s*0Y|�t��|j��Wd�n1s^0Y|�t�� t|�|j��Wd�n1s�0Y|�t��|j��Wd�n1s�0Y|�t��|j��Wd�n1�s0YdSr)ror�rYr_r'rrr&rrrr�"test_assert_awaited_but_not_called)s((.(z2AsyncMockAssert.test_assert_awaited_but_not_calledcCs�td�g}t|��|�d�Wd�n1s20Y|j�|�|�t��|j�|�Wd�n1st0YdS�Nr[)rr/rYZassert_has_callsror�r�)rZkallsrrr� test_assert_has_calls_not_awaits7s

(z0AsyncMockAssert.test_assert_has_calls_not_awaitscCs�t|��|��Wd�n1s&0Yddifg}|�|jj|�t|��|�d�Wd�n1st0Yt|��|�d�Wd�n1s�0Yt�td�td�g}|�|jj|�dS)N�rr[r)r/rYrN�
mock_callsr)r�kalls_empty�
mock_kallsrrr�0test_assert_has_mock_calls_on_async_mock_no_spec?s
&
(
(z@AsyncMockAssert.test_assert_has_mock_calls_on_async_mock_no_speccCs�tt�}t|��|��Wd�n1s.0Yddifg}|�|jj|�|�|jt��g�t|��$|jdddddd�Wd�n1s�0Yt�tdddddd�g}t��tjdddddd�g}|�|jj|�|�|j|�dS)	Nr3rrGrKrL�r�)r&r')rrr/rrNr4r)rZa_class_mockr5Zmethod_kallsr6rrr�2test_assert_has_mock_calls_on_async_mock_with_specLs
&
2zBAsyncMockAssert.test_assert_has_mock_calls_on_async_mock_with_speccCs�t|�� |jjddd�Wd�n1s.0Yt|��$|jjjdtjd�Wd�n1sj0Y|�|jjddddifdd	d
tjifgd�|�|jjjdd	d
tjifgd�dS)NrL)�fishr�)�cake�	something)rLr:zsomething_else.something)r�r;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_recordedcsF�fdd�}|�j�t������Wd�n1s<0Yt�����dd�Wd�n1sp0Yt����jdd�Wd�n1s�0Y�j��|�j�tt�}t���|��Wd�n1s�0Yt���|jddd�Wd�n1�s(0Y|��||�dS)Ncs@d}|D]2}t||�}��|t���|t���|g�qdS)N)r�r=r4)�getattrrBr�listrN)rY�namesr��attrrrr�assert_attrsks
z:AsyncMockAssert.test_async_arg_lists.<locals>.assert_attrsrGrKrL)r&)rYr/r�rrr)rrCr�rrr�test_async_arg_listsjs"

&
*
*


&
.z$AsyncMockAssert.test_async_arg_listscCsN|�t��|j��Wd�n1s*0Yt|���|j��dSr)ror�rYr_rr$rrrr�test_assert_awaited�s(z#AsyncMockAssert.test_assert_awaitedcCs�|�t��|j��Wd�n1s*0Yt|���|j��t|���|�t��|j��Wd�n1s�0YdSr)ror�rYr�rr$rrrr�test_assert_awaited_once�s(
z(AsyncMockAssert.test_assert_awaited_oncecCs�d}|�t|��|j�d�Wd�n1s20Yt|���d}|�t|��|j�d�Wd�n1sz0Yt|�d��|j�d�t|�d��|�t��|j�d�Wd�n1s�0YdS)NzNot awaitedr[zexpected await not found�
SomethingElse)�assertRaisesRegexr�rYr�rr$ro)r�msgrrr�test_assert_awaited_with�s**z(AsyncMockAssert.test_assert_awaited_withcCs�|�t��|j�d�Wd�n1s,0Yt|�d��|j�d�t|�d��|�t��|j�d�Wd�n1s�0YdSr1)ror�rYr�rr$rrrr�test_assert_awaited_once_with�s*z-AsyncMockAssert.test_assert_awaited_once_withcCs�|�t��|j�d�Wd�n1s,0Yt|�d��|�t��|j�d�Wd�n1sp0Yt|�d��|j�d�t|�d��|j�d�dS)Nr[rrG)ror�rYr�rr$rrrr�test_assert_any_wait�s**z$AsyncMockAssert.test_assert_any_waitcCstd�td�g}|�t��}|j�|�Wd�n1s<0Y|�t|jj�d�t	|�
d��|�t��|j�|�Wd�n1s�0Yt	|�
d��|�t��|j�|�Wd�n1s�0Yt	|�
d��|j�|�t	|�
d��|j�|�dS)Nr[rrGrG)rror�rYr�rN�len�	exceptionr�rr$)r�callsr�rrr�test_assert_has_awaits_no_order�s***z/AsyncMockAssert.test_assert_has_awaits_no_ordercCsTGdd�d�}t|�|�d��|j�ttd�g�|j�td�|j�td�dS)Nc@seZdZdd�ZdS)z9AsyncMockAssert.test_awaits_asserts_with_any.<locals>.FoocSsdSrr�r�otherrrr�__eq__�rz@AsyncMockAssert.test_awaits_asserts_with_any.<locals>.Foo.__eq__N�rrr rSrrrr�Foo�srUrG)rr$rYr�rrr�r�)rrUrrr�test_awaits_asserts_with_any�s
z,AsyncMockAssert.test_awaits_asserts_with_anycsbGdd�d�}t|d���fdd�}t||�d����ttd�g���td���td�dS)Nc@seZdZdd�ZdS)zBAsyncMockAssert.test_awaits_asserts_with_spec_and_any.<locals>.FoocSsdSrrrQrrrrS�rzIAsyncMockAssert.test_awaits_asserts_with_spec_and_any.<locals>.Foo.__eq__NrTrrrrrU�srUrsc�s�|�IdHdSrrr�Zmock_with_specrr�_custom_mock_runnable_test�szYAsyncMockAssert.test_awaits_asserts_with_spec_and_any.<locals>._custom_mock_runnable_testrG)rrr�rrr�r�)rrUrXrrWr�%test_awaits_asserts_with_spec_and_any�s
z5AsyncMockAssert.test_awaits_asserts_with_spec_and_anycCstd�td�g}|�t�� |jj|dd�Wd�n1s@0Yt|�d��|�t�� |jj|dd�Wd�n1s�0Yt|�d��|�t�� |jj|dd�Wd�n1s�0Yt|�d��|jj|dd�t|�d��|jj|dd�dS)Nr[rT)Z	any_orderZbamfZqux)rror�rYr�rr$)rrOrrr�test_assert_has_awaits_ordered�s...z.AsyncMockAssert.test_assert_has_awaits_orderedcCsN|j��t|���|�t��|j��Wd�n1s@0YdSr)rYr~rr$ror�rrrr�test_assert_not_awaiteds
z'AsyncMockAssert.test_assert_not_awaitedcCs�d	dd�}t|d�|_t|�d��|�td�t�d���� }|j�	t
�g�Wd�n1sb0Y|�|jj
�|�td�t�d����(}|j�	t
�t
dd�g�Wd�n1s�0Y|�|jj
t�dS)
Nc�sdSrrr�rrr�frzIAsyncMockAssert.test_assert_has_awaits_not_matching_spec_error.<locals>.frsrGz^{}$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)]rK)N)rrYrr$rHr��format�re�escaper�rr{rN�	__cause__rBr)rr\r�rrr�.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
rrr
rrrr#r%r)r*r6r+rr?r�r/ZTestCaser0rPrWrir�r�r�r�r�rr"rrrr�<module>s<,


=!"Tay&rE

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists