Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/test_asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/test_asyncio/__pycache__/test_pep492.cpython-39.opt-2.pyc

a

XC?h��@s�ddlZddlZddlZddlmZddlZddlmZdd�ZGdd�d�Z	Gdd	�d	ej
�ZGd
d�de�ZGdd
�d
e�Z
Gdd�de�Zedkr�e��dS)�N)�mock)�utilscCst�d�dS�N)�asyncioZset_event_loop_policy�rr�B/opt/alt/python39/lib64/python3.9/test/test_asyncio/test_pep492.py�tearDownModule
src@s.eZdZdd�Zd
dd�Zdd�Zdd	�ZdS)�FakeCorocCsdSrr)�self�valuerrr�sendsz
FakeCoro.sendNcCsdSrr)r
�typ�val�tbrrr�throwszFakeCoro.throwcCsdSrr�r
rrr�closeszFakeCoro.closeccs
dVdSrrrrrr�	__await__szFakeCoro.__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)�	LockTestscs���t��Dtj�jd�tj�jd�tj�jd�tj�jd�g}Wd�n1sT0Y�fdd�}|D]"}�j�||����	|�
��qndS)N�rc	�s�t�d�IdH��|���|4IdH�N}��|d���|���t�d�IdH��|���Wd�IdHq�1IdHs�0Y��|���dS)N�{�G�z�?)r�sleep�assertFalse�lockedZassertIs�
assertTrue)�lock�_lockrrr�test6s8z7LockTests.test_context_manager_async_with.<locals>.test��assertWarns�DeprecationWarningrZLockrZ	ConditionZ	SemaphoreZBoundedSemaphore�run_until_completer"r#�r
Z
primitivesr'Z	primitiverrr�test_context_manager_async_with-s�"
z)LockTests.test_context_manager_async_withcs���t��Dtj�jd�tj�jd�tj�jd�tj�jd�g}Wd�n1sT0Y�fdd�}|D]"}�j�||����	|�
��qndS)Nrc	�sxt�d�IdH��|�����td��:|IdH�Wd�n1sL0YWd�n1sj0YdS)Nr z#can't be used in 'await' expression)rr!r"r#ZassertRaisesRegex�	TypeError)r%rrrr'Ms�z7LockTests.test_context_manager_with_await.<locals>.testr(r,rrr�test_context_manager_with_awaitDs�"
z)LockTests.test_context_manager_with_awaitN)rrrr-r/rrrrr+src@seZdZdd�ZdS)�StreamReaderTestscsRd}tj|jd����|�����fdd�}|j�|��}|�|gd��dS)Nsline1
line2
line3rc�s&g}�2z3dHW}|�|�q6|Sr)�append)�data�line��streamrr�readeresz/StreamReaderTests.test_readline.<locals>.reader)sline1
sline2
sline3)r�StreamReaderrZ	feed_dataZfeed_eofr+�assertEqual)r
ZDATAr6r2rr4r�
test_readline^s
zStreamReaderTests.test_readlineN)rrrr9rrrrr0\sr0c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�CoroutineTestscCsLdd�}|�}z|�t�|��W|��n
|��0|�t�t���dS)Nc�sdSrrrrrr�foor�z,CoroutineTests.test_iscoroutine.<locals>.foo)r$rZiscoroutinerr	)r
r;�frrr�test_iscoroutineqszCoroutineTests.test_iscoroutinecCsdd�}|�t�|��dS)Nc�sdSrrrrrrr;}r<z4CoroutineTests.test_iscoroutinefunction.<locals>.foo)r$rZiscoroutinefunction)r
r;rrr�test_iscoroutinefunction|sz'CoroutineTests.test_iscoroutinefunctioncsnGdd�d��|�t��"tj�fdd��}Wd�n1s@0Y|�}|�|�d�d�|��dS)Nc@seZdZdd�ZdS)zCCoroutineTests.test_function_returning_awaitable.<locals>.AwaitablecSsdS)N)�spamrrrrrr�szMCoroutineTests.test_function_returning_awaitable.<locals>.Awaitable.__await__N)rrrrrrrr�	Awaitable�srAcs��Srrr�rArr�func�sz>CoroutineTests.test_function_returning_awaitable.<locals>.funcr@)r)r*r�	coroutiner8rr)r
rC�cororrBr�!test_function_returning_awaitable�s,z0CoroutineTests.test_function_returning_awaitablecsXdd���fdd�}|j�|��}|�|d�|j�d�|j�|��}|�|d�dS)Nc�sdS)Nr@rrrrr�bar�sz5CoroutineTests.test_async_def_coroutines.<locals>.barc�s��IdHSrrr�rGrrr;�sz5CoroutineTests.test_async_def_coroutines.<locals>.foor@T)rr+r8�	set_debug)r
r;r2rrHr�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�szOCoroutineTests.test_debug_mode_manages_coroutine_origin_tracking.<locals>.startrT)r8rLrMrrIr+)r
rNrrr�1test_debug_mode_manages_coroutine_origin_tracking�s
z@CoroutineTests.test_debug_mode_manages_coroutine_origin_trackingcsFdd��tj�fdd�����fdd�}�j�|��}��|d�dS)NcssdEdHdS)Nrr@rrrrr�gen�s
z0CoroutineTests.test_types_coroutine.<locals>.gencs��Srrr)rPrrrC�sz1CoroutineTests.test_types_coroutine.<locals>.funcc�s��}��|tj�|IdHSr)ZassertIsInstance�types�_GeneratorWrapper)�wrapper)rCr
rrrE�sz1CoroutineTests.test_types_coroutine.<locals>.coror@)rQrDrr+r8)r
rEr2r)rCrPr
r�test_types_coroutine�sz#CoroutineTests.test_types_coroutinecs4d���fdd�����fdd�}�j�|��dS)Nc�s4�jdd�}z��|djjd�Wd}nd}0dS)N�)�limitrr;)Z	get_stackr8�f_code�co_name)r=)�Tr
rrr;�sz1CoroutineTests.test_task_print_stack.<locals>.fooc�s tj���jd���IdHdS)Nr)rZ
ensure_futurerr�rYr;r
rr�runner�sz4CoroutineTests.test_task_print_stack.<locals>.runner)rr+�r
r[rrZr�test_task_print_stack�sz$CoroutineTests.test_task_print_stackcsbdd����fdd�}�j�d��jtdd���j�|��Wd�n1sT0YdS)Nc�st�d�IdHdS)Ng�������?)rr!rrrr�afunc�sz/CoroutineTests.test_double_await.<locals>.afuncc�sH��}�j�|�}z&t�d�IdH|IdHW|��n
|��0dSrK)rZcreate_taskrr!Zcancel)rE�t�r^r
rrr[�sz0CoroutineTests.test_double_await.<locals>.runnerTz"coroutine is being awaited already)�msg)rrIZassertRaises�RuntimeErrorr+r\rr`r�test_double_await�s	�z CoroutineTests.test_double_awaitN)rrrr>r?rFrJrOrTr]rcrrrrr:os	r:�__main__)rLrQZunittestrrZtest.test_asynciorZ
test_utilsrr	ZTestCaserrr0r:r�mainrrrr�<module>s1n