add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
f

��_V�c@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�9/usr/lib64/python3.10/unittest/test/testmock/testasync.py�tearDownModule�rc@s<eZdZdd�Zdd�Zdd�Zedd��Zed	d
��Z	dS)�
AsyncClasscC�dSrr��selfrrr�__init__�zAsyncClass.__init__c�rrrrrrr�async_methodrzAsyncClass.async_methodcCrrrrrrr�
normal_methodrzAsyncClass.normal_methodc�rrr)Zclsrrr�async_class_methodrzAsyncClass.async_class_methodc�rrrrrrr�async_static_methodrzAsyncClass.async_static_methodN)
�__name__�
__module__�__qualname__rrrZclassmethodrZstaticmethodrrrrrrs
rc@�eZdZdd�ZdS)�AwaitableClassccs
dVdSrrrrrr�	__await__rzAwaitableClass.__await__N)rrr r#rrrrr"�r"c�rrrrrrr�
async_func!rr%c�rrr)�a�b�crrr�async_func_args#rr)cCrrrrrrr�normal_func%rr*c@r!)�NormalClasscCrrrrrrrr&(rz
NormalClass.aN)rrr r&rrrrr+'r$r+z.AsyncClassz.NormalClassccs>|�td��dVt��Wd�n1s00YdS)Nzwas never awaited$)ZassertWarnsRegexZRuntimeWarning�gcZcollect)Ztestrrr�assertNeverAwaited/sr-c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�AsyncPatchDecoratorTestc�"t�td��fdd��}|�dS)Nrcs��t|��dSr)�
assertTruer��mock_methodrrr�
test_async:�zLAsyncPatchDecoratorTest.test_is_coroutine_function_patch.<locals>.test_async�r�objectr�rr3rrr� test_is_coroutine_function_patch9s
z8AsyncPatchDecoratorTest.test_is_coroutine_function_patchcsBt�td��fdd��}tt�d���fdd��}|�|�dS)Nrc�"|�}��t�|��t|�dSr�r0�inspect�isawaitabler�r2�mrrrr3@�z?AsyncPatchDecoratorTest.test_is_async_patch.<locals>.test_asyncz
.async_methodcr9rr:r=rrr�test_no_parent_attributeFr?zMAsyncPatchDecoratorTest.test_is_async_patch.<locals>.test_no_parent_attribute)rr6r�async_foo_name)rr3r@rrr�test_is_async_patch?s
z+AsyncPatchDecoratorTest.test_is_async_patchcr/)Nrc���|t�dSr��assertIsInstancerr1rrrr3Pr4zCAsyncPatchDecoratorTest.test_is_AsyncMock_patch.<locals>.test_asyncr5r7rrr�test_is_AsyncMock_patchO�
z/AsyncPatchDecoratorTest.test_is_AsyncMock_patchcr/)NrcrCrrDr1rrrr3Wr4zPAsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethod.<locals>.test_asyncr5r7rrr�$test_is_AsyncMock_patch_staticmethodVrGz<AsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethodcr/)NrcrCrrDr1rrrr3^r4zOAsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethod.<locals>.test_asyncr5r7rrr�#test_is_AsyncMock_patch_classmethod]rGz;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%rKrO��r()�assertEqualZ
_mock_namerEr%rr))Zfunc_args_mockZ	func_mockrrrr3esz@AsyncPatchDecoratorTest.test_async_def_patch.<locals>.test_async)rrrr0r;rr%r7rrr�test_async_def_patchds


z,AsyncPatchDecoratorTest.test_async_def_patchN)	rrr r8rBrFrHrIrSrrrrr.8sr.c@�,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AsyncPatchCMTestc��fdd�}|�dS)Ncs>t�td��}��t|��Wd�n1s00YdS�Nr)rr6rr0rr1rrrr3w�z>AsyncPatchCMTest.test_is_async_function_cm.<locals>.test_asyncrr7rrr�test_is_async_function_cmv�z*AsyncPatchCMTest.test_is_async_function_cmcrV)NcsNt�td��.}|�}��t�|��t|�Wd�n1s@0YdSrW)rr6rr0r;r<rr=rrrr3~sz5AsyncPatchCMTest.test_is_async_cm.<locals>.test_asyncrr7rrr�test_is_async_cm}sz!AsyncPatchCMTest.test_is_async_cmcrV)Ncs<t�td��}��|t�Wd�n1s.0YdSrW)rr6rrErr1rrrr3�rXz9AsyncPatchCMTest.test_is_AsyncMock_cm.<locals>.test_asyncrr7rrr�test_is_AsyncMock_cm�rZz%AsyncPatchCMTest.test_is_AsyncMock_cmc��fdd�}t|��dS)Nc�sRtt�d�t�����tt�Wd�n1s40Y��t�t��dS)NrJ)rrrrEr%r0r;rrrrrr3�s*z6AsyncPatchCMTest.test_async_def_cm.<locals>.test_async�rr7rrr�test_async_def_cm�sz"AsyncPatchCMTest.test_async_def_cmN)rrr rYr[r\r_rrrrrUus	rUc@�4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
AsyncMockTestcCst�}|�t|��dSr)rr0r�r�mockrrr� test_iscoroutinefunction_default�sz.AsyncMockTest.test_iscoroutinefunction_defaultcC�2dd�}t|�}|�t|��|�t�|��dS)Nc�rrrrrrr�foo�rz<AsyncMockTest.test_iscoroutinefunction_function.<locals>.foo�rr0rr;�rrfrcrrr�!test_iscoroutinefunction_function��z/AsyncMockTest.test_iscoroutinefunction_functioncCs8t�}|�}|�t�|��t|�|�dt|��dS)N�assert_awaited)rr0r;r<rZassertInZdir�rrcr>rrr�test_isawaitable�s
zAsyncMockTest.test_isawaitablecCre)NcSrrrrrrrrf�rzCAsyncMockTest.test_iscoroutinefunction_normal_function.<locals>.foorgrhrrr�(test_iscoroutinefunction_normal_function�rjz6AsyncMockTest.test_iscoroutinefunction_normal_functioncCsDt��}t�|�t��}|��|��t|�}|�|tj�dSr)rZnew_event_loopZset_event_loop�FutureZstopZcloserrE)rZloop�futrcrrr�test_future_isfuture�s
z"AsyncMockTest.test_future_isfutureN)rrr rdrirmrnrqrrrrra�s
rac@r`)�AsyncAutospecTestcs@ttdd��fdd��}ttdd��fdd��}|�|�dS)NT�Zautospecc���|jt���|t�dSr�rErrr	r1rrrr3��z=AsyncAutospecTest.test_is_AsyncMock_patch.<locals>.test_asynccs��|jt�dSr)rErr	r1rrr�test_normal_method�r4zEAsyncAutospecTest.test_is_AsyncMock_patch.<locals>.test_normal_method�rrA)rr3rwrrrrF�s

z)AsyncAutospecTest.test_is_AsyncMock_patchcCs:|�t��ttdd�Wd�n1s,0YdS)NT)�instance)�assertRaises�RuntimeErrorrr%rrrr�test_create_autospec_instance��z/AsyncAutospecTest.test_create_autospec_instancecCs tt�d�}|�t|�t�dS�N��spec)rr"rEr)rZawaitable_mockrrr�$test_create_autospec_awaitable_class�r}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)	NrKrOrPrQc�s�IdHdSrrr��	awaitablerr�main�rz4AsyncAutospecTest.test_create_autospec.<locals>.mainr)�e)rr)rR�await_count�assertIsNone�
await_args�await_args_list�assert_not_awaitedrr0rr�iscoroutiner�assert_awaited_once�assert_awaited_once_with�assert_awaited_withrkrz�AssertionError�assert_any_await)rr�r�rr�r�test_create_autospec�s&
z&AsyncAutospecTest.test_create_autospeccr])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)	NrNTrsrKrOrPrQr)rrrErcrr0rrr�r;r<rRr�r�r�r�r�rr�r�r�rk�
reset_mock)r2r�rrrr3�s,(z>AsyncAutospecTest.test_patch_with_autospec.<locals>.test_asyncr^r7rrr�test_patch_with_autospec�sz*AsyncAutospecTest.test_patch_with_autospecN)rrr rFr|r�r�r�rrrrrr�s

rrc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�
AsyncSpecTestc	�V�fdd�}ttfD]<}��d|����||�Wd�q1sF0YqdS)Ncs(|t�}��|jt���|jt�dSr)rrErrrr	)�	mock_typercrrr�
inner_test�zCAsyncSpecTest.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)r
rrErrrrbrrr�+test_spec_normal_methods_on_class_with_mockr�z9AsyncSpecTest.test_spec_normal_methods_on_class_with_mockc	�X�fdd�}tttfD]<}��d|����||�Wd�q1sH0YqdS)Ncsj|td�}��||�t���"��t�|���Wd�n1sF0Y|td�}��||�dSr~�r%rEr-r0r;r<r*�r��
async_mockZ	sync_mockrrrr�s

0
z8AsyncSpecTest.test_spec_mock_type_kw.<locals>.inner_testztest spec kwarg with �rr	r
r�r�rrr�test_spec_mock_type_kw�	z$AsyncSpecTest.test_spec_mock_type_kwc	r�)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*r�z,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|�dSrr�rlrrr�(test_spec_as_normal_positional_AsyncMock?s
z6AsyncSpecTest.test_spec_as_normal_positional_AsyncMockc�&tjtddd��fdd��}|�dS)NrTrcrCrrDr1rrrr3Gr4z6AsyncSpecTest.test_spec_async_mock.<locals>.test_asyncr5r7rrr�test_spec_async_mockFsz"AsyncSpecTest.test_spec_async_mockcs"ttdd��fdd��}|�dS)NTrcs��|t���|jt�dSr)rEr	rrr1rrrr3NszIAsyncSpecTest.test_spec_parent_not_async_attribute_is.<locals>.test_asyncrxr7rrr�'test_spec_parent_not_async_attribute_isM�
z5AsyncSpecTest.test_spec_parent_not_async_attribute_iscs(tjtdtjd��fdd��}|�dS)Nrrcs0��|t���t�|����t�|��dSr)rEr	�assertFalser;r�r<r1rrr�test_async_attributeVszFAsyncSpecTest.test_target_async_spec_not.<locals>.test_async_attribute)rr6rr+r&)rr�rrr�test_target_async_spec_notUsz(AsyncSpecTest.test_target_async_spec_notcs&tjtdtd��fdd��}|�dS)Nr&rcrCrrD)Zmock_async_funcrrr� test_attribute_not_async_spec_is_r4zUAsyncSpecTest.test_target_not_async_spec_is.<locals>.test_attribute_not_async_spec_is)rr6r+r%)rr�rrr�test_target_not_async_spec_is^�z+AsyncSpecTest.test_target_not_async_spec_iscs"tttd��fdd��}|�dS)Nrcrtrru)ZMockNormalClassrrr� test_async_attributes_coroutineservzRAsyncSpecTest.test_spec_async_attributes.<locals>.test_async_attributes_coroutines)r�normal_foo_namer)rr�rrr�test_spec_async_attributesdr�z(AsyncSpecTest.test_spec_async_attributesN)rrr r�r�r�r�r�r�r�r�r�r�r�rrrrr�s
	r�c@rT)
�AsyncSpecSetTestcr�)NrT�Zspec_setcrCrrD)rrrrr3or4z<AsyncSpecSetTest.test_is_AsyncMock_patch.<locals>.test_asyncr5r7rrrrFnr�z(AsyncSpecSetTest.test_is_AsyncMock_patchcCs*ttjd�}|�t|��|�|t�dS�Nr�)rrrr0rrErbrrr�test_is_async_AsyncMocktsz(AsyncSpecSetTest.test_is_async_AsyncMockcCsVttd�}|�t|j��|�t|j��|�|jt�|�|jt�|�|t�dSr�)	r	rr0rrr�rrErrbrrr�test_is_child_AsyncMockys
z(AsyncSpecSetTest.test_is_child_AsyncMockcCsRt�}tdd�d�|_t�|d��}|�|t�Wd�n1sD0YdS)NcSs|Srr�ZxrrrZ<lambda>�rz=AsyncSpecSetTest.test_magicmock_lambda_spec.<locals>.<lambda>r�	mock_func)r	r�rr6rE)rZmock_obj�cmrrr�test_magicmock_lambda_spec�sz+AsyncSpecSetTest.test_magicmock_lambda_specN)rrr rFr�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�rrr)r�varrrr�addition�rz6AsyncArguments.test_add_return_value.<locals>.addition�
rL��rrR)rr�rcZoutputrrr�test_add_return_value�sz$AsyncArguments.test_add_return_valuec�sTdd�}t|td�d�}|�t��|d�IdHWd�n1sF0YdS)Nc�rrr�r�rrrr��rz?AsyncArguments.test_add_side_effect_exception.<locals>.additionZerr�Zside_effectr�)r�	Exceptionrz)rr�rcrrr�test_add_side_effect_exception�sz-AsyncArguments.test_add_side_effect_exceptionc��0dd�}t|d�}|d�IdH}|�|d�dS)Nc��|dS�NrKrr�rrrr��rz?AsyncArguments.test_add_side_effect_coroutine.<locals>.additionr�r��r��rr�rc�resultrrr�test_add_side_effect_coroutine��
z-AsyncArguments.test_add_side_effect_coroutinec�r�)NcSr�r�rr�rrrr��rzEAsyncArguments.test_add_side_effect_normal_function.<locals>.additionr�r�r�r�r�rrr�$test_add_side_effect_normal_function�r�z3AsyncArguments.test_add_side_effect_normal_functionc�sjgd�}t|d�}|D]}|�|�IdH|�q|�t��}|�IdHWd�n1s\0YdS)N�rKrOrPr�)rrRrz�StopAsyncIteration)r�valsrc�itemr�rrr�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�r$r�rKrfr�)r�rrRrz)rr�r�rcr�rrr�'test_add_side_effect_exception_iterable�s
z6AsyncArguments.test_add_side_effect_exception_iterablec�s0tdd�}t|d�}|�IdH}|�||�dS)Nr�rL)r�assertIs)r�valuercr�rrr�test_return_value_AsyncMock�s

z*AsyncArguments.test_return_value_AsyncMockc�s:t��}|�d�t|d�}|�IdH}|�|tj�dS)NrL)rro�
set_resultrrE�rrprcr�rrr�test_return_value_awaitable�s


z*AsyncArguments.test_return_value_awaitablec�srt��}|�d�t|gd�}|�IdH}|�|tj�|�t��|�IdHWd�n1sd0YdS)Nr�)rror�rrErzr�r�rrr�!test_side_effect_awaitable_values�s
z0AsyncArguments.test_side_effect_awaitable_valuesc�s0tdd�}t|d�}|�IdH}|�|d�dS)Nr�rLr�r�)rZeffectrcr�rrr�test_side_effect_is_AsyncMock�s

z,AsyncArguments.test_side_effect_is_AsyncMockc�sRt���d���fdd�}t|d�}|�IdH}|�|��|��|���dS)NFc��d��S�NTrr�Zranr�rr�inner��z2AsyncArguments.test_wraps_coroutine.<locals>.inner�Zwraps)rrorrRrkr0�rr�rcr�rr�r�test_wraps_coroutine�s
z#AsyncArguments.test_wraps_coroutinec�sNd�d���fdd�}t|d�}|�IdH}|�|��|��|���dS)NrKFcr�r�rrr�rrr��r�z8AsyncArguments.test_wraps_normal_function.<locals>.innerr�)rrRrkr0r�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)NrOrK)r�assert_has_awaitsrrRr��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@r`)�AsyncMagicMethodscCsBt�}|�|jt�|�|jt�|�|jt�|�|jt�dSr)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�|�|jt�dSr)rrE�	__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	r0�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�)rr0r�r�rrr�%test_asyncmock_has_sync_magic_methodss
z7AsyncMagicMethods.test_asyncmock_has_sync_magic_methodscCsFt�}|�|jt�|�|jt�|�t|j��|�t|j��dSr)r	rEr�rr�r0rr�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@�eZdZdd�Zdd�ZdS)z/AsyncContextManagerTest.WithAsyncContextManagerc�rrr�r�argsZkwargsrrrr�+rz:AsyncContextManagerTest.WithAsyncContextManager.__aenter__c�rrrrrrrr�-rz9AsyncContextManagerTest.WithAsyncContextManager.__aexit__N)rrr r�r�rrrr�WithAsyncContextManager*�rc@r)z.AsyncContextManagerTest.WithSyncContextManagercOrrrrrrrr�0rz8AsyncContextManagerTest.WithSyncContextManager.__enter__cOrrrrrrrr�2rz7AsyncContextManagerTest.WithSyncContextManager.__exit__N)rrr r�r�rrrr�WithSyncContextManager/rrc@r)z&AsyncContextManagerTest.ProductionCodecCs
d|_dSr)�sessionrrrrr6rz/AsyncContextManagerTest.ProductionCode.__init__c	�sV|j�d�4IdH�(}|��IdH}|Wd�IdHS1IdHsH0YdS)Nzhttps://python.org)r�post�json)r�responseZvalrrrr�9sz+AsyncContextManagerTest.ProductionCode.mainN)rrr rr�rrrr�ProductionCode4src	r�)Ncsj���}tdd�|_|dd�}tdd�}tddid�|_||j_||jj_t|�	��}��
|ddi�dS)NZsessionmock��nameZmagic_cmr
r	i{rL)rr	rrr	r�rMrrr�rR)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>�z7AsyncContextManagerTest.test_set_return_value_of_aenterc	r�)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)rrr0r�rr�rkZassertIsNot)r�r�rZ	cm_resultrrrr�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_instancerrrorXz^AsyncContextManagerTest.test_mock_customize_async_context_manager.<locals>.use_context_manager)rr	r6r�rMr�r)rryZexpected_resultrrrr�)test_mock_customize_async_context_managerhszAAsyncContextManagerTest.test_mock_customize_async_context_managercsjd�d��fdd�}�fdd�}|��}t|��|�_|�_�fdd�}t|��|���|���dS)NFc��d�dSr�r�r)�enter_calledrr�enter_coroutineyr4ziAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.enter_coroutinec�rr�rr)�exit_calledrr�exit_coroutine}r4zhAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.exit_coroutinec	�s<�4IdH�Wd�IdHq81IdHs.0YdSrrrrrrr�rXzmAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.use_context_manager)rr	r�r�rr0)rrrryrr)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�rXzYAsyncContextManagerTest.test_context_manager_raise_exception_by_default.<locals>.raise_in)rr	rzrr)rr ryrrrr�/test_context_manager_raise_exception_by_default�s
zGAsyncContextManagerTest.test_context_manager_raise_exception_by_defaultN)rrr rrrrrrrr!rrrrr(s

rc@s4eZdZGdd�de�Zdd�Zdd�Zdd�Zd	S)
�AsyncIteratorTestc@s$eZdZdd�Zdd�Zdd�ZdS)z#AsyncIteratorTest.WithAsyncIteratorcCsgd�|_dS)N)rfZ	NormalFoo�baz)Zitemsrrrrr�rz,AsyncIteratorTest.WithAsyncIterator.__init__cCrrrrrrrr��rz-AsyncIteratorTest.WithAsyncIterator.__aiter__c�rrrrrrrr��rz-AsyncIteratorTest.WithAsyncIterator.__anext__N)rrr rr�r�rrrr�WithAsyncIterator�sr$cs@tdd��gd��j_�fdd�}t|��}|�|gd��dS)NZtesterrr�c�sdd��2�IdHS)Nc�sg|z3dHW}|�q6Srr)Z.0ZirrrZ
<listcomp>�rzOAsyncIteratorTest.test_aiter_set_return_value.<locals>.main.<locals>.<listcomp>rr�Z	mock_iterrrr��rz;AsyncIteratorTest.test_aiter_set_return_value.<locals>.main)rr�rMrrR)rr�r�rr%r�test_aiter_set_return_value�s


z-AsyncIteratorTest.test_aiter_set_return_valuec	r�)NcsT���}||�}��t|j����t|j����t|j����t|j��dSr)r$r�rr�r0r�)r�ryrrrrr��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�rz5AsyncIteratorTest.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)Zappend)ZiteratorZaccumulatorr�rrr�iterate�sz6AsyncIteratorTest.test_mock_async_for.<locals>.iterate)ZFOOZBARZBAZcs$|����}��t�|��g�dSr)r$rRr�r�r)r(rrr�test_default�r}z;AsyncIteratorTest.test_mock_async_for.<locals>.test_defaultcs4|����}�dd�|j_��t�|����dSr)r$r�rMrRrr)�Zexpectedr(rrr�test_set_return_value�szDAsyncIteratorTest.test_mock_async_for.<locals>.test_set_return_valuecs8|����}t�dd��|j_��t�|����dSr)r$Ziterr�rMrRrr)r+rr�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�)rr*r,r-r�rr+r�test_mock_async_for�s&&z%AsyncIteratorTest.test_mock_async_forN)rrr r6r$r&r'r.rrrrr"�sr"c@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)rrcrrrr�setUp�rzAsyncMockAssert.setUpc�s|j|i|��IdHdSr)rcrrrr�_runnable_test�rzAsyncMockAssert._runnable_testc�s
|IdHSrr)r�	coroutinerrr�_await_coroutine�rz AsyncMockAssert._await_coroutinecCs�tt�}t|��|��Wd�n1s.0Y|�t|j��|j��|j��|j��|�	t
��|��Wd�n1s�0Y|�	t
��|j��Wd�n1s�0YdSr)rrr-rr0r�
assert_called�assert_called_once�assert_called_once_withrzr�rkrbrrr�"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)
rrrr4r5r6rzr�rkrr3r�r�)rrcZmock_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)	rzr�rcrkr4rr1r5r�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-rzr�rkr4rr3r��rrcr2rrr�)test_assert_called_twice_and_awaited_onces
&(

z9AsyncMockAssert.test_assert_called_twice_and_awaited_oncecCsntt�}|��}|j��t|�|��|�t��t|�|��Wd�n1sV0Y|j��dSr)	rrrr5rr3rzr{rkr: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)rzr�rcrkr4rrr3rrrr�"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�Nrf)rr-rcZassert_has_callsrzr�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�rrfr#)r-rcrR�
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)	Nr@rrKrOrPir�)r&r')rrr-rrRrAr)rZa_class_mockrBZmethod_kallsrCrrr�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)NrP)�fishr�)�cake�	something)rPrFzsomething_else.something)r�rGz#method calls not recorded correctly)r-rcrHZsomething_elserZCakerR�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�rIrA)ZgetattrrEr
ZlistrR)rcZnamesr
Zattrrrr�assert_attrsks
z:AsyncMockAssert.test_async_arg_lists.<locals>.assert_attrsrKrOrP)r&)rcr-r�rrr)rrKr�rrr�test_async_arg_listsjs"

&
*
*


&
.z$AsyncMockAssert.test_async_arg_listscCsN|�t��|j��Wd�n1s*0Yt|���|j��dSr)rzr�rcrkrr1rrrr�test_assert_awaited�s(z#AsyncMockAssert.test_assert_awaitedcCs�|�t��|j��Wd�n1s*0Yt|���|j��t|���|�t��|j��Wd�n1s�0YdSr)rzr�rcr�rr1rrrr�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 awaitedrfzexpected await not found�
SomethingElse)�assertRaisesRegexr�rcr�rr1rz)rZmsgrrr�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�0YdSr>)rzr�rcr�rr1rrrr�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)Nrfr#rO)rzr�rcr�rr1rrrr�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)Nrfr#rKrO)rrzr�rcr�rRZlen�	exceptionrrr1)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@r!)z9AsyncMockAssert.test_awaits_asserts_with_any.<locals>.FoocSrrr�rZotherrrr�__eq__�rz@AsyncMockAssert.test_awaits_asserts_with_any.<locals>.Foo.__eq__N�rrr rXrrrr�Foo�r$rZrK)rr1rcr�rrr�r�)rrZrrr�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@r!)zBAsyncMockAssert.test_awaits_asserts_with_spec_and_any.<locals>.FoocSrrrrWrrrrX�rzIAsyncMockAssert.test_awaits_asserts_with_spec_and_any.<locals>.Foo.__eq__NrYrrrrrZ�r$rZrc�s�|�IdHdSrrr�Zmock_with_specrr�_custom_mock_runnable_test�rzYAsyncMockAssert.test_awaits_asserts_with_spec_and_any.<locals>._custom_mock_runnable_testrK)rrr�rrr�r�)rrZr]rr\r�%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)Nrfr#T)Z	any_orderZbamfZqux)rrzr�rcr�rr1)rrUrrr�test_assert_has_awaits_ordered�s...z.AsyncMockAssert.test_assert_has_awaits_orderedcCsN|j��t|���|�t��|j��Wd�n1s@0YdSr)rcr�rr1rzr�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�rrrr�rrr�frzIAsyncMockAssert.test_assert_has_awaits_not_matching_spec_error.<locals>.frrKz^{}$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)]rOr)rrcrr1rPr�Zformat�reZescaper�rr�rTZ	__cause__rEr)rrar�rrr�.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
rrr
rrr"r%r)r*r6r+rrAr�r-ZTestCaser.rUrarrr�r�r�r�rr"r/rrrrZ<module>s<,


=!"Tay&rE