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_pep492.cpython-310.pyc

o

0�i��@s�dZddlZddlZddlZddlmZddlZddlmZdd�Z	Gdd�d�Z
Gd	d
�d
ej�ZGdd�de�Z
Gd
d�de�ZGdd�de�ZedkrTe��dSdS)z3Tests support for new syntax introduced by PEP 492.�N)�mock)�utilscCst�d�dS�N)�asyncioZset_event_loop_policy�rr�D/opt/alt/python310/lib64/python3.10/test/test_asyncio/test_pep492.py�tearDownModule
src@s.eZdZdd�Zd
dd�Zdd�Zdd	�ZdS)�FakeCorocC�dSrr)�self�valuerrr�send�z
FakeCoro.sendNcCr
rr)r�typ�val�tbrrr�throwrzFakeCoro.throwcCr
rr�rrrr�closerzFakeCoro.closeccs�dVdSrrrrrr�	__await__s�
zFakeCoro.__await__)NN)�__name__�
__module__�__qualname__r
rrrrrrrr	s

r	cseZdZ�fdd�Z�ZS)�BaseTestcsHt���t��|_t��|j_t��|j_d|jjj	_
|�|j�dS)Nr)�super�setUprZ
BaseEventLoop�looprZMockZ_process_eventsZ	_selectorZselectZreturn_valueZset_event_loopr��	__class__rrr"s

zBaseTest.setUp)rrrr�
__classcell__rrrrr src@seZdZdd�Zdd�ZdS)�	LockTestsc�Tt��t��t��t��g}�fdd�}|D]}�j�||����|���qdS)Nc	�s��t�d�IdH��|���|4IdH�'}��|d���|���t�d�IdH��|���Wd�IdHn1IdHsCwY��|���dS)N�{�G�z�?)r�sleep�assertFalse�lockedZassertIs�
assertTrue)�lock�_lockrrr�test5s�(�z7LockTests.test_context_manager_async_with.<locals>.test�	rZLockZ	ConditionZ	SemaphoreZBoundedSemaphorer�run_until_completer$r%�rZ
primitivesr)Z	primitiverrr�test_context_manager_async_with-��
�z)LockTests.test_context_manager_async_withcr!)Nc	�s��t�d�IdH��|�����td��&|IdH�Wd�n1s'wYWd�dSWd�dS1s?wYdS)Nr"z#can't be used in 'await' expression)rr#r$r%ZassertRaisesRegex�	TypeError)r'rrrr)Ks����"�z7LockTests.test_context_manager_with_await.<locals>.testr*r,rrr�test_context_manager_with_awaitCr.z)LockTests.test_context_manager_with_awaitN)rrrr-r0rrrrr +sr c@�eZdZdd�ZdS)�StreamReaderTestscsRd}tj|jd����|�����fdd�}|j�|��}|�|gd��dS)Nsline1
line2
line3�rc�s(�g}�2z3dHW}|�|�q6|Sr)�append)�data�line��streamrr�readercs��z/StreamReaderTests.test_readline.<locals>.reader)sline1
sline2
sline3)r�StreamReaderrZ	feed_dataZfeed_eofr+�assertEqual)rZDATAr9r5rr7r�
test_readline\s
zStreamReaderTests.test_readlineN)rrrr<rrrrr2Zsr2c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�CoroutineTestscCsLdd�}|�}z|�t�|��W|��n|��w|�t�t���dS)Nc���dSrrrrrr�foop��z,CoroutineTests.test_iscoroutine.<locals>.foo)r&rZiscoroutinerr	)rr?�frrr�test_iscoroutineoszCoroutineTests.test_iscoroutinecCsdd�}|�t�|��dS)Nc�r>rrrrrrr?{r@z4CoroutineTests.test_iscoroutinefunction.<locals>.foo)r&rZiscoroutinefunction)rr?rrr�test_iscoroutinefunctionzsz'CoroutineTests.test_iscoroutinefunctioncsnGdd�d��|�t��tj�fdd��}Wd�n1s wY|�}|�|�d�d�|��dS)Nc@r1)zCCoroutineTests.test_function_returning_awaitable.<locals>.AwaitablecSsdS)N)�spamrrrrrr�rzMCoroutineTests.test_function_returning_awaitable.<locals>.Awaitable.__await__N)rrrrrrrr�	AwaitablesrEc���Srrr�rErr�func��z>CoroutineTests.test_function_returning_awaitable.<locals>.funcrD)ZassertWarns�DeprecationWarningr�	coroutiner;r
r)rrH�cororrGr�!test_function_returning_awaitable~s�z0CoroutineTests.test_function_returning_awaitablecsXdd���fdd�}|j�|��}|�|d�|j�d�|j�|��}|�|d�dS)Nc�s�dS)NrDrrrrr�bar�s�z5CoroutineTests.test_async_def_coroutines.<locals>.barc�s���IdHSrrr�rNrrr?�s�z5CoroutineTests.test_async_def_coroutines.<locals>.foorDT)rr+r;�	set_debug)rr?r5rrOr�test_async_def_coroutines�sz(CoroutineTests.test_async_def_coroutinescsJ�fdd�}��t��d��j�d��j�|����t��d�dS)Nc�s���t��dk�dS�Nr)r&�sys�#get_coroutine_origin_tracking_depthrrrr�start�s�zOCoroutineTests.test_debug_mode_manages_coroutine_origin_tracking.<locals>.startrT)r;rSrTrrPr+)rrUrrr�1test_debug_mode_manages_coroutine_origin_tracking�s
z@CoroutineTests.test_debug_mode_manages_coroutine_origin_trackingcsFdd��tj�fdd�����fdd�}�j�|��}��|d�dS)Ncss�dEdHdS)NrrDrrrrr�gen�s�
z0CoroutineTests.test_types_coroutine.<locals>.gencrFrrr)rWrrrH�rIz1CoroutineTests.test_types_coroutine.<locals>.funcc�s ���}��|tj�|IdHSr)ZassertIsInstance�types�_GeneratorWrapper)�wrapper)rHrrrrL�s�
z1CoroutineTests.test_types_coroutine.<locals>.cororD)rXrKrr+r;)rrLr5r)rHrWrr�test_types_coroutine�sz#CoroutineTests.test_types_coroutinecs4d���fdd�����fdd�}�j�|��dS)Nc�s4��jdd�}z��|djjd�Wd}dSd}w)N�)�limitrr?)Z	get_stackr;�f_code�co_name)rA)�Trrrr?�s
�z1CoroutineTests.test_task_print_stack.<locals>.fooc�s"�tj���jd���IdHdS)Nr3)rZ
ensure_futurerr�r`r?rrr�runner�s�z4CoroutineTests.test_task_print_stack.<locals>.runner)rr+�rrbrrar�test_task_print_stack�sz$CoroutineTests.test_task_print_stackcsddd����fdd�}�j�d��jtdd���j�|��Wd�dS1s+wYdS)Nc�s�t�d�IdHdS)Ng�������?)rr#rrrr�afunc�s�z/CoroutineTests.test_double_await.<locals>.afuncc�sH���}�j�|�}zt�d�IdH|IdHW|��dS|��wrR)rZcreate_taskrr#Zcancel)rL�t�rerrrrb�s�z0CoroutineTests.test_double_await.<locals>.runnerTz"coroutine is being awaited already)�msg)rrPZassertRaises�RuntimeErrorr+rcrrgr�test_double_await�s	�"�z CoroutineTests.test_double_awaitN)rrrrBrCrMrQrVr[rdrjrrrrr=ms	r=�__main__)�__doc__rSrXZunittestrrZtest.test_asynciorZ
test_utilsrr	ZTestCaserr r2r=r�mainrrrr�<module>s /n�