AlkantarClanX12

Your IP : 18.116.85.108


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.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._callCleanupcOs^|jdus	Jd��||i|��}t�|�sJ|�d���|j��}|j�||f�|j�|�S)N�$asyncio test loop is not initializedz returned non-awaitable�r	�inspectZisawaitable�
create_futurer
�
put_nowait�run_until_complete�rrrr�ret�futrrrrIs
z"IsolatedAsyncioTestCase._callAsynccOsT|jdus	Jd��||i|��}t�|�r(|j��}|j�||f�|j�|�S|S)Nr"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._asyncioLoopRunnercCs\|jdus	Jd��t��}t�|�|�d�||_|��}|�|�|��|_|�	|�dS)Nz%asyncio test loop already initializedT)
r	r+Znew_event_loop�set_event_loopZ	set_debugr%Zcreate_taskr2Z_asyncioCallsTaskr')r�loopr*rrr�_setupAsyncioLoopns

z)IsolatedAsyncioTestCase._setupAsyncioLoopc
Cs$|jdus	Jd��|j}d|_|j�d�|�|j���zct�|�}|s8W|�|���t�d�|�	�dS|D]}|�
�q:|�tj|ddi��|D]}|��rUqN|�
�durf|�d|�
�|d��qN|�|���W|�|���t�d�|�	�dS|�|���t�d�|�	�w)Nr"Zreturn_exceptionsTz(unhandled exception during test shutdown)�message�	exception�task)r	r
r&r'�joinr+Z	all_tasksZshutdown_default_executorr3�closeZcancelZgatherr-r7Zcall_exception_handlerZshutdown_asyncgens)rr4Z	to_cancelr8rrr�_tearDownAsyncioLoopxsD

�
���
�

z,IsolatedAsyncioTestCase._tearDownAsyncioLoopNcs*|��zt��|�W|��S|��wr)r5r�runr;)r�resultrrrr<�szIsolatedAsyncioTestCase.runcs|��t���|��dSr)r5r�debugr;rrrrr>�s
zIsolatedAsyncioTestCase.debugcCs|jdur|��dSdSr)r	r;rrrr�__del__�s
�zIsolatedAsyncioTestCase.__del__)rr)�__name__�
__module__�__qualname__rrrrrrr r!rrr2r5r;r<r>r?�
__classcell__rrrrrs"

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