Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/bsddb/test/test_recno.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Qc@s�dZddlZddlZddlZddlmZddlZddlmZmZm	Z	m
Z
mZdZdej
fd��YZd�Zed	kr�ejd
d�ndS(s%TestCases for exercising a Recno DB.
i�N(tpprint(tdbttest_supporttverbosetget_new_environment_pathtget_new_database_patht4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZtSimpleRecnoTestCasecBs�eZejdks3ejd
krNejdkrNdd�Zdd�Znd�Zd�Zd�Z	d	�Z
d
�Zd�ZRS(iiiicCs|jt|�|d|�S(Ntmsg(tassertEqualttype(tselftobjtdatatypeR((s+/sys/lib/python2.7/bsddb/test/test_recno.pytassertIsInstancescCs|j||kd|�S(NR(t
assertTrue(RtatbR((s+/sys/lib/python2.7/bsddb/test/test_recno.pytassertGreaterEqualscCst�|_d|_dS(N(RtfilenametNonethomeDir(R((s+/sys/lib/python2.7/bsddb/test/test_recno.pytsetUpscCs0tj|j�|jr,tj|j�ndS(N(RtunlinkRRtrmtree(R((s+/sys/lib/python2.7/bsddb/test/test_recno.pyttearDowns	c
Cs�tj�}|jd�}|j|�|j|jtjtj�xNtD]F}|j|d�}|j	|t
�|j|d�trK|GqKqKWtr�Hn|j
�}tr�t|�nxbtdt|�d�D]G}||}tr�GHn|j	|t�|j||j|��q�Wy|d}Wngtjk
r�}tjdkro|j|dtj�n|j|jdtj�tr�|GHq�nX|jd�y|jd�Wntjk
r�}nX|jd�y|d}Wntk
rnX|jd�y|jd�}Wn,tjk
rO}|r`|jd	�q`nX|j|d�|j�}trz|GHn|j	|t �|j	|dt
�|jt|�t|��|j!�}	tr�t|	�n|j	|	t �|j	|	dt"�|jt|	d�d�|j	|	ddt
�|j	|	ddt�|jt|	�t|��|j#|jd
��|d
=|j$|jd
��|j%d�|j$|jd��|j&dd
d�}|j|d
dd|�tr�GHn|j'�}
tr|
GHn|j(�}|j)�}x$|rPtrA|GHn|j*�}q-W|j+d�|j,�}trx|GHn|j-ddtj.�|j+d�|j,�}|j|d�tr�|GHn|j/d�}tr�GHn|j/d�}|j|d�tr|GHn|j0�|j0�tj�}|j|j�|j(�}d|d<|j|dd�y|d}Wntk
r�nX|jd�y|jd�Wn}tj1k
r(}|r�|jd�q?tjdkr�j|dtj2�n|j|jdtj2�tr?|GHq?nX|s?|jd�n|j+d�}x$|rttre|GHn|j*�}qQW|j0�|j0�dS(Nii<iiisexpected exceptions(has_key did not raise a proper exceptionidsunexpected exceptionii
itzswas %ri2i�sa replacement recordii?Bs
way out thereics$unexpected DBKeyEmptyError exceptioni((ii(i2sa replacement record(ii(3RtDBtset_get_returns_nonetopenRtDB_RECNOt	DB_CREATEtletterstappendRtintRRtstatRtrangetlentstrR	tgettDBInvalidArgErrortsystversion_infotEINVALtargstfailthas_keytDBErrortKeyErrortDBNotFoundErrorRtkeystlisttitemsttupleRtassertFalsetdeletetget_bothtfdtcursortfirsttnexttsettcurrenttputt
DB_CURRENTt	set_rangetclosetDBKeyEmptyErrortDB_KEYEMPTY(
Rtdtget_returns_nonetxtrecnoR#tdatatvalR2R4R9tctrec((s+/sys/lib/python2.7/bsddb/test/test_recno.pyttest01_basic"s�


 






	






	
cCs!t�}||_tjj|d�}tjj|�sItj|�nt|d�}|j�t	j
�}|jd�|jd�|j|�|j|j
t	jt	j�dj�}x|D]}|j|�q�W|j�|j�t|d�}|j�}|j�|j�}trA|GH|GH|jd�GHn|j|jd�|�t	j
�}|j|�|j|j
t	j�d|d<d	|d
<|j�|j�t|d�}|j�}|j�|j�}tr�GH|jd�GHn|j|jd�dj��dS(
s
        A Recno file that is given a "backing source file" is essentially a
        simple ASCII file.  Normally each record is delimited by 
 and so is
        just a line in the file, but you can set a different record delimiter
        if needed.
        stest_recno.txttwi
s
s,The quick brown fox jumped over the lazy dogtrs
reddish-brownitcomatoseis8The quick reddish-brown fox jumped over the comatose dogN(RRtostpathtjointisdirtmkdirRRBRRtset_re_delimt
set_re_sourceRRRtsplitR!tsynctreadtstripRR	(RRtsourcetfRERItdatumttext((s+/sys/lib/python2.7/bsddb/test/test_recno.pyttest02_WithSource�sT		













cCsetj�}|jd�|jd�|jd�|j|jtjtj�xtD]}|j	|d�qVW|j	dd�y|j	dd�Wngtj
k
r}tjdkr�|j
|d
tj�n|j
|jd
tj�tr|GHqnX|jd�|j�}|j�}x$|rLtr=|GHn|j�}q)W|j�|j�dS(
Ni(t-i-i#t.tbadiiiisexpected exception(ii(RRt
set_re_lent
set_re_padRRRRR R!R(R)R*R	R+R,RR-R:R;R<RB(RRERGRJRKRL((s+/sys/lib/python2.7/bsddb/test/test_recno.pyttest03_FixedLength
s2




	
cCs�tj�}|j|jdtjdtj�|jd�}|jd|jd|��|jd�}|jd|jd|��dS(Ntdbtypetflagst itkeyti(	RRRRRRR!R	tget_size(RREtrow_id((s+/sys/lib/python2.7/bsddb/test/test_recno.pyttest04_get_size_empty+s"(ii(ii(iiN(
t__name__t
__module__R)R*RRRRRRMR`RfRn(((s+/sys/lib/python2.7/bsddb/test/test_recno.pyRs			�>	!cCs
tjt�S(N(tunittestt	makeSuiteR(((s+/sys/lib/python2.7/bsddb/test/test_recno.pyt
test_suite;st__main__tdefaultTestRs(t__doc__RQR)terrnoRRqttest_allRRRRRR tTestCaseRRsRotmain(((s+/sys/lib/python2.7/bsddb/test/test_recno.pyt<module>s(�

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].