Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_dummy_thread.cpython-38.pyc
U

>��g�&�@s�ddlZddlZddlZddlZddlZddlmZddlmZdZ	Gdd�dej
�ZGdd�dej
�ZGdd	�d	ej
�Z
Gd
d�dej
�Zedkr�e��dS)
�N)�support)�mockc@szeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
e�d�dd��Zdd�ZdS)�	LockTestszTest lock objects.cCst��|_dS�N)�_thread�
allocate_lock�lock��self�r�5/opt/cppython/lib/python3.8/test/test_dummy_thread.py�setUpszLockTests.setUpcCs|�|j��d�dS)Nz(Lock object is not initialized unlocked.)�assertFalser�lockedr	rrr�
test_initlocks�zLockTests.test_initlockcCs*|j��|j��|�|j��d�dS)Nz%Lock object did not release properly.)r�acquire�releaserrr	rrr�test_releases


�zLockTests.test_releasec	Cs*t���W5QRX|�|j��d�dS)NzAcquired Lock was not released)r�LockTyperrrr	rrr�test_LockType_context_managers


�z'LockTests.test_LockType_context_managercCs|�t|jj�dSr)�assertRaises�RuntimeErrorrrr	rrr�test_improper_release%szLockTests.test_improper_releasecCs|�|j�d�d�dS)Nrz)Conditional acquiring of the lock failed.)�
assertTruerrr	rrr�test_cond_acquire_success)s�z#LockTests.test_cond_acquire_successcCs$|j�d�|�|j�d�d�dS)Nrz=Conditional acquiring of a locked lock incorrectly succeeded.)rrrr	rrr�test_cond_acquire_fail.s�z LockTests.test_cond_acquire_failcCs |j��|�|j��d�dS)NzUncondional locking failed.)rrrrr	rrr�test_uncond_acquire_success5s
�z%LockTests.test_uncond_acquire_successcCs,|�|j�d�dd�|�|j��d�dS)N�Tz*Unconditional locking did not return True.)ZassertIsrrr	rrr�test_uncond_acquire_return_val;s�z(LockTests.test_uncond_acquire_return_valcCs�dd�}|j��tt���}t�||jtf�tj	rHt
�t
dt�|j��tt���}tj	rlt
d�|�||td�dS)NcSst�|�|��dS)z:Hold on to lock for a set amount of time before unlocking.N)�time�sleepr)Z	to_unlock�delayrrr�delay_unlockCs
z<LockTests.test_uncond_acquire_blocking.<locals>.delay_unlockz@*** Waiting for thread to release the lock (approx. %s sec.) ***�donez+Blocking by unconditional acquiring failed.)rr�intr�	monotonicr�start_new_thread�DELAYr�verbose�printZassertGreaterEqual)r
r"Z
start_time�end_timerrr�test_uncond_acquire_blockingAs 
�
�z&LockTests.test_uncond_acquire_blockingz
time.sleepcCs@|j��|jjddd�}|�|j�|�d�|�|d�dS)z�Test invoking acquire() with a positive timeout when the lock is
        already acquired. Ensure that time.sleep() is invoked with the given
        timeout and that False is returned.rr)Zwaitflag�timeoutFN)rrr�calledZassert_called_once_with�assertEqual)r
Z
mock_sleep�retvalrrr�test_acquire_timeoutVs


zLockTests.test_acquire_timeoutcCs<|j��|�dt|j��|j��|�dt|j��dS)Nr�unlocked)rr�assertIn�reprrr	rrr�test_lock_representationbs

z"LockTests.test_lock_representationN)�__name__�
__module__�__qualname__�__doc__r
rrrrrrrrr+r�patchr0r4rrrrrs
rc@s eZdZdZdd�Zdd�ZdS)�
RLockTestszTest dummy RLock objects.cCst��|_dSr)r�RLock�rlockr	rrrr
lszRLockTests.setUpcCs�|�dt|j��|j��|j��|�dt|j��|j��|�dt|j��|j��|�dt|j��|�t|jj�dS)Nr1r)r2r3r<rrrrr	rrr�test_multiple_acquireos



z RLockTests.test_multiple_acquireN)r5r6r7r8r
r=rrrrr:isr:c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�	MiscTestszMiscellaneous tests.cCs|�ttj�dSr)r�
SystemExitr�exitr	rrr�	test_exit~szMiscTests.test_exitcCs&|�t��td�|�t��d�dS)Nz*_thread.get_ident() returned a non-integerr)�assertIsInstancer�	get_identr$Z
assertGreaterr	rrr�
test_ident�s�zMiscTests.test_identcCs|�t��tjd�dS)NzR_thread.LockType is not an instance of what is returned by _thread.allocate_lock())rBrrrr	rrr�
test_LockType�s�zMiscTests.test_LockTypecCs|�t��tjd�dS)Nz;_thread._set_sentinel() did not return a LockType instance.)rBr�
_set_sentinelrr	rrr�test_set_sentinel�s�zMiscTests.test_set_sentinelcCs dd�}|�ttj|t��dS)NcSst��dSr)r�interrupt_mainrrrr�call_interrupt�sz5MiscTests.test_interrupt_main.<locals>.call_interrupt)r�KeyboardInterruptrr&�tuple)r
rIrrr�test_interrupt_main�s�zMiscTests.test_interrupt_maincCs|�ttj�dSr)rrJrrHr	rrr�test_interrupt_in_main�sz MiscTests.test_interrupt_in_maincCst�d�}|�|d�dS)Nr)r�
stack_sizer.)r
r/rrr�test_stack_size_None�s
zMiscTests.test_stack_size_Nonec	Cs:|�tj��}t�d�W5QRX|�|jjdd�dS)N�rz'setting thread stack size not supported)rr�errorrNr.�	exception�args�r
�cmrrr�test_stack_size_not_None�s
�z"MiscTests.test_stack_size_not_NoneN)r5r6r7r8rArDrErGrLrMrOrVrrrrr>{sr>c@sJeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	�
d�d
d��ZdS)�ThreadTestszTest thread creation.cCs�ddd�}t�d�}t�||ddf�|��}|�|do@|dd�t�|t�|ddd��|��}|�|dox|dd	�t�||dfd
di�|��}|�|do�|dd�dS)
NFcSs|�||f�dS)z<Use to test _thread.start_new_thread() passes args properly.N)�put��queueZarg1�arg2rrr�
arg_tester�sz0ThreadTests.test_arg_passing.<locals>.arg_testerrTrz7Argument passing for thread creation using tuple failedrYz8Argument passing for thread creation using kwargs failedr[zGArgument passing for thread creation using both tuple and kwargs failed)FF)rZ�Queuerr&�getrrK)r
r\�
testing_queue�resultrrr�test_arg_passing�s2

�
����zThreadTests.test_arg_passingcCs�dd�}d}t�|�}tjr2t�tdt|f�t|�D],}trRtt��d�}nd}t	�
|||f�q:t�t�tjr�td�|�
|��|d|tf�dS)	NcSst�|�|�t���dSr)rr rXrrC)rZr!rrr�
queue_mark�s
z:ThreadTests.test_multi_thread_creation.<locals>.queue_mark�zJ*** Testing multiple thread creation (will take approx. %s to %s sec.) ***rrr#z2Not all %s threads executed properly after %s sec.)rZr]rr(r)r'�range�round�randomrr&rr r.�qsize)r
rbZthread_countr_�countZlocal_delayrrr�test_multi_thread_creation�s2
���
��z&ThreadTests.test_multi_thread_creationc	Cs>|�t��}t�t��g�W5QRX|�|jjdd�dS)z�
        Test invoking start_new_thread() with a non-tuple value for "args".
        Expect TypeError with a meaningful error message to be raised.
        rz2nd arg must be a tupleN)	r�	TypeErrorrr&r�Mockr.rRrSrTrrr�test_args_not_tuple�szThreadTests.test_args_not_tuplec	CsD|�t��}tjt��t�gd�W5QRX|�|jj	dd�dS)z�
        Test invoking start_new_thread() with a non-dict value for "kwargs".
        Expect TypeError with a meaningful error message to be raised.
        )�kwargsrz3rd arg must be a dictN)
rrjrr&rrkrKr.rRrSrTrrr�test_kwargs_not_dict�s z ThreadTests.test_kwargs_not_dictcCsDtjt�d�}zt�|t��Wntk
r>|�d�YnXdS)z�
        Test invoking start_new_thread() with a function that raises
        SystemExit.
        The exception should be discarded.
        �Zside_effectz#start_new_thread raised SystemExit.N)rrkr?rr&rKZfail)r
�funcrrr�test_SystemExit�s
zThreadTests.test_SystemExitztraceback.print_exccCs*tjtd�}t�|t��|�|j�dS)z�
        Test invoking start_new_thread() with a function that raises exception.

        The exception should be discarded and the traceback should be printed
        via traceback.print_exc()
        roN)rrk�	Exceptionrr&rKrr-)r
Zmock_print_excrprrr�test_RaiseExceptionszThreadTests.test_RaiseExceptionN)r5r6r7r8rarirlrnrqrr9rsrrrrrW�s!		rW�__main__)�
_dummy_threadrrrZrfZunittest�testrrr'ZTestCaserr:r>rWr5�mainrrrr�<module>s].j

F1le Man4ger