Your IP : 216.73.216.85


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_sched.cpython-35.opt-2.pyc



���]��@s�ddlZddlZddlZddlZddlmZyddlZWnek
rjdZYnXdZGdd�d�Z	Gdd�dej
�Z
edkr�ej�dS)	�N)�support�
c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TimercCs%tj�|_d|_d|_dS)Nr)�	threading�	Condition�_cond�_time�_stop)�self�r�//opt/alt/python35/lib64/python3.5/test_sched.py�__init__s	zTimer.__init__c	Cs|j�|jSWdQRXdS)N)rr)r
rrr�times
z
Timer.timec	CsZ|j�J||j7}x,|j|krE|j|_|jj�qW||_WdQRXdS)N)rrr	�wait)r
�trrr�sleeps

zTimer.sleepc
Cs1|j�!|j|7_|jj�WdQRXdS)N)rr	�
notify_all)r
rrrr�advance#s
z
Timer.advanceN)�__name__�
__module__�__qualname__r
rrrrrrrrs
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)�lrr�<lambda>.sz%TestCase.test_enter.<locals>.<lambda>g�?g�������?g333333�?g�������?g�������?�)�sched�	schedulerrr�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)rrrr7sz(TestCase.test_enterabs.<locals>.<lambda>g�������?g{�G�z�?g���Q��?g{�G�z�?g{�G�z�?r)rrrr�enterabsr r!)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�putrrrrrrr�Threadr �startrr!�get�TIMEOUT�
assertTrue�empty�join�assertFalse�is_alive)r
�qr"�timerrrrr#rrr�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)rrrr_sz(TestCase.test_priority.<locals>.<lambda>rr,r'r*r+g{�G�z�?)rrrrr%r r!)r
r"r�priorityr#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)rrrrhsz&TestCase.test_cancel.<locals>.<lambda>�{�G�z�?r�{�G�z�?���Q��?�{�G�z�?皙�����?)r>)r?)r@)rA)rB)rrrrr%�cancelr r!)	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/rrrrrr%rr0r r1rr!r2r3r4r5rCr6r7r8)r
r9r"r:rrDrErFrHrIrGrrrr�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)rrrr�sz%TestCase.test_empty.<locals>.<lambda>g�������?g{�G�z�?g���Q��?g{�G�z�?g{�G�z�?r)	rrrrr4r5r%r7r )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)rrrr�sz%TestCase.test_queue.<locals>.<lambda>g�������?rg{�G�z�?g{�G�z�?g{�G�z�?g���Q��?)rrrrr%r!r-)	r
r"rrDZe5Ze1Ze2Ze4Ze3r)rr�
test_queue�szTestCase.test_queuec	s{g���fdd�}tjtjtj�}|jdd|dd
dd	di�}|j��j�dg�dS)Ncs7�jd��j|d��j|ddi�dS)Nrr,r'�foo)rr,r')rr!)�a�b)�flagr
rrr"�s
z&TestCase.test_args_kwargs.<locals>.fung{�G�z�?r�argumentr,r'�kwargsrN)rr,r')rrrrr%r r!)r
r"rr#r)rQr
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)rrrr�sz0TestCase.test_run_non_blocking.<locals>.<lambda>r�	���r�blockingF)rrrrrr r!)r
r"rrr)rr�test_run_non_blocking�szTestCase.test_run_non_blockingN)rrrr$r&�unittestZ
skipUnlessrr;r=rJrKrLrMrTrZrrrrr*s			!
r�__main__)
r-rrr[Ztestrr�ImportErrorr3rrr�mainrrrr�<module>s
�