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_queues.cpython-39.opt-2.pyc

a

XC?h�U�@s�ddlZddlmZddlZddlmZddlmZdd�ZGdd�dej	�Z
Gd	d
�d
e
�ZGdd�de
�ZGd
d�de
�Z
Gdd�de
�ZGdd�de
�ZGdd�d�ZGdd�dee
�ZGdd�dee
�ZGdd�dee
�Zedkr�e��dS)�N)�mock)�GenericAlias)�utilscCst�d�dS�N)�asyncioZset_event_loop_policy�rr�B/opt/alt/python39/lib64/python3.9/test/test_asyncio/test_queues.py�tearDownModulesr	cseZdZ�fdd�Z�ZS)�_QueueTestBasecst���|��|_dSr)�super�setUp�
new_test_loop�loop��self��	__class__rrrs
z_QueueTestBase.setUp)�__name__�
__module__�__qualname__r�
__classcell__rrrrr
sr
c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�QueueBasicTestscs@�fdd�}��|����t��tj�d�}Wd�n1sB0Y���|��d��|��tt|���|�v}��	||����fdd�}��t����
|��Wd�n1s�0Y���fdd�}��t��(��
|��tj�d�}Wd�n1�s0Y|�d	���d
�|�v�dS)Nc3s.dV}��d|�dV}��d|�dVdS�N皙�����?g�������?��assertAlmostEqual�Zwhenrrr�gens
z.QueueBasicTests._test_repr_or_str.<locals>.gen�rz<Queuec�sJtj�d�}��|���t�d�IdH��d�|�v�|�d�dS)Nrrz_getters[1]r)r�Queue�create_task�get�sleep�
assertTrue�
put_nowait��q��fnrrrr�
add_getter-s
z5QueueBasicTests._test_repr_or_str.<locals>.add_getterc�sVtjd�d�}|�d���|�d��t�d�IdH��d�|�v�|��dS)N���maxsizer�rz_putters[1])rrr$r �putr"r#�
get_nowaitr%r'rr�
add_putter:s
z5QueueBasicTests._test_repr_or_str.<locals>.add_putterr*z
_queue=[1])r
�assertWarns�DeprecationWarningrrr#�
startswith�hex�id�assertEqual�run_until_completer$)rr(Z	expect_idrr&Z
id_is_presentr)r0rr'r�_test_repr_or_strs 
*
*,
z!QueueBasicTests._test_repr_or_strcCs�t��}|�t��tj|d�}Wd�n1s40Y|�|j|�|�t��tj|jd�}Wd�n1sz0Y|�|j|j�dS�Nr)	rZMockr1r2rr�assertIs�_loopr)rrr&rrr�test_ctor_loopKs*,zQueueBasicTests.test_ctor_loopcCs(t�|j�t��}|�|j|j�dSr)rZset_event_looprrr:r;�rr&rrr�test_ctor_noloopUsz QueueBasicTests.test_ctor_noloopcCs|�td�dS�NT)r8�reprrrrr�	test_reprZszQueueBasicTests.test_reprcCs|�td�dS)NF)r8�strrrrr�test_str]szQueueBasicTests.test_strcCs*tjt}|�|jtf�|�|t�dSr)rr�intr6�__args__ZassertIsInstancerr=rrr�test_generic_alias`s
z"QueueBasicTests.test_generic_aliascCs�|�t��tj|jd�}Wd�n1s.0Y|�|���|�d�|�|���|�	d|�
��|�|���dS�Nrr*)r1r2rrrr#�emptyr$�assertFalser6r/r=rrr�
test_emptyes,
zQueueBasicTests.test_emptycCs�|�t��tj|jd�}Wd�n1s.0Y|�|���|�t�� tjd|jd�}Wd�n1sv0Y|�d�|�|���dS)Nrr*r+)	r1r2rrrrI�fullr$r#r=rrr�	test_fullns,.
zQueueBasicTests.test_fullcsv|�t��tj|jd��Wd�n1s.0YdD]}��|�q<�fdd�td�D�}|�gd�|�dS)Nr�r*�r-csg|]}����qSr�r/��.0�_r%rr�
<listcomp>~�z.QueueBasicTests.test_order.<locals>.<listcomp>rN)r1r2rrrr$�ranger6�r�i�itemsrr%r�
test_orderxs,zQueueBasicTests.test_ordercs��fdd�}��|����t��tjd�d��Wd�n1sD0Y��d�j�g���fdd�������fdd�}��|����d	��	��dS)
Nc3s.dV}��d|�dV}��d|�dVdS)N�{�G�z�?�{�G�z�?rrrrrr�s
z)QueueBasicTests.test_maxsize.<locals>.genr-r+c�s,td�D]}��|�IdH��|�qdS)NrNT)rUr.�append)rW)�
have_been_putr&rr�putter�sz,QueueBasicTests.test_maxsize.<locals>.putterc�s������}t�d�IdH��ddg����d����t�d�IdH��gd�����d������d������|�����|���dS)NrZrr*)rr*r-r-)r rr"r6r/r#�done�result)�t�r]rr^r&rrr�test�sz*QueueBasicTests.test_maxsize.<locals>.testr[)
r
r1r2rrr6r,r7r�time�rrrcrrbr�test_maxsize�s
,zQueueBasicTests.test_maxsizeN)
rrrr8r<r>rArCrFrJrLrYrfrrrrrs3
	
	rc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�
QueueGetTestscsl|�t��tj|jd��Wd�n1s.0Y��d��fdd�}|j�|��}|�d|�dS)Nrr*c�s���IdHSr�r!rr%rr�	queue_get�sz2QueueGetTests.test_blocking_get.<locals>.queue_get)r1r2rrrr$r7r6)rri�resrr%r�test_blocking_get�s,
zQueueGetTests.test_blocking_getcCs�|�t�� tjd|jd�}Wd�n1s00Y|�d�|j��}|j�|�|j�	|�
��}|�d|�|�|�
��|�|���dS)Nr*r)r1r2rrrr$Z
create_future�_puttersr\r7r!r6r#r_ZassertIsNoner`)rr&Zwaiterrjrrr�test_get_with_putters�s.

z#QueueGetTests.test_get_with_putterscs��fdd�}��|����t��(tj�d��tj�d��Wd�n1sN0Yd����fdd��������fdd�}��|��}��d	|���d
��	��dS)Nc3sdV}��d|�dVdS�NrZrrrrrr�sz1QueueGetTests.test_blocking_get_wait.<locals>.genrFc�s������IdH}d�|Sr?)�setr!)rj��finishedr&�startedrrri�sz7QueueGetTests.test_blocking_get_wait.<locals>.queue_getc�sL��d�jd������}���IdH����|IdH}����|S�NrZr*)�
call_laterr$r �waitrIr#)Zqueue_get_taskrj�rqrr&rirrrrr�	queue_put�s


z7QueueGetTests.test_blocking_get_wait.<locals>.queue_putr*rZ)
r
r1r2rr�Eventr7r6rrd)rrrwrjrrvr�test_blocking_get_wait�s
*	z$QueueGetTests.test_blocking_get_waitcCsV|�t��tj|jd�}Wd�n1s.0Y|�d�|�d|���dSrG�r1r2rrrr$r6r/r=rrr�test_nonblocking_get�s,
z"QueueGetTests.test_nonblocking_getcCsL|�t��tj|jd�}Wd�n1s.0Y|�tj|j�dSr9)r1r2rrr�assertRaisesZ
QueueEmptyr/r=rrr�test_nonblocking_get_exception�s,z,QueueGetTests.test_nonblocking_get_exceptioncs��fdd�}��|����t��tj�d��Wd�n1sB0Y�fdd�����fdd�}��d��|�����d	����dS)
Nc3s.dV}��d|�dV}��d|�dVdS)NrZg�Zd;�?g�������?rrrrrr�s
z-QueueGetTests.test_get_cancelled.<locals>.genrc�st����d�IdHS)Ng�&1��?)r�wait_forr!rr%rrrisz3QueueGetTests.test_get_cancelled.<locals>.queue_getc�s0�����}t�d�IdH��d�|IdHSrs)r rr"r$)Zget_task)rr&rirrrcs
z.QueueGetTests.test_get_cancelled.<locals>.testr*g���Q��?)	r
r1r2rrr6r7rrdrer)rr&rirr�test_get_cancelled�s
*z QueueGetTests.test_get_cancelledcCs�|�t��tj|jd�}Wd�n1s.0Y|j�|���}|j�|���}t�|j�|�	�t�|j�|�
|���|�d�t�|j�|�
|��d�dS�Nr�a)r1r2rrrr r!�
test_utils�run_briefly�cancelr#r_r$r6r`)rr&�t1�t2rrr�test_get_cancelled_race
s,
z%QueueGetTests.test_get_cancelled_racecCs�|�t�� tj|jdd�}Wd�n1s00Y|j�|�d��|j�|�d��t�|j�|�	|j�
|���d�|�	|j�
|���d�dS)Nr*�rr,r��b)r1r2rrrr r.r�r�r6r7r!r=rrr�test_get_with_waiting_putterss.z+QueueGetTests.test_get_with_waiting_putterscCs�dd�}dd�}d}d}|�t�� tj||jd�}Wd�n1sH0Y|�t��6|j�tj|||�|||�|jd��Wd�n1s�0YdS)Nc�s t|�D]}|��IdHqdSr)rUr!)�queueZnum_expectedrRrrr�consumer(sz<QueueGetTests.test_why_are_getters_waiting.<locals>.consumerc�s"t|�D]}|�|�IdHqdSr)rUr.)r�Z	num_itemsrWrrr�producer,sz<QueueGetTests.test_why_are_getters_waiting.<locals>.producerr*�r�r1r2rrrr7Zgather)rr�r�Z
queue_sizeZproducer_num_itemsr&rrr�test_why_are_getters_waiting%s.��z*QueueGetTests.test_why_are_getters_waitingcCs�dd�}|�|�|_dd�}|�t�� tj|jdd�}Wd�n1sL0Y|j�|j�||���|�t	|j
�d�dS)NcssdVdVdSrrrrrr�a_generator>szXQueueGetTests.test_cancelled_getters_not_being_held_in_self_getters.<locals>.a_generatorc�s4zt�|��d�IdH}Wntjy.Yn0dS)Nr)rr~r!�TimeoutError)r��itemrrrr�DszUQueueGetTests.test_cancelled_getters_not_being_held_in_self_getters.<locals>.consumerr�r�r)r
rr1r2rrr7r r6�lenZ_getters)rr�r�r�rrr�5test_cancelled_getters_not_being_held_in_self_getters=s.zCQueueGetTests.test_cancelled_getters_not_being_held_in_self_gettersN)
rrrrkrmryr{r}rr�r�r�r�rrrrrg�s
"	rgc@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�
QueuePutTestscsV|�t��tj|jd��Wd�n1s.0Y�fdd�}|j�|��dS)Nrc�s��d�IdHdS)Nr*�r.rr%rrrwVsz2QueuePutTests.test_blocking_put.<locals>.queue_put)r1r2rrrr7�rrwrr%r�test_blocking_putRs,zQueuePutTests.test_blocking_putcs��fdd�}��|����t��*tjd�d��tj�d��Wd�n1sP0Yd����fdd��������fd	d
�}��|����d����dS)Nc3sdV}��d|�dVdSrnrrrrrr^sz1QueuePutTests.test_blocking_put_wait.<locals>.genr*r+rFc�s0�����d�IdH��d�IdHd�dS)Nr*r-T)ror.rrprrrwjsz7QueuePutTests.test_blocking_put_wait.<locals>.queue_putc�sJ��d�j������}���IdH����|IdH����dSrn)rtr/r rurIr#)Zqueue_put_task�rqrr&rwrrrrrriqs

z7QueuePutTests.test_blocking_put_wait.<locals>.queue_getrZ)	r
r1r2rrrxr7rrd)rrrirr�r�test_blocking_put_wait\s
*z$QueuePutTests.test_blocking_put_waitcCsV|�t��tj|jd�}Wd�n1s.0Y|�d�|�d|���dSrGrzr=rrr�test_nonblocking_put|s,
z"QueuePutTests.test_nonblocking_putcCs�dd�}|�|�}|�t��tj|d�}Wd�n1s>0Y|�|���}|�t�d��|�	d�|�	d�|�
�z|�|�Wn,tjy�|�|���}|�|�Yn0|��}|�
d|�dS)NcssdVdVdS�NrZrrrrrrr�szBQueuePutTests.test_get_cancel_drop_one_pending_reader.<locals>.genrrZr*r-)r
r1r2rrr r!r7r"r$r��CancelledErrorr`r6)rrrr&�readerr`rrr�'test_get_cancel_drop_one_pending_reader�s 
*

z5QueuePutTests.test_get_cancel_drop_one_pending_readercCs�dd�}|�|�}|�d�|�t��tj|d�}Wd�n1sH0Y|�|���}|�|���}|�|���}|�t�	d��|�
d�|�
d�|��z|�|�Wntjy�Yn0|�|�|�
|��|��hddh�dS)NcssdVdVdSr�rrrrrr�szDQueuePutTests.test_get_cancel_drop_many_pending_readers.<locals>.genTrrZr*r-)r
Z	set_debugr1r2rrr r!r7r"r$r�r�r6r`)rrrr&Zreader1Zreader2Zreader3rrr�)test_get_cancel_drop_many_pending_readers�s$

*


z7QueuePutTests.test_get_cancel_drop_many_pending_readerscCs�dd�}|�|�}|�t��tjd|d�}Wd�n1s@0Y|�d�|�|�d��}|�t�	d��|�
�}|�|d�|��z|�|�Wn.tj
y�|�|�d��}|�|�Yn0|�
�}|�|d�|�|��d�dS)NcssdVdVdSr�rrrrrr�sz/QueuePutTests.test_put_cancel_drop.<locals>.genr*rr-rZr)r
r1r2rrr$r r.r7r"r/r6r�r��qsize)rrrr&�writerZvalue1Zvalue2rrr�test_put_cancel_drop�s$
,
z"QueuePutTests.test_put_cancel_dropcCsZ|�t�� tjd|jd�}Wd�n1s00Y|�d�|�tj|jd�dS)Nr*r+r-)r1r2rrrr$r|�	QueueFullr=rrr�test_nonblocking_put_exception�s.
z,QueuePutTests.test_nonblocking_put_exceptioncs���t�� tjd�jd��Wd�n1s00Y��d���d���������tj	�jd���t�� tjd�jd��Wd�n1s�0Y��fdd�}�j�
|��dS)Ng�������?r+r*r-rNc�s2��d�IdH��d�IdH������dS)Nr*r-)r.r#rKr�r&rrrrw�sz3QueuePutTests.test_float_maxsize.<locals>.queue_put)r1r2rrrr$r#rKr|r�r7r�rr�r�test_float_maxsize�s.

.z QueuePutTests.test_float_maxsizecs�|�t��tj|jd��Wd�n1s.0Y�fdd�}�fdd�}|j�|��}|�d|j�|���|�|�	��|�|�
��dS)Nrc�s��d�IdHdS)Nr*Tr�rr%rrrw�sz3QueuePutTests.test_put_cancelled.<locals>.queue_putc�s���IdHSrrhrr%rrrc�sz.QueuePutTests.test_put_cancelled.<locals>.testr*)r1r2rrrr r6r7r#r_r`)rrwrcrarr%r�test_put_cancelled�s,z QueuePutTests.test_put_cancelledcCs�|�t�� tj|jdd�}Wd�n1s00Y|j�|�d��}|j�|�d��}|j�|�d��}t�|j�|�	|�
��|�|�
��|��t�|j�|�	|�
��|�
|��d�t�|j�|�
|��d�|j�|�dS)Nr*r�r�r��X)r1r2rrrr r.r�r�r#r_rIr�r6r/r7)rr&Zput_aZput_bZput_crrr�test_put_cancelled_races.z%QueuePutTests.test_put_cancelled_racecCs~|�t��tj|jd�}Wd�n1s.0Y|j�|���}t�|j�|j�	|�
d��|�|j�	|�d�dSr�)r1r2rrrr r!r�r�r7r.r6)rr&rarrr�test_put_with_waiting_getterss,z+QueuePutTests.test_put_with_waiting_getterscs�|�t�� tjd|jd��Wd�n1s00Y�fdd�}�fdd�}|d�}|d�}|d�}|d	�}|�t��2|j�tj|�|||||jd��Wd�n1s�0YdS)
Nr-rc�s��|�IdHdSrr��r��r�rrr^(sz:QueuePutTests.test_why_are_putters_waiting.<locals>.putterc�s2t�d�IdH���}t|�D]}���}q dS)Nr)rr"r�rUr/)ZnumrRr�r�rr�getter+sz:QueuePutTests.test_why_are_putters_waiting.<locals>.getterrr*rNr�)rr^r�Zt0r�r�Zt3rr�r�test_why_are_putters_waiting"s.�z*QueuePutTests.test_why_are_putters_waitingcCs�dd�}|�|�}|�t��tj|dd�}Wd�n1s@0Y|�d�|�|�d��}|�t�	d��|�
t|j�d�|�
�|�tj��|�|�Wd�n1s�0Y|�
t|j�d�dS)NcssdVdVdSr�rrrrrr�:szUQueuePutTests.test_cancelled_puts_not_being_held_in_self_putters.<locals>.a_generatorr*r�rZr)r
r1r2rrr$r r.r7r"r6r�rlr�r|r�)rr�rr��put_taskrrr�2test_cancelled_puts_not_being_held_in_self_putters9s
,
(z@QueuePutTests.test_cancelled_puts_not_being_held_in_self_putterscCs�dd�}|�|�}|�t��tjd|d�}Wd�n1s@0Y|�d�|�|�d��}|�t�	d��|�
�|��|�tj
��|�|�Wd�n1s�0YdS)NcssdVdVdSr�rrrrrrRszKQueuePutTests.test_cancelled_put_silence_value_error_exception.<locals>.genr*rrZ)r
r1r2rrr$r r.r7r"r/r�r|r�)rrrr�r�rrr�0test_cancelled_put_silence_value_error_exceptionQs
,
z>QueuePutTests.test_cancelled_put_silence_value_error_exceptionN)rrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�Ps
  r�c@seZdZdd�ZdS)�LifoQueueTestscsv|�t��tj|jd��Wd�n1s.0YdD]}��|�q<�fdd�td�D�}|�gd�|�dS)NrrMcsg|]}����qSrrOrPr%rrrSvrTz-LifoQueueTests.test_order.<locals>.<listcomp>rN)r-rNr*)r1r2r�	LifoQueuerr$rUr6rVrr%rrYps,zLifoQueueTests.test_orderN�rrrrYrrrrr�nsr�c@seZdZdd�ZdS)�PriorityQueueTestscsv|�t��tj|jd��Wd�n1s.0YdD]}��|�q<�fdd�td�D�}|�gd�|�dS)NrrMcsg|]}����qSrrOrPr%rrrS�rTz1PriorityQueueTests.test_order.<locals>.<listcomp>rN)r*r-rN)r1r2r�
PriorityQueuerr$rUr6rVrr%rrY|s,zPriorityQueueTests.test_orderNr�rrrrr�zsr�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�ZdS)
�_QueueJoinTestMixinNcCsJ|�t��|j|jd�}Wd�n1s.0Y|�t|j�dSr9)r1r2�q_classrr|�
ValueError�	task_doner=rrr�test_task_done_underflow�s,z,_QueueJoinTestMixin.test_task_done_underflowcs���t���j�jd��Wd�n1s.0Ytd�D]}��|�q@d�d����fdd�����fdd�}�j�|��}��ttd����d	�tt	|��D]}��d�q��j�t
�|��dS)
Nr�drTc�s(�r$���IdH}�|7����qdSr)r!r�r�)�accumulatorr&�runningrr�worker�sz2_QueueJoinTestMixin.test_task_done.<locals>.workerc�s*��fdd�td�D�}���IdH|S)Ncsg|]}�j�����qSr)rr )rQ�index)rr�rrrS�s�zD_QueueJoinTestMixin.test_task_done.<locals>.test.<locals>.<listcomp>r-)rU�join)�tasks)r&rr�rrrc�s
�z0_QueueJoinTestMixin.test_task_done.<locals>.testF)r1r2r�rrUr$r7r6�sumr�rru)rrWrcr�r)r�r&r�rr�r�test_task_done�s,z"_QueueJoinTestMixin.test_task_donecsV|�t��|j|jd��Wd�n1s.0Y�fdd�}|j�|��dS)Nrc�s ���IdH���IdHdSr)r�rr%rrr��sz7_QueueJoinTestMixin.test_join_empty_queue.<locals>.join)r1r2r�rr7)rr�rr%r�test_join_empty_queue�s,z)_QueueJoinTestMixin.test_join_empty_queuecCsb|�t��|j|jd�}Wd�n1s.0Y|�|��d�d|_|�|��d�dS)Nrz	maxsize=0r-zmaxsize=0 tasks=2)r1r2r�rr6Z_formatZ_unfinished_tasksr=rrr�test_format�s
,z_QueueJoinTestMixin.test_format)rrrr�r�r�r�r�rrrrr��s
$
r�c@seZdZejZdS)�QueueJoinTestsN)rrrrrr�rrrrr��sr�c@seZdZejZdS)�LifoQueueJoinTestsN)rrrrr�r�rrrrr��sr�c@seZdZejZdS)�PriorityQueueJoinTestsN)rrrrr�r�rrrrr��sr��__main__)Zunittestrr�typesrZtest.test_asynciorr�r	ZTestCaser
rrgr�r�r�r�r�r�r�r�mainrrrr�<module>s*% C