| Server IP : 118.27.122.248 / Your IP : 216.73.216.15 Web Server : Apache System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64 User : c9415830 ( 11735) PHP Version : 8.4.17 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/alt/python36/lib64/python3.6/test/__pycache__/ |
Upload File : |
3
�w2_�$ � @ s~ d dl Zd dlZd dlZd dlZd dlZd dlmZ d dlmZ d Z G dd� dej
�ZG dd� dej
�ZG dd � d ej
�Z
dS )
� N)�support)�mockc @ sz e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� Zdd� Z
ejd�dd� �Zdd� ZdS )� LockTestszTest lock objects.c C s t j� | _d S )N)�_thread�
allocate_lock�lock)�self� r �;/opt/alt/python36/lib64/python3.6/test/test_dummy_thread.py�setUp s zLockTests.setUpc C s | j | jj� d� d S )Nz(Lock object is not initialized unlocked.)�assertFalser �locked)r r r r
�
test_initlock s zLockTests.test_initlockc C s* | j j� | j j� | j| j j� d� d S )Nz%Lock object did not release properly.)r �acquire�releaser r
)r r r r
�test_release s
zLockTests.test_releasec
C s* t j� � W d Q R X | j| jj� d� d S )NzAcquired Lock was not released)r �LockTyper r r
)r r r r
�test_LockType_context_manager s
z'LockTests.test_LockType_context_managerc C s | j t| jj� d S )N)�assertRaises�RuntimeErrorr r )r r r r
�test_improper_release% s zLockTests.test_improper_releasec C s | j | jjd�d� d S )Nr z)Conditional acquiring of the lock failed.)�
assertTruer r )r r r r
�test_cond_acquire_success) s z#LockTests.test_cond_acquire_successc C s$ | j jd� | j| j jd�d� d S )Nr z=Conditional acquiring of a locked lock incorrectly succeeded.)r r r )r r r r
�test_cond_acquire_fail. s z LockTests.test_cond_acquire_failc C s | j j� | j| j j� d� d S )NzUncondional locking failed.)r r r r
)r r r r
�test_uncond_acquire_success5 s
z%LockTests.test_uncond_acquire_successc C s, | j | jjd�dd� | j | jj� d� d S )N� Tz*Unconditional locking did not return True.)ZassertIsr r )r r r r
�test_uncond_acquire_return_val; s z(LockTests.test_uncond_acquire_return_valc C s� dd� }| j j� ttj� �}tj|| j tf� tjrHt � t dt � | j j� ttj� �}tjrlt d� | j
|| td� d S )Nc S s t j|� | j� dS )z:Hold on to lock for a set amount of time before unlocking.N)�time�sleepr )Z to_unlock�delayr r r
�delay_unlockC s
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.)r r �intr r �start_new_thread�DELAYr �verbose�printZassertGreaterEqual)r r Z
start_timeZend_timer r r
�test_uncond_acquire_blockingA s
z&LockTests.test_uncond_acquire_blockingz
time.sleepc C s@ | j j� | j jddd�}| j|j� |jd� | j|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.r r )ZwaitflagZtimeoutFN)r r r �calledZassert_called_once_with�assertEqual)r Z
mock_sleep�retvalr r r
�test_acquire_timeoutV s
zLockTests.test_acquire_timeoutc C s<