Current File : //opt/imh-python/lib/python2.7/test/test_dummy_thread.pyc
�
��Wc@s�dZddladdlZddlZddlZddlZddlmZda	dej
fd��YZdej
fd��YZd	ej
fd
��YZ
dd�Zedkr�e�ndS(
s�Generic thread tests.

Meant to be used by dummy_thread and thread.  To allow for different modules
to be used, test_main() can be called with the module to use as the thread
implementation as its sole argument.

i����N(ttest_supportit	LockTestscBs_eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
sTest lock objects.cCstj�|_dS(N(t_threadt
allocate_locktlock(tself((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pytsetUpscCs|j|jj�d�dS(Ns(Lock object is not initialized unlocked.(tassertFalseRtlocked(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyt
test_initlockscCs7|jj�|jj�|j|jj�d�dS(Ns%Lock object did not release properly.(RtacquiretreleaseRR(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_releases

cCs|jtj|jj�dS(N(tassertRaisesRterrorRR(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_improper_release%scCs |j|jjd�d�dS(Nis)Conditional acquiring of the lock failed.(t
assertTrueRR
(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_cond_acquire_success)scCs0|jjd�|j|jjd�d�dS(Nis=Conditional acquiring of a locked lock incorrectly succeeded.(RR
R(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_cond_acquire_fail.scCs*|jj�|j|jj�d�dS(NsUncondional locking failed.(RR
RR(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_uncond_acquire_success5s
cCs<|j|jjd�td�|j|jj�t�dS(Nis*Unconditional locking did not return True.(tassertIsRR
tTrue(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_uncond_acquire_return_val;scCs�d�}|jj�ttj��}tj||jtf�tjrWHdtGHn|jj�ttj��}tjr�dGHn|j	||td�dS(NcSstj|�|j�dS(s:Hold on to lock for a set amount of time before unlocking.N(ttimetsleepR(t	to_unlocktdelay((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pytdelay_unlockCs
s@*** Waiting for thread to release the lock (approx. %s sec.) ***tdones+Blocking by unconditional acquiring failed.(
RR
tintRRtstart_new_threadtDELAYRtverbosetassertGreaterEqual(RRt
start_timetend_time((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_uncond_acquire_blockingAs	
		
	(t__name__t
__module__t__doc__RR	RRRRRRR$(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyRs								t	MiscTestscBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(sMiscellaneous tests.cCs|jttj�dS(N(R
t
SystemExitRtexit(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyt	test_exitYscCs6|jtj�td�|jtj�dd�dS(Ns*_thread.get_ident() returned a non-integeris_thread.get_ident() returned 0(tassertIsInstanceRt	get_identRtassertNotEqual(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyt
test_ident]scCs |jtj�tjd�dS(NsR_thread.LockType is not an instance of what is returned by _thread.allocate_lock()(R,RRtLockType(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyt
test_LockTypedscCs)d�}|jttj|t��dS(NcSstj�dS(N(Rtinterrupt_main(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pytcall_interruptms(R
tKeyboardInterruptRRttuple(RR3((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_interrupt_mainjs	cCs|jttj�dS(N(R
R4RR2(R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_interrupt_in_mainrs(R%R&R'R+R/R1R6R7(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyR(Vs				tThreadTestscBs eZdZd�Zd�ZRS(sTest thread creation.cCsttd�}tjd�}tj||ttf�|j�}|j|doZ|dd�tj|t�i|d6td6td6�|j�}|j|do�|dd�tj||tfitd6�|j�}|j|do�|dd	�dS(
NcSs|j||f�dS(s<Use to test _thread.start_new_thread() passes args properly.N(tput(tqueuetarg1targ2((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyt
arg_tester|siis7Argument passing for thread creation using tuple failedR:R;R<s8Argument passing for thread creation using kwargs failedsGArgument passing for thread creation using both tuple and kwargs failed(tFalsetQueueRRRtgetRR5(RR=t
testing_queuetresult((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_arg_passingzs cCs�d�}d}tj|�}tjr:Hdt|fGHnxNt|�D]@}trkttj�d�}nd}tj|||f�qGWt	j
t�tjr�dGHn|j|j�|d|tf�dS(NcSs$tj|�|jtj��dS(s@Wait for ``delay`` seconds and then put something into ``queue``N(RRR9RR-(R:R((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyt
queue_mark�s
isJ*** Testing multiple thread creation (will take approx. %s to %s sec.) ***iiRs2Not all %s threads executed properly after %s sec.(
R?RR RtxrangetroundtrandomRRRRtassertEqualtqsize(RRDtthread_countRAtcounttlocal_delay((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyttest_multi_creation�s&			
	(R%R&R'RCRM(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyR8ws	cCsB|r|adantjr+HdtGHntjttt�dS(Nis"*** Using %s as _thread module ***(RRRR trun_unittestRR(R8(timported_module((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyt	test_main�s		t__main__(R'tdummy_threadRRR?RGtunittestttestRRtTestCaseRR(R8tNoneRPR%(((so/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_dummy_thread.pyt<module>sD!4