B
    u9a                 @   sJ   d dl mZ d dlZd dlZd dlZG dd dejZedkrFe	  dS )    )supportNc               @   s.   e Zd ZG dd dejZdd Zdd ZdS )DummyThreadingTestCasec               @   s   e Zd Zdd ZdS )z!DummyThreadingTestCase.TestThreadc             C   s   d}t jrtd| jd|d t  t  td7 at jrDttd t  t	
| t jrjtd| jd t  td8 at jrt| jdtd t  t  d S )	Nr   Ztaskzwill run forZsec   ztasks are runningZdonezis finished.)r   verboseprintnamesemaacquiremutexrunningreleasetimeZsleep)selfZdelay r   */usr/lib/python3.7/test_dummy_threading.pyrun
   s$    

z%DummyThreadingTestCase.TestThread.runN)__name__
__module____qualname__r   r   r   r   r   
TestThread   s   r   c             C   s(   d| _ tjddat adag | _d S )N
      )valuer   )numtasks
_threadingZBoundedSemaphorer   RLockr
   r   threads)r   r   r   r   setUp$   s
    zDummyThreadingTestCase.setUpc             C   sp   x6t | jD ](}| jd| d}| j| |  qW tjrFtd x| jD ]}|	  qNW tjrltd d S )Nz<thread %d>)r   z!waiting for all tasks to completezall tasks done)
ranger   r   r   appendstartr   r   r   join)r   itr   r   r   
test_tasks.   s    z!DummyThreadingTestCase.test_tasksN)r   r   r   r   ZThreadr   r   r$   r   r   r   r   r      s   
r   __main__)
Ztestr   ZunittestZdummy_threadingr   r   ZTestCaser   r   mainr   r   r   r   <module>   s   5