Your IP : 3.144.15.34


Current Path : /opt/alt/python310/lib64/python3.10/unittest/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/unittest/__pycache__/async_case.cpython-310.opt-1.pyc

o

6��f��@s0ddlZddlZddlmZGdd�de�ZdS)�N�)�TestCasecs�eZdZd#�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd$�fdd�	Z�fdd �Zd!d"�Z�ZS)%�IsolatedAsyncioTestCase�runTestcst��|�d|_d|_dS�N)�super�__init__�_asyncioTestLoop�_asyncioCallsQueue)�selfZ
methodName��	__class__��:/opt/alt/python310/lib64/python3.10/unittest/async_case.pyr!s
z IsolatedAsyncioTestCase.__init__c���dSrr�rrrr�
asyncSetUp&��z"IsolatedAsyncioTestCase.asyncSetUpc�rrrrrrr�
asyncTearDown)rz%IsolatedAsyncioTestCase.asyncTearDowncO�|j|g|�Ri|��dSr)Z
addCleanup)r�func�args�kwargsrrr�addAsyncCleanup,s
z'IsolatedAsyncioTestCase.addAsyncCleanupcCs|��|�|j�dSr)ZsetUp�
_callAsyncrrrrr�
_callSetUp;sz"IsolatedAsyncioTestCase._callSetUpcCs|�|�dSr��_callMaybeAsync)r�methodrrr�_callTestMethod?sz'IsolatedAsyncioTestCase._callTestMethodcCs|�|j�|��dSr)rrZtearDownrrrr�
_callTearDownBsz%IsolatedAsyncioTestCase._callTearDowncOrrr)rZfunctionrrrrr�_callCleanupFsz$IsolatedAsyncioTestCase._callCleanupcOs4||i|��}|j��}|j�||f�|j�|�Sr)r	�
create_futurer
�
put_nowait�run_until_complete�rrrr�ret�futrrrrIs
z"IsolatedAsyncioTestCase._callAsynccOsB||i|��}t�|�r|j��}|j�||f�|j�|�S|Sr)�inspectZisawaitabler	r"r
r#r$r%rrrrQs

z'IsolatedAsyncioTestCase._callMaybeAsyncc
�s��t��|_}|�d�	|��IdH}|��|durdS|\}}z|IdH}|��s2|�|�Wn'ttfy=�t	tj
fyZ}z|��sP|�|�WYd}~nd}~wwqr)�asyncioZQueuer
Z
set_result�getZ	task_done�	cancelled�
SystemExit�KeyboardInterrupt�
BaseExceptionZCancelledErrorZ
set_exception)rr'�queueZqueryZ	awaitabler&Zexrrr�_asyncioLoopRunner[s,�


�
���z*IsolatedAsyncioTestCase._asyncioLoopRunnercCsJt��}t�|�|�d�||_|��}|�|�|��|_|�	|�dS)NT)
r)Znew_event_loop�set_event_loopZ	set_debugr	r"Zcreate_taskr0Z_asyncioCallsTaskr$)r�loopr'rrr�_setupAsyncioLoopns

z)IsolatedAsyncioTestCase._setupAsyncioLoopc
Cs|j}d|_|j�d�|�|j���zct�|�}|s/W|�|���t�d�|�	�dS|D]}|�
�q1|�tj|ddi��|D]}|��rLqE|�
�dur]|�d|�
�|d��qE|�|���W|�|���t�d�|�	�dS|�|���t�d�|�	�w)NZreturn_exceptionsTz(unhandled exception during test shutdown)�message�	exception�task)r	r
r#r$�joinr)Z	all_tasksZshutdown_default_executorr1�closeZcancelZgatherr+r5Zcall_exception_handlerZshutdown_asyncgens)rr2Z	to_cancelr6rrr�_tearDownAsyncioLoopxsB

�
���
�

z,IsolatedAsyncioTestCase._tearDownAsyncioLoopNcs*|��zt��|�W|��S|��wr)r3r�runr9)r�resultrrrr:�szIsolatedAsyncioTestCase.runcs|��t���|��dSr)r3r�debugr9rrrrr<�s
zIsolatedAsyncioTestCase.debugcCs|jdur|��dSdSr)r	r9rrrr�__del__�s
�zIsolatedAsyncioTestCase.__del__)rr)�__name__�
__module__�__qualname__rrrrrrr r!rrr0r3r9r:r<r=�
__classcell__rrrrrs"

$r)r)r(�caserrrrrr�<module>s

?>