Your IP : 216.73.216.213


Current Path : /opt/alt/python310/lib64/python3.10/test/test_asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/test_asyncio/__pycache__/test_runners.cpython-310.pyc

o

0�i��@s|ddlZddlZddlmZddlmZdd�ZGdd�dej�ZGdd	�d	ej	�Z
Gd
d�de
�Zedkr<e�
�dSdS)
�N)�mock)�utilscCst�d�dS�N)�asyncio�set_event_loop_policy�rr�E/opt/alt/python310/lib64/python3.10/test/test_asyncio/test_runners.py�tearDownModulesr	c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
TestPolicycCs||_d|_dSr)�loop_factory�loop)�selfrrrr�__init__s
zTestPolicy.__init__cCst�r)�RuntimeError�r
rrr�get_event_loopszTestPolicy.get_event_loopcCs|��Sr)rrrrr�new_event_loopszTestPolicy.new_event_loopcCs|dur	||_dSdSr�r)r
rrrr�set_event_loops
�zTestPolicy.set_event_loopN)�__name__�
__module__�__qualname__rrrrrrrrr
s
r
cs0eZdZdd�Z�fdd�Z�fdd�Z�ZS)�BaseTestcsBt���t���_t���_d�jj_d�_�fdd�}|�_	�S)NrFc�s�d�_dS�NT)�shutdown_ag_runrrrr�shutdown_asyncgens)s�
z-BaseTest.new_loop.<locals>.shutdown_asyncgens)
rZ
BaseEventLoopr�MockZ_process_eventsZ	_selectorZselectZreturn_valuerr)r
rrrr�new_loop"s


zBaseTest.new_loopcs"t���t|j�}t�|�dSr)�super�setUpr
rrr�r
Zpolicy��	__class__rrr/s

zBaseTest.setUpcsHt��}|jdur|�|j���|�|jj�t�d�t���dSr)	rZget_event_loop_policyr�
assertTrueZ	is_closedrrr�tearDownr r!rrr$5s

zBaseTest.tearDown)rrrrrr$�
__classcell__rrr!rr s
rc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�RunTestscCs dd�}|�t�|��d�dS)Nc�s�t�d�IdHdS)Nr�*�r�sleeprrrr�mainBs�z.RunTests.test_asyncio_run_return.<locals>.mainr')�assertEqualr�run�r
r*rrr�test_asyncio_run_returnAsz RunTests.test_asyncio_run_returncCsFdd�}|�td��t�|��Wd�dS1swYdS)Nc�s�t�d�IdHtd��)Nr�spam)rr)�
ValueErrorrrrrr*Is�z.RunTests.test_asyncio_run_raises.<locals>.mainr/)�assertRaisesRegexr0rr,r-rrr�test_asyncio_run_raisesHs"�z RunTests.test_asyncio_run_raisesc
Csxddd�hD]3}|j|d��#|�td��
t�|�Wd�n1s%wYWd�n1s4wYqdS)N�cSsdSrrrrrr�<lambda>Q�z5RunTests.test_asyncio_run_only_coro.<locals>.<lambda>)�objza coroutine was expected)ZsubTestr1r0rr,)r
�orrr�test_asyncio_run_only_coroPs������z#RunTests.test_asyncio_run_only_corocs��fdd�}t�|d��tj|d�dd�t�ddd���t�|d��tj|d�dd�Wd�dS1s:wYdS)	Nc�s�t��}��|��|�dSr)rrZassertIsZ	get_debug)Zexpectedrrrrr*Xs�z-RunTests.test_asyncio_run_debug.<locals>.mainFT)�debugz!asyncio.coroutines._is_debug_modecSsdSrrrrrrr4^r5z1RunTests.test_asyncio_run_debug.<locals>.<lambda>)rr,rZpatchr-rrr�test_asyncio_run_debugWs"�zRunTests.test_asyncio_run_debugcsJ�fdd��|�td��t����Wd�dS1swYdS)Nc�s,���}zt�|�W|��dS|��wr)rr,�close)�coro�r*rrr*cs
�z9RunTests.test_asyncio_run_from_running_loop.<locals>.mainzcannot be called from a running)r1rrr,rrr=r�"test_asyncio_run_from_running_loopbs�"�z+RunTests.test_asyncio_run_from_running_loopcs@d�dd����fdd�}|�t�|��d�|�����dS)Nc�s�t�d�IdHdS)N皙�����?r(rrrr�leftoverqs�zARunTests.test_asyncio_run_cancels_hanging_tasks.<locals>.leftoverc�s�t�����dS�N�{)r�create_taskr�r@�lo_taskrrr*ts�z=RunTests.test_asyncio_run_cancels_hanging_tasks.<locals>.mainrB)r+rr,r#�doner-rrDr�&test_asyncio_run_cancels_hanging_tasksns
z/RunTests.test_asyncio_run_cancels_hanging_taskscshd�t���dd�����fdd�}|�t�|��d�|�������t�	d��t�
t�d��dS)Nc�s8�zt�d�IdHWdStjyddYdSw)Nr?r3r)rr)�CancelledErrorrrrrr@�s��zHRunTests.test_asyncio_run_reports_hanging_tasks_errors.<locals>.leftoverc�s �t��}�|_t�����dSrA)r�get_running_loop�call_exception_handlerrCr�Zcall_exc_handler_mockr@rErrr*�s
�zDRunTests.test_asyncio_run_reports_hanging_tasks_errors.<locals>.mainrBzasyncio.run.*shutdown)�messageZtaskZ	exception)rrr+rr,r#rFZassert_called_with�
test_utilsZMockPatternZMockInstanceOf�ZeroDivisionErrorr-rrKr�-test_asyncio_run_reports_hanging_tasks_errors|s�z6RunTests.test_asyncio_run_reports_hanging_tasks_errorscs�d�d�Gdd�dt��dd����fdd�����fdd�}|����t�|��Wd�n1s5wY|�����|��j�|��j	�dS)	Nc@seZdZdS)zSRunTests.test_asyncio_run_closes_gens_after_hanging_tasks_errors.<locals>.FancyExitN)rrrrrrr�	FancyExit�srPcSs�	dVt�d�IdHq)NTr3r(rrrr�fidget�s
��zPRunTests.test_asyncio_run_closes_gens_after_hanging_tasks_errors.<locals>.fidgetc�sB����z
�2z3dHW}q6WdStjy ddYdSw)Nr3r)rrH)Zthe_meaning_of_life)rQ�spinnerrr�spin�s���zNRunTests.test_asyncio_run_closes_gens_after_hanging_tasks_errors.<locals>.spinc�s$�t��}t��|_t�������r)rrIrrrJrCr)rP�lazyboyrSrrr*�s
�
zNRunTests.test_asyncio_run_closes_gens_after_hanging_tasks_errors.<locals>.main)
�	ExceptionZassertRaisesrr,r#rFZassertIsNone�ag_frameZassertFalse�
ag_runningr-r)rPrQrTrSrRr�7test_asyncio_run_closes_gens_after_hanging_tasks_errors�s	�z@RunTests.test_asyncio_run_closes_gens_after_hanging_tasks_errorsN)rrrr.r2r8r:r>rGrOrXrrrrr&?sr&�__main__)rZunittestrZtest.test_asynciorrMr	ZAbstractEventLoopPolicyr
ZTestCaserr&rr*rrrr�<module>s~�