ó o®¸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 TypeErrort assertEqualtargs(Rtconte((s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckCreateCollationNotCallable"s cCsMtjdƒ}y!|jdtƒ|jdƒWntjk rH}nXdS(Ns:memory:scolläs%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’|ddd kr¢|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 R tlower(RRR tsqltresultR ((s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckCollationIsUsed2s  <cCsfd„}tjdƒ}|jd|ƒd}|j|ƒjƒ}|j|d d d gdd ƒdS( NcSs||k||k dS(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.pytissi 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(cCstjdƒ}|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( RRRRRRRRR t 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,tcurst first_countt second_count((R+s(/sys/lib/python2.7/sqlite3/test/hooks.pytCheckOpcodeCounts   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.pyts dF