��Qc@s�dZddlZddlZddlZddlmZddlZddlmZmZm Z m
Z
mZdZdej
fd��YZd�Zed kr�ejd
d�ndS(s%TestCases for exercising a Recno DB.
i�N(tpprint(tdbttest_supporttverbosetget_new_environment_pathtget_new_database_patht4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZtSimpleRecnoTestCasecBs�eZejdks3ejd
krNejdkrNdd�Zdd�Znd�Zd�Zd�Z d �Z
d
�Zd�ZRS(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.pytsetUpscCs0tj|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�trK|GqKqKWtr�Hn|j
�}tr�t|�nxbtdt|�d�D]G}||}tr�GHn|j |t�|j||j|��q�Wy|d}Wngtjk
r�}tjdkro|j|dtj�n|j|jdtj�tr�|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�}trz|GHn|j |t �|j |dt
�|jt|�t|��|j!�} tr�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&dd
d�}|j|d
dd|�tr�GHn|j'�}
tr|
GHn|j(�}|j)�}x$|rPtrA|GHn|j*�}q-W|j+d�|j,�}trx|GHn|j-ddtj.�|j+d�|j,�}|j|d�tr�|GHn|j/d�}tr�GHn|j/d�}|j|d�tr|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�tr?|GHq?nX|s?|jd�n|j+d�}x$|rttre|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 tgettDBInvalidArgErrortsystversion_infotEINVALtargstfailthas_keytDBErrortKeyErrortDBNotFoundErrorRtkeystlisttitemsttupleRtassertFalsetdeletetget_bothtfdtcursortfirsttnexttsettcurrenttputt
DB_CURRENTt set_rangetclosetDBKeyEmptyErrortDB_KEYEMPTY(
Rtdtget_returns_nonetxtrecnoR#tdatatvalR2R4R9tctrec((s+/sys/lib/python2.7/bsddb/test/test_recno.pyttest01_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��dS(
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(RRtostpathtjointisdirtmkdirRRBRRtset_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}tjdkr�|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(�
|