Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/sqlite3/test/hooks.pyc

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


��Qc@s�ddlZddlZddlZdejfd��YZdejfd��YZd�Zd�Ze	dkr~e�ndS(	i�NtCollationTestscBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCsdS(N((tself((s(/sys/lib/python2.7/sqlite3/test/hooks.pytsetUpscCsdS(N((R((s(/sys/lib/python2.7/sqlite3/test/hooks.pyttearDownscCsatjd�}y!|jdd�|jd�Wn*tk
r\}|j|jdd�nXdS(Ns:memory:tXi*sshould have raised a TypeErrorisparameter must be callable(tsqlitetconnecttcreate_collationtfailt	TypeErrortassertEqualtargs(Rtconte((s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckCreateCollationNotCallable"scCsMtjd�}y!|jdt�|jd�Wntjk
rH}nXdS(Ns:memory:scoll�should have raised a ProgrammingError(RRRtcmpRtProgrammingError(RRR
((s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckCreateCollationNotAscii*scCstjdkrdSd�}tjd�}|jd|�d}|j|�j�}|ddd	ks�|ddd
ks�|dddkr�|jd�n|jdd�y&|j|�j�}|jd
�Wn3tjk
r
}|j	|j
dj�d�nXdS(NiiicSst||�S(N(R(txty((s(/sys/lib/python2.7/sqlite3/test/hooks.pytmycoll5ss:memory:Rs�
            select x from (
            select 'a' as x
            union
            select 'b' as x
            union
            select 'c' as x
            ) order by x collate mycoll
            itctbtas#the expected order was not returneds&should have raised an OperationalErrors"no such collation sequence: mycoll(iii(Rtversion_infoRRtexecutetfetchallRtNonetOperationalErrorR
Rtlower(RRRtsqltresultR
((s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckCollationIsUsed2s		<cCsfd�}tjd�}|jd|�d}|j|�j�}|j|d
ddgdd	�dS(
NcSs||k||kdS(Nii l((RR((s(/sys/lib/python2.7/sqlite3/test/hooks.pyRPss:memory:Rs�
            select x from (
            select 'a' as x
            union
            select 'b' as x
            union
            select 'c' as x
            ) order by x collate mycoll
            RRRtmsgs#the expected order was not returned(R(R(R(RRRRRR
(RRRRR((s(/sys/lib/python2.7/sqlite3/test/hooks.pyt!CheckCollationReturnsLargeIntegerOs		cCs�tjd�}|jdt�|jdd��|jd�j�}|dddkso|dddkr|jd	�nd
S(s�
        Register two different collation functions under the same name.
        Verify that the last one is actually used.
        s:memory:RcSst||�S(N(R(RR((s(/sys/lib/python2.7/sqlite3/test/hooks.pyt<lambda>issi
            select x from (select 'a' as x union select 'b' as x) order by x collate mycoll
            iRiRs wrong collation function is usedN(RRRRRRR(RRR((s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckCollationRegisterTwicebs(cCs�tjd�}|jdt�|jdd�y|jd�|jd�Wn<tjk
r�}|jdj	d�s�|jd�q�nXdS(	su
        Register a collation, then deregister it. Make sure an error is raised if we try
        to use it.
        s:memory:Rs?select 'a' as x union select 'b' as x order by x collate mycolls&should have raised an OperationalErrorisno such collation sequenceswrong OperationalError raisedN(
RRRRRRRRRt
startswith(RRR
((s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckDeregisterCollationps
(
t__name__t
__module__RRRRR R"R$R&(((s(/sys/lib/python2.7/sqlite3/test/hooks.pyRs							t
ProgressTestscBs,eZd�Zd�Zd�Zd�ZRS(csRtjd�}g��fd�}|j|d�|jd�|j��dS(sK
        Test that the progress handler is invoked once it is set.
        s:memory:cs�jd�dS(Ni(tappendR((tprogress_calls(s(/sys/lib/python2.7/sqlite3/test/hooks.pytprogress�s
is0
            create table foo(a, b)
            N(RRtset_progress_handlerRt
assertTrue(RRR,((R+s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckProgressHandlerUsed�scs�tjd�}g��fd�}|j|d�|j�}|jd�t��}g�|j|d�|jd�t��}|j||k�dS(s=
        Test that the opcode argument is respected.
        s:memory:cs�jd�dS(Ni(R*R((R+(s(/sys/lib/python2.7/sqlite3/test/hooks.pyR,�s
is1
            create table foo (a, b)
            is1
            create table bar (a, b)
            N(RRR-tcursorRtlenR.(RRR,tcurstfirst_counttsecond_count((R+s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckOpcodeCount�scs]tjd�}g��fd�}|j|d�|j�}|jtj|jd�dS(sW
        Test that returning a non-zero value stops the operation in progress.
        s:memory:cs�jd�dS(Ni(R*R((R+(s(/sys/lib/python2.7/sqlite3/test/hooks.pyR,�s
iscreate table bar (a, b)N(RRR-R0tassertRaisesRR(RRR,R2((R+s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckCancelOperation�scsttjd�}g��fd�}|j|d�|jdd�|jd�j�|jt��dd�dS(sc
        Test that setting the progress handler to None clears the previously set handler.
        s:memory:cs�jd�dS(Nii(R*((taction(s(/sys/lib/python2.7/sqlite3/test/hooks.pyR,�s
is&select 1 union select 2 union select 3is progress handler was not clearedN(RRR-RRRR
R1(RRR,((R8s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckClearHandler�s(R'R(R/R5R7R9(((s(/sys/lib/python2.7/sqlite3/test/hooks.pyR)s			cCs7tjtd�}tjtd�}tj||f�S(NtCheck(tunittestt	makeSuiteRR)t	TestSuite(tcollation_suitetprogress_suite((s(/sys/lib/python2.7/sqlite3/test/hooks.pytsuite�scCs tj�}|jt��dS(N(R;tTextTestRunnertrunR@(trunner((s(/sys/lib/python2.7/sqlite3/test/hooks.pyttest�st__main__(
tosR;tsqlite3RtTestCaseRR)R@RDR'(((s(/sys/lib/python2.7/sqlite3/test/hooks.pyt<module>sdF		

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.