Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_sched.cpython-34.pyo

�
g f��@s�ddlZddlZddlZddlZddlmZyddlZWnek
rjdZYnXdZGdd�d�Z	Gdd�dej
�Z
edkr�ej�ndS)	�N)�support�
c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TimercCs%tj�|_d|_d|_dS)Nr)�	threadingZ	Condition�_cond�_time�_stop)�self�r
�4/opt/alt/python34/lib64/python3.4/test/test_sched.py�__init__s	zTimer.__init__cCs|j�|jSWdQXdS)N)rr)r	r
r
r�times
z
Timer.timec	CsY|j�J||j7}x,|j|krE|j|_|jj�qW||_WdQXdS)N)rrr�wait)r	�tr
r
r�sleeps

zTimer.sleepc
Cs0|j�!|j|7_|jj�WdQXdS)N)rrZ
notify_all)r	rr
r
r�advance#s
z
Timer.advanceN)�__name__�
__module__�__qualname__rr
rrr
r
r
rrs
rc@s�eZdZdd�Zdd�Zejed�dd��Zdd	�Z	d
d�Z
ejed�dd
��Zdd�Zdd�Z
dd�Zdd�ZdS)�TestCasecs�g��fdd�}tjtjtj�}x8dddddgD]!}|j|d||f�}qFW|j�|j�dddddg�dS)	Ncs
�j|�S)N)�append)�x)�lr
r�<lambda>.sz%TestCase.test_enter.<locals>.<lambda>g�?g�������?g333333�?g�������?g�������?�)�sched�	schedulerr
r�enter�run�assertEqual)r	�funrr�zr
)rr�
test_enter,s
zTestCase.test_entercs�g��fdd�}tjtjtj�}x8dddddgD]!}|j|d||f�}qFW|j�|j�dddddg�dS)	Ncs
�j|�S)N)r)r)rr
rr7sz(TestCase.test_enterabs.<locals>.<lambda>g�������?g{�G�z�?g���Q��?g{�G�z�?g{�G�z�?r)rrr
r�enterabsrr)r	r rrr!r
)rr�
test_enterabs5s
zTestCase.test_enterabsz!Threading required for this test.cCs#tj�}|j}t�}tj|j|j�}|jdd|d	�|jdd|d
�t	j
d|j�}|j�|j
d�|j|jdt�d�|j|j��x6dddgD]%}|j|dd||f�}q�W|j
d�|j|jdt�d�|j|jdt�d�|j|j��|j
d�|j|jdt�d�|j|j��|j
d�|j|jdt�d�|j|j��|j
d�|jdt�|j|j��|j|j��|j|j�d�dS)Nr��target�timeout���i�)r)r%)�queue�Queue�putrrrr
rrr�Threadr�startrr�get�TIMEOUT�
assertTrue�empty�join�assertFalse�is_alive)r	�qr �timerrrrr!r
r
r�test_enter_concurrent>s8		

#



zTestCase.test_enter_concurrentcs�g��fdd�}tjtjtj�}x8dddddgD]!}|jd|||f�}qFW|j�|j�dddddg�dS)	Ncs
�j|�S)N)r)r)rr
rr_sz(TestCase.test_priority.<locals>.<lambda>rr*r%r(r)g{�G�z�?)rrr
rr#rr)r	r rZpriorityr!r
)rr�
test_priority]s
zTestCase.test_priorityc	s	g��fdd�}tjtjtj�}tj�}|j|dd|d	�}|j|dd|d
�}|j|dd|d�}|j|dd|d�}|j|dd|d
�}|j|�|j|�|j�|j�dddg�dS)Ncs
�j|�S)N)r)r)rr
rrhsz&TestCase.test_cancel.<locals>.<lambda>�{�G�z�?r�{�G�z�?���Q��?�{�G�z�?皙�����?)r;)r<)r=)r>)r?)rrr
rr#�cancelrr)	r	r r�now�event1�event2�event3�event4�event5r
)rr�test_cancelfs


zTestCase.test_cancelcCs8tj�}|j}t�}tj|j|j�}|j�}|j|dd|d	�}|j|dd|d
�}|j|dd|d�}|j|dd|d�}	|j|dd|d
�}
t	j
d|j�}|j�|j
d�|j|jdt�d�|j|j��|j|�|j|	�|j
d�|j|j��|j
d�|j|jdt�d�|j|j��|j
d�|j|jdt�d�|j|j��|j
d�|jdt�|j|j��|j|j��|j|j�d�dS)Nrr*r(r)r%r&r'i�)r)r*)r()r))r%)r+r,r-rrrr
rr#rr.rr/rrr0r1r2r3r@r4r5r6)r	r7r r8rrArBrCrErFrDrr
r
r�test_cancel_concurrentus<		







zTestCase.test_cancel_concurrentcs�g��fdd�}tjtjtj�}|j|j��x8dddddgD]!}|j|d||f�}qYW|j|j��|j�|j|j��dS)	Ncs
�j|�S)N)r)r)rr
rr�sz%TestCase.test_empty.<locals>.<lambda>g�������?g{�G�z�?g���Q��?g{�G�z�?g{�G�z�?r)	rrr
rr2r3r#r5r)r	r rrr!r
)rr�
test_empty�s
zTestCase.test_emptyc	s�g��fdd�}tjtjtj�}tj�}|j|dd|�}|j|dd|�}|j|dd|�}|j|dd|�}|j|dd|�}|j|j|||||g�dS)	Ncs
�j|�S)N)r)r)rr
rr�sz%TestCase.test_queue.<locals>.<lambda>g�������?rg{�G�z�?g{�G�z�?g{�G�z�?g���Q��?)rrr
rr#rr+)	r	r rrAZe5Ze1Ze2Ze4Ze3r
)rr�
test_queue�szTestCase.test_queuec
s|g���fdd�}tjtjtj�}|jdd|dd
didd	6�}|j��j�dg�dS)Ncs8�jd��j|d��j|idd6�dS)Nrr*r%�foo)rr*r%)rr)�a�b)�flagr	r
rr �s
z&TestCase.test_args_kwargs.<locals>.fung{�G�z�?rZargumentr*r%�kwargsrK)rr*r%)rrr
rr#rr)r	r rr!r
)rNr	r�test_args_kwargs�s(
zTestCase.test_args_kwargscs�g��fdd�}tjtjtj�}x6dddddgD]}|j|d||f�qFW|jd	d
�|j�g�dS)Ncs
�j|�S)N)r)r)rr
rr�sz0TestCase.test_run_non_blocking.<locals>.<lambda>r�	���rZblockingF)rrr
rrrr)r	r rrr
)rr�test_run_non_blocking�szTestCase.test_run_non_blockingN)rrrr"r$�unittestZ
skipUnlessrr9r:rGrHrIrJrPrUr
r
r
rr*s			!
r�__main__)
r+rr
rVZtestrr�ImportErrorr1rrr�mainr
r
r
r�<module>s
�