Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_dbm_gnu.cpython-310.opt-2.pyc

o

0�i�@sxddlmZddlmZmZe�d�ZddlZddlZddl	m
Z
mZmZe
Z
Gdd�dej�Zedkr:e��dSdS)	�)�support)�
import_helper�cpython_onlyzdbm.gnuN)�TESTFN�TESTFN_NONASCII�unlinkc@s�eZdZedd��Zdd�Zdd�Zedd��Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Ze�ed�dd��Zdd�ZdS)�TestGdbmcCsBtjrzddlm}Wn
tyYdSwtd|���dSdS)Nr)�
_GDBM_VERSIONzgdbm version: )r�verboseZ_gdbmr	�ImportError�print)�version�r�8/opt/alt/python310/lib64/python3.10/test/test_dbm_gnu.py�
setUpClasss��zTestGdbm.setUpClasscCs
d|_dS�N��g��selfrrr�setUps
zTestGdbm.setUpcCs |jdur
|j��tt�dSr)r�closer�filenamerrrr�tearDowns

zTestGdbm.tearDowncCs$t�td�|_t�|t|j��dS)N�c)�gdbm�openrrrZcheck_disallow_instantiation�typerrrr�test_disallow_instantiationsz$TestGdbm.test_disallow_instantiationcCs^t�td�|_|�|j��g�d|jd<d|jd<d|jd<t|j���}|�|tgd���|�d|j�|�d	|j�|�|jdd�|j��}|ra|�||�|�	|�|j�
|�}|sN|�|j�d	�d
�|�|j�d��|�|j�dd�d�|�
t��
|jd
Wd�n1s�wY|�|j�dd�d�|�|jdd�dS)Nr�b�aZ019237410982340912840198242Z12345678910sdata�bytes)�ar!s12345678910r"�bsxxxsfooZxxx)rrrr�assertEqual�keys�set�assertInZfirstkey�removeZnextkey�getZassertIsNone�assertRaises�KeyError�
setdefault)rZkey_set�keyrrr�test_key_methods$s0




��zTestGdbm.test_key_methodscs`tt���tjtjtd�t�td��_�j����tj�fdd����tjdd��dS)N�rrcs
�jdS)Nr rrrrr�<lambda>Ds
z0TestGdbm.test_error_conditions.<locals>.<lambda>cSst�td���S)NZrx)rrrrrrrrr0Fs)rrr*r�errorrrrrrrr�test_error_conditions=s
zTestGdbm.test_error_conditionscCs|ttj�}|td�}t|�D]}t�t|�|_|j��q|td�}|D]}|D]}t�t||�|_|j��q*q&dS)NZfsuZcrwn)r&rZ
open_flags�sortedrrrr)r�allZmodes�mode�flags�flagrrr�
test_flagsHs
��zTestGdbm.test_flagscCs�t�td�|_tj�t�}t|d�}d||jd<tj�t�}|�||�|jd=|�	tj�t�|�|j�
�tj�t�}|�||�|�||�dS)Nri'�x)
rrrr�os�path�getsize�maxZ
assertGreaterr$Z
reorganizeZ
assertLessZassertGreaterEqual)rZsize0Z
value_sizeZsize1Zsize2rrr�test_reorganizeXs

zTestGdbm.test_reorganizecCs�t�td��}d|d<Wd�n1swYt�td��}|�t|���dg�Wd�n1s6wY|�tj��}|��Wd�n1sPwY|�t|j	�d�dS)Nrzcontext managerzgdbm context managerr/sgdbm context managerz#GDBM object has already been closed)
rrrr$�listr%r*r1�str�	exception)r�db�cmrrr�test_context_managerms
��
��zTestGdbm.test_context_managercCs�t�td��}d|d<Wd�n1swYt�td��#}|�t|���dg�|�d|v�|�|dd�Wd�dS1sFwYdS)Nrs
bytes value �sbytes key �r/)rrrr$r?r%�
assertTrue�rrBrrr�
test_bytesys
�"�zTestGdbm.test_bytescCs�t�td��}d|d<Wd�n1swYt�td��<}|�t|���d��g�|�d��|v�|�d|v�|�|d��d���|�|dd���Wd�dS1s_wYdS)NruUnicode value 🐍uUnicode key 🐍r/)rrrr$r?r%�encoderErFrrr�test_unicode�s
��
�"�zTestGdbm.test_unicodec	Cst�td��}d|d<Wd�n1swYt�td��]}|�tj��|d=Wd�n1s5wY|�tj��|d=Wd�n1sNwY|�tj��d|d<Wd�n1shwYWd�dSWd�dS1s�wYdS)Nrsbytes values	bytes keyr/s
not exist keysnot exist value)rrrr*r1rFrrr�test_write_readonly_file�s 
���
��"�z!TestGdbm.test_write_readonly_filez*requires OS support of non-ASCII encodingscCs�t}|�t|�t�|d��}d|d<Wd�n1swY|�tj�|��t�|d��#}|�	t
|���dg�|�d|v�|�	|dd�Wd�dS1sWwYdS)Nrsvalueskeyr/)rZ
addCleanuprrrrEr:r;�existsr$r?r%)rrrBrrr�test_nonascii_filename�s
�"�zTestGdbm.test_nonascii_filenamecCs`d}|�tj��
}t�|�Wd�n1swY|�|t|j��|�|jj|�dS)Nznonexisting-file)	r*rr1rr'r@rAr$r)rZnonexisting_filerCrrr�test_nonexisting_file�s�zTestGdbm.test_nonexisting_fileN)�__name__�
__module__�__qualname__�staticmethodrrrrrr.r2r8r>rDrGrIrJ�unittestZ
skipUnlessrrLrMrrrrrs(
	
�
r�__main__)�testrZtest.supportrr�
import_modulerrRr:Ztest.support.os_helperrrrrZTestCaserrN�mainrrrr�<module>s
#�