a ZÚß^&Šc@sìddlZddlZddlZddlmZmZGdd„dejƒZGdd„dejƒZ Gdd„dejƒZ Gd d „d ejƒZ Gd d „d ejƒZ Gd d„dejƒZ Gdd„dejƒZGdd„dejƒZGdd„dejƒZdd„Zdd„ZedkrèeƒdS)éN)ÚTESTFNÚunlinkc@steZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„ZdS)Ú ModuleTestscCó| tjddtj¡dS)Nz2.0zapilevel is %s, should be 2.0)Ú assertEqualÚsqliteZapilevel©Úself©r ú*/usr/lib64/python3.9/sqlite3/test/dbapi.pyÚ CheckAPILevel ó ÿzModuleTests.CheckAPILevelcCr)Nézthreadsafety is %d, should be 1)rrZ threadsafetyrr r r ÚCheckThreadSafety$r zModuleTests.CheckThreadSafetycCr)NZqmarkz%paramstyle is '%s', should be 'qmark')rrZ paramstylerr r r ÚCheckParamStyle(s  ÿÿzModuleTests.CheckParamStylecCó| ttjtƒd¡dS)Nz&Warning is not a subclass of Exception)Ú assertTrueÚ issubclassrÚWarningÚ Exceptionrr r r Ú CheckWarning-óÿzModuleTests.CheckWarningcCr)Nz$Error is not a subclass of Exception)rrrÚErrorrrr r r Ú CheckError1rzModuleTests.CheckErrorcCó| ttjtjƒd¡dS)Nz)InterfaceError is not a subclass of Error)rrrÚInterfaceErrorrrr r r ÚCheckInterfaceError5óÿzModuleTests.CheckInterfaceErrorcCr)Nz(DatabaseError is not a subclass of Error)rrrÚ DatabaseErrorrrr r r ÚCheckDatabaseError9rzModuleTests.CheckDatabaseErrorcCr)Nz,DataError is not a subclass of DatabaseError)rrrÚ DataErrorrrr r r ÚCheckDataError=rzModuleTests.CheckDataErrorcCr)Nz3OperationalError is not a subclass of DatabaseError)rrrÚOperationalErrorrrr r r ÚCheckOperationalErrorArz!ModuleTests.CheckOperationalErrorcCr)Nz1IntegrityError is not a subclass of DatabaseError)rrrÚIntegrityErrorrrr r r ÚCheckIntegrityErrorErzModuleTests.CheckIntegrityErrorcCr)Nz0InternalError is not a subclass of DatabaseError)rrrÚ InternalErrorrrr r r ÚCheckInternalErrorIrzModuleTests.CheckInternalErrorcCr)Nz3ProgrammingError is not a subclass of DatabaseError)rrrÚProgrammingErrorrrr r r ÚCheckProgrammingErrorMrz!ModuleTests.CheckProgrammingErrorcCr)Nz4NotSupportedError is not a subclass of DatabaseError)rrrÚNotSupportedErrorrrr r r ÚCheckNotSupportedErrorQs  ÿþz"ModuleTests.CheckNotSupportedErrorN)Ú__name__Ú __module__Ú __qualname__r rrrrrrr r"r$r&r(r*r r r r rsrc@s–eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Ze ejdkd¡dd „ƒZd!S)"ÚConnectionTestscCs0t d¡|_|j ¡}| d¡| dd¡dS)Nú:memory:z4create table test(id integer primary key, name text)ú!insert into test(name) values (?)©Úfoo)rÚconnectÚcxÚcursorÚexecute©rÚcur r r ÚsetUpXs   zConnectionTests.setUpcCó|j ¡dS©N©r4Úcloserr r r ÚtearDown^ózConnectionTests.tearDowncCr:r;©r4Úcommitrr r r Ú CheckCommitar?zConnectionTests.CheckCommitcCó|j ¡|j ¡dSr;r@rr r r ÚCheckCommitAfterNoChangesdó z)ConnectionTests.CheckCommitAfterNoChangescCr:r;©r4Úrollbackrr r r Ú CheckRollbackkr?zConnectionTests.CheckRollbackcCrCr;rFrr r r ÚCheckRollbackAfterNoChangesnrEz+ConnectionTests.CheckRollbackAfterNoChangescCs|j ¡}dSr;)r4r5r7r r r Ú CheckCursorur?zConnectionTests.CheckCursorcCs>d}| tj¡t |¡}Wdƒn1s00YdS)Nz/foo/bar/bla/23534/mydb.db)Ú assertRaisesrr!r3)rZYOU_CANNOT_OPEN_THISÚconr r r ÚCheckFailedOpenxszConnectionTests.CheckFailedOpencCr:r;r<rr r r Ú CheckClose}r?zConnectionTests.CheckClosecCs¸| |jjtj¡| |jjtj¡| |jjtj¡| |jjtj¡| |jjtj¡| |jjtj¡| |jj tj ¡| |jj tj ¡| |jj tj ¡| |jj tj ¡dSr;) rr4rrrrrrr!r#r%r'r)rr r r ÚCheckExceptions€szConnectionTests.CheckExceptionscCs´t d¡}| ¡}| |jd¡| d¡| |jd¡| dd¡| |jd¡| ddg¡| ¡}| |jd¡| ¡| |jd¡| ddg¡| ¡}| |jd¡dS) Nr/Fz?create table transactiontest(id integer primary key, name text)z,insert into transactiontest(name) values (?)r1Tz-select name from transactiontest where name=?r2)rr3r5rÚin_transactionr6ÚfetchonerA)rr4r8Úrowr r r ÚCheckInTransactions   z"ConnectionTests.CheckInTransactioncCs6| t¡d|j_Wdƒn1s(0YdS)NT)rKZAttributeErrorr4rPrr r r ÚCheckInTransactionROŸó z$ConnectionTests.CheckInTransactionROcCsX| tt¡Gdd„dƒ}|ƒ}t |¡}| d¡Wdƒn1sJ0YdS)Nc@óeZdZdd„ZdS)z9ConnectionTests.CheckOpenWithPathLikeObject..PathcSstSr;)rrr r r Ú __fspath__¨r?zDConnectionTests.CheckOpenWithPathLikeObject..Path.__fspath__N)r+r,r-rWr r r r ÚPath§órXúcreate table test(id integer))Ú addCleanuprrrr3r6)rrXZpathr4r r r ÚCheckOpenWithPathLikeObject£s   z+ConnectionTests.CheckOpenWithPathLikeObjectc Cs8tjdkrH| tj¡tjdddWdƒn1s:0YdS| tt¡t t¡}| d¡Wdƒn1s~0Ytjdtdd}| d¡Wdƒn1sº0YtjdtdddH}| tj ¡| d ¡Wdƒn1s 0YWdƒn1s*0YdS) N)éér^r/T)ZurirZzfile:zinsert into test(id) values(0)z?mode=rozinsert into test(id) values(1)) rÚsqlite_version_inforKr)r3r[rrr6r!)rr4r r r Ú CheckOpenUri®s ,  ((zConnectionTests.CheckOpenUri)r]r]r z&needs sqlite versions older than 3.3.1cCsP| tj¡}tjdddWdƒn1s00Y| t|jƒd¡dS)Nr/F)Zcheck_same_threadz shared connections not available)rKrr)r3rÚstrÚ exception©rÚcmr r r Ú CheckSameThreadErrorOnOldVersion¼s,z0ConnectionTests.CheckSameThreadErrorOnOldVersionN)r+r,r-r9r>rBrDrHrIrJrMrNrOrSrTr\r`ÚunittestZskipIfrr_rer r r r r.Vs$   ÿr.c@sœeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„Zd;d<„Z d=d>„Z!d?d@„Z"dAdB„Z#dCdD„Z$dEdF„Z%dGdH„Z&dIdJ„Z'dKdL„Z(dMdN„Z)dOdP„Z*dQdR„Z+dSdT„Z,dUdV„Z-dWdX„Z.dYdZ„Z/d[d\„Z0d]d^„Z1d_d`„Z2dadb„Z3dcdd„Z4deS)fÚ CursorTestscCs6t d¡|_|j ¡|_|j d¡|j dd¡dS)Nr/z\create table test(id integer primary key, name text, income number, unique_test text unique)r0r1©rr3r4r5r8r6rr r r r9Äs   ÿzCursorTests.setUpcCó|j ¡|j ¡dSr;©r8r=r4rr r r r>Íó zCursorTests.tearDowncCó|j d¡dS)Núdelete from test©r8r6rr r r ÚCheckExecuteNoArgsÑr?zCursorTests.CheckExecuteNoArgscCó<| tj¡|j d¡Wdƒn1s.0YdS)Nz select asdf)rKrr!r8r6rr r r ÚCheckExecuteIllegalSqlÔóz"CursorTests.CheckExecuteIllegalSqlcCrp)Nzselect 5+4; select 4+5)rKrrr8r6rr r r ÚCheckExecuteTooMuchSqlØrrz"CursorTests.CheckExecuteTooMuchSqlcCrl)Nzselect 5+4; -- foo barrnrr r r ÚCheckExecuteTooMuchSql2Ür?z#CursorTests.CheckExecuteTooMuchSql2cCrl)NzT select 5+4; /* foo */ rnrr r r ÚCheckExecuteTooMuchSql3ßr?z#CursorTests.CheckExecuteTooMuchSql3cCs:| t¡|j d¡Wdƒn1s,0YdS©Né*)rKÚ TypeErrorr8r6rr r r ÚCheckExecuteWrongSqlArgèrUz#CursorTests.CheckExecuteWrongSqlArgcCó|j dd¡dS)Núinsert into test(id) values (?))rwrnrr r r ÚCheckExecuteArgIntìr?zCursorTests.CheckExecuteArgIntcCrz)Nú#insert into test(income) values (?))gq= ×£ˆ£@rnrr r r ÚCheckExecuteArgFloatïr?z CursorTests.CheckExecuteArgFloatcCrz)Nr0)ZHugornrr r r ÚCheckExecuteArgStringòr?z!CursorTests.CheckExecuteArgStringcCs@|j dd¡|j d|jjf¡|j ¡}| |dd¡dS)Nr0)úHugoz select name from test where id=?rr€)r8r6Ú lastrowidrQr©rrRr r r Ú!CheckExecuteArgStringWithZeroByteõs z-CursorTests.CheckExecuteArgStringWithZeroBytecCsN| t¡}|j dd¡Wdƒn1s.0Y| t|jƒd¡dS)Nr{rwz"parameters are of unsupported type)rKÚ ValueErrorr8r6rrarbrcr r r ÚCheckExecuteNonIterableüs ,z#CursorTests.CheckExecuteNonIterablecCs>| tj¡|j dd¡Wdƒn1s00YdS)Nr{)éZEgon©rKrr'r8r6rr r r ÚCheckExecuteWrongNoOfArgs1óz&CursorTests.CheckExecuteWrongNoOfArgs1cCrp©Nr{r‡rr r r ÚCheckExecuteWrongNoOfArgs2r‰z&CursorTests.CheckExecuteWrongNoOfArgs2cCrprŠr‡rr r r ÚCheckExecuteWrongNoOfArgs3 r‰z&CursorTests.CheckExecuteWrongNoOfArgs3cCs:|j d¡|j ddg¡|j ¡}| |dd¡dS)Nú%insert into test(name) values ('foo')ú"select name from test where name=?r2r©r8r6rQrr‚r r r ÚCheckExecuteParamLists  z!CursorTests.CheckExecuteParamListcCóJGdd„dtƒ}|j d¡|j d|ƒ¡|j ¡}| |dd¡dS)Nc@óeZdZdd„Zdd„ZdS)z0CursorTests.CheckExecuteParamSequence..LcSódS)Nr r rr r r Ú__len__r?z8CursorTests.CheckExecuteParamSequence..L.__len__cSr“©Nr2r ©rÚxr r r Ú __getitem__óz.L.__getitem__N)r+r,r-r”r˜r r r r ÚLsršrrŽrr2)Zobjectr8r6rQr)rršrRr r r ÚCheckExecuteParamSequences   z%CursorTests.CheckExecuteParamSequencecCs<|j d¡|j dddi¡|j ¡}| |dd¡dS)Nrú&select name from test where name=:nameÚnamer2rrr‚r r r ÚCheckExecuteDictMapping#s  z#CursorTests.CheckExecuteDictMappingcCr‘)Nc@rV)z6CursorTests.CheckExecuteDictMapping_Mapping..DcSr“r•r )rZkeyr r r Ú __missing__+r?zBCursorTests.CheckExecuteDictMapping_Mapping..D.__missing__N)r+r,r-rŸr r r r ÚD*rYr rrœrr2)Zdictr8r6rQr)rr rRr r r ÚCheckExecuteDictMapping_Mapping)s   z+CursorTests.CheckExecuteDictMapping_MappingcCóN|j d¡| tj¡"|j dddi¡Wdƒn1s@0YdS)Nrz1select name from test where name=:name and id=:idrr2©r8r6rKrr'rr r r Ú$CheckExecuteDictMappingTooLittleArgs3ó z0CursorTests.CheckExecuteDictMappingTooLittleArgscCsH|j d¡| tj¡|j d¡Wdƒn1s:0YdS)Nrrœr£rr r r ÚCheckExecuteDictMappingNoArgs8r¥z)CursorTests.CheckExecuteDictMappingNoArgscCr¢)NrrŽrr2r£rr r r ÚCheckExecuteDictMappingUnnamed=r¥z*CursorTests.CheckExecuteDictMappingUnnamedcCr:r;)r8r=rr r r rNBr?zCursorTests.CheckClosecCsD|j d¡|j d¡|j d¡|j d¡| |jjd¡dS)Nrmrzupdate test set name='bar'é©r8r6rÚrowcountrr r r ÚCheckRowcountExecuteEs     z CursorTests.CheckRowcountExecutecCs |j d¡| |jjd¡dS)Nzselect 5 union select 6iÿÿÿÿr©rr r r ÚCheckRowcountSelectLs zCursorTests.CheckRowcountSelectcCs2|j d¡|j dgd¢¡| |jjd¡dS)Nrmr0))r )r¨©r]r])r8r6Ú executemanyrrªrr r r ÚCheckRowcountExecutemanyUs z$CursorTests.CheckRowcountExecutemanycCs0|j d¡|j d¡|jd|jjdddS)Nrr¨z"total changes reported wrong value)Zmsg)r8r6Z assertLessr4Z total_changesrr r r ÚCheckTotalChangesZó  zCursorTests.CheckTotalChangescCs"|j ddd„tddƒDƒ¡dS)Nr}cSsg|] }|f‘qSr r )Z.0r—r r r Z dóz8CursorTests.CheckExecuteManySequence..édin)r8r®Úrangerr r r ÚCheckExecuteManySequencecr?z$CursorTests.CheckExecuteManySequencecCs"Gdd„dƒ}|j d|ƒ¡dS)Nc@r’)z4CursorTests.CheckExecuteManyIterator..MyItercSs d|_dS©Né)Úvaluerr r r Ú__init__hr?z=CursorTests.CheckExecuteManyIterator..MyIter.__init__cSs*|jdkrt‚n|jd7_|jfSdS)Né r )r¸Z StopIterationrr r r Ú__next__ks z=CursorTests.CheckExecuteManyIterator..MyIter.__next__N)r+r,r-r¹r»r r r r ÚMyItergsr¼r}©r8r®)rr¼r r r ÚCheckExecuteManyIteratorfs z$CursorTests.CheckExecuteManyIteratorcCsdd„}|j d|ƒ¡dS)NcsstdƒD] }|fVqdSr¶)r´)Zir r r ÚmygenurUz4CursorTests.CheckExecuteManyGenerator..mygenr}r½)rr¿r r r ÚCheckExecuteManyGeneratortsz%CursorTests.CheckExecuteManyGeneratorcCs>| t¡ |j ddg¡Wdƒn1s00YdS)Nrwr­©rKrxr8r®rr r r ÚCheckExecuteManyWrongSqlArg{rUz'CursorTests.CheckExecuteManyWrongSqlArgcCs@| tj¡ |j ddg¡Wdƒn1s20YdS)Nzselect ?r­)rKrr'r8r®rr r r ÚCheckExecuteManySelectrrz"CursorTests.CheckExecuteManySelectcCs<| t¡|j dd¡Wdƒn1s.0YdS)Nr}rwrÁrr r r ÚCheckExecuteManyNotIterableƒrUz'CursorTests.CheckExecuteManyNotIterablecCsv|j d¡|j dd¡|j dd¡|j d¡g}|jD]}| |d¡q>| |dd¡| |dd ¡dS) Nrmr{)r·)ézselect id from test order by idrr·r rÅ)r8r6Úappendr)rZlstrRr r r ÚCheckFetchIter‡s   zCursorTests.CheckFetchItercCs@|j d¡|j ¡}| |dd¡|j ¡}| |d¡dS)Núselect name from testrr2rr‚r r r Ú CheckFetchone“ó    zCursorTests.CheckFetchonecCs"|j ¡}| ¡}| |d¡dSr;)r4r5rQr)rÚcurrRr r r ÚCheckFetchoneNoStatementšs z$CursorTests.CheckFetchoneNoStatementcCsr| |jjd¡d|j_|j d¡|j d¡|j d¡|j d¡|j d¡|j ¡}| t|ƒd¡dS)Nr r¨rmz#insert into test(name) values ('A')z#insert into test(name) values ('B')z#insert into test(name) values ('C')rÈ)rr8Z arraysizer6Ú fetchmanyÚlen©rÚresr r r ÚCheckArraySizeŸs      zCursorTests.CheckArraySizecCsD|j d¡|j d¡}| t|ƒd¡|j d¡}| |g¡dS)NrÈr³r ©r8r6rÍrrÎrÏr r r ÚCheckFetchmany°s    zCursorTests.CheckFetchmanycCs.|j d¡|jjdd}| t|ƒd¡dS)NrÈr³)Zsizer rÒrÏr r r ÚCheckFetchmanyKwArg·s zCursorTests.CheckFetchmanyKwArgcCs@|j d¡|j ¡}| t|ƒd¡|j ¡}| |g¡dS)NrÈr )r8r6ÚfetchallrrÎrÏr r r Ú CheckFetchall½rÊzCursorTests.CheckFetchallcCs|j gd¢¡dS)N)r]ér·)r8Z setinputsizesrr r r ÚCheckSetinputsizesÄr?zCursorTests.CheckSetinputsizescCrz)Nr·r©r8Z setoutputsizerr r r ÚCheckSetoutputsizeÇr?zCursorTests.CheckSetoutputsizecCrlrvrÙrr r r ÚCheckSetoutputsizeNoColumnÊr?z&CursorTests.CheckSetoutputsizeNoColumncCs| |jj|j¡dSr;)rr8Z connectionr4rr r r ÚCheckCursorConnectionÍr™z!CursorTests.CheckCursorConnectioncCsB| t¡$dd„}|j |¡}Wdƒn1s40YdS)NcSódSr;r r r r r ÚfÓr²z/CursorTests.CheckWrongCursorCallable..f)rKrxr4r5)rrÞrËr r r ÚCheckWrongCursorCallableÑs z$CursorTests.CheckWrongCursorCallablecCsLGdd„dƒ}|ƒ}| t¡t |¡}Wdƒn1s>0YdS)Nc@s eZdZdS)z.CursorTests.CheckCursorWrongClass..FooN)r+r,r-r r r r ÚFoo×r²rà)rKrxrZCursor)rràr2rËr r r ÚCheckCursorWrongClassÖs z!CursorTests.CheckCursorWrongClassc Csbd}dD]T}|j|d4|j | |¡d¡| |jjd¡Wdƒq1sR0YqdS)Nz+{} INTO test(id, unique_test) VALUES (?, ?))zINSERT OR REPLACEZREPLACE©Ú statement)r r2r )ÚsubTestr8r6Úformatrr)rÚsqlrãr r r ÚCheckLastRowIDOnReplaceÜs z#CursorTests.CheckLastRowIDOnReplacecCs@|j dd¡| |jjd¡|j dd¡| |jjd¡dS)Nz2insert or ignore into test(unique_test) values (?))Útestr¨)r8r6rrrr r r ÚCheckLastRowIDOnIgnoreæsþþz"CursorTests.CheckLastRowIDOnIgnorec CsØg}dD]¶}d}|jd |¡dŒ|j | |¡|f¡| ||jjf¡| tj¡&|j | |¡|f¡Wdƒn1s„0Y| ||jjf¡Wdƒq1s´0Yqgd¢}|  ||¡dS)N)ÚFAILÚABORTÚROLLBACKz.INSERT OR {} INTO test(unique_test) VALUES (?)z INSERT OR {}râ)©rêr¨rí©rër]rî©rìr×rï) rärår8r6rÆrrKrr#r)rZresultsrãræZexpectedr r r ÚCheckLastRowIDInsertORðs42z"CursorTests.CheckLastRowIDInsertORN)5r+r,r-r9r>rorqrsrtruryr|r~rrƒr…rˆr‹rŒrr›ržr¡r¤r¦r§rNr«r¬r¯r°rµr¾rÀrÂrÃrÄrÇrÉrÌrÑrÓrÔrÖrØrÚrÛrÜrßrárçrérðr r r r rgÃsd         rgc@s\eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dS)Ú ThreadTestscCó(t d¡|_|j ¡|_|j d¡dS)Nr/z\create table test(id integer primary key, name text, bin binary, ratio number, ts timestamp))rr3rLr5rËr6rr r r r9r±zThreadTests.setUpcCrir;)rËr=rLrr r r r>rkzThreadTests.tearDowncCóRdd„}g}tj||j|dœd}| ¡| ¡t|ƒdkrN| d |¡¡dS)NcSóHz| ¡}| d¡WdStjy.YdS| d¡Yn0dS©Núdid not raise ProgrammingErrorúraised wrong exception)r5rÆrr')rLÚerrorsrËr r r Úrun ó z'ThreadTests.CheckConCursor..run©rLrø©ZtargetZkwargsrÚ ©Ú threadingÚThreadrLÚstartÚjoinrÎÚfail©rrùrøÚtr r r ÚCheckConCursor ó  zThreadTests.CheckConCursorcCró)NcSóHz| ¡| d¡WdStjy.YdS| d¡Yn0dSrõ)rArÆrr'rûr r r rùrúz'ThreadTests.CheckConCommit..runrûrürrýrþrr r r ÚCheckConCommitrzThreadTests.CheckConCommitcCró)NcSrrõ)rGrÆrr'rûr r r rù1rúz)ThreadTests.CheckConRollback..runrûrürrýrþrr r r ÚCheckConRollback0rzThreadTests.CheckConRollbackcCró)NcSrrõ©r=rÆrr'rûr r r rùCrúz&ThreadTests.CheckConClose..runrûrürrýrþrr r r Ú CheckConCloseBrzThreadTests.CheckConClosecCró)NcSóJz| d¡| d¡WdStjy0YdS| d¡Yn0dS)Nú#insert into test(name) values ('a')rör÷©r6rÆrr'©rËrør r r rùUó  z.ThreadTests.CheckCurImplicitBegin..runrrürrý©rÿrrËrrrÎrrr r r ÚCheckCurImplicitBeginTrz!ThreadTests.CheckCurImplicitBegincCró)NcSrrõr rr r r rùgrúz&ThreadTests.CheckCurClose..runrrürrýrrr r r Ú CheckCurClosefrzThreadTests.CheckCurClosecCs^dd„}g}|j d¡tj||j|dœd}| ¡| ¡t|ƒdkrZ| d |¡¡dS)NcSr )NrÈrör÷rrr r r rùyrz(ThreadTests.CheckCurExecute..runrrrürrý©rËr6rÿrrrrÎrrr r r ÚCheckCurExecutexs   zThreadTests.CheckCurExecutecCsjdd„}g}|j d¡|j d¡tj||j|dœd}| ¡| ¡t|ƒdkrf| d |¡¡dS) NcSrôrõ)rQrÆrr')rËrørRr r r rùŒrúz)ThreadTests.CheckCurIterNext..runrrÈrrürrýrrr r r ÚCheckCurIterNext‹s    zThreadTests.CheckCurIterNextN) r+r,r-r9r>rr r r rrrrr r r r rñsrñc@óDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)ÚConstructorTestscCót ddd¡}dS)NéÔrºé)rZDate©rZdr r r Ú CheckDate r?zConstructorTests.CheckDatecCr)Né é'é#)rZTime©rrr r r Ú CheckTime£r?zConstructorTests.CheckTimecCst dddddd¡}dS)Nrrºrrr r!)rZ Timestamp©rZtsr r r ÚCheckTimestamp¦r?zConstructorTests.CheckTimestampcCót d¡}dSrv)rZ DateFromTicksrr r r ÚCheckDateFromTicks©r?z#ConstructorTests.CheckDateFromTickscCr&rv)rZ TimeFromTicksr"r r r ÚCheckTimeFromTicks¬r?z#ConstructorTests.CheckTimeFromTickscCr&rv)rZTimestampFromTicksr$r r r ÚCheckTimestampFromTicks¯r?z(ConstructorTests.CheckTimestampFromTickscCr&)Ns')rZBinary)rZbr r r Ú CheckBinary²r?zConstructorTests.CheckBinaryN) r+r,r-rr#r%r'r(r)r*r r r r rŸsrc@r)ÚExtensionTestscCsBt d¡}| ¡}| d¡| d¡| ¡d}| |d¡dS)Nr/z -- bla bla /* a stupid comment */ create table a(i); insert into a(i) values (5); zselect i from arr·)rr3r5Ú executescriptr6rQr)rrLrËrÐr r r ÚCheckScriptStringSql¶s     z#ExtensionTests.CheckScriptStringSqlcCóLt d¡}| ¡}| tj¡| d¡Wdƒn1s>0YdS)Nr/z1create table test(x); asdf; create table test2(x)©rr3r5rKr!r,©rrLrËr r r ÚCheckScriptSyntaxErrorÃó z%ExtensionTests.CheckScriptSyntaxErrorcCr.)Nr/z5create table test(sadfsadfdsa); select foo from hurz;r/r0r r r ÚCheckScriptErrorNormalÉr2z%ExtensionTests.CheckScriptErrorNormalcCs\t d¡}| ¡}| t¡}| d¡Wdƒn1s<0Y| t|jƒd¡dS)Nr/s9create table test(foo); insert into test(foo) values (5);z script argument must be unicode.) rr3r5rKr„r,rrarb)rrLrËrdr r r ÚCheckCursorExecutescriptAsBytesÏs   (z.ExtensionTests.CheckCursorExecutescriptAsBytescCs.t d¡}| d¡ ¡d}| |dd¡dS)Nr/zselect 5rr·z Basic test of Connection.execute)rr3r6rQr©rrLZresultr r r ÚCheckConnectionExecuteÖs z%ExtensionTests.CheckConnectionExecutecCsbt d¡}| d¡| dddg¡| d¡ ¡}| |dddd ¡| |d dd d ¡dS) Nr/zcreate table test(foo)z insert into test(foo) values (?)r­©r×z!select foo from test order by foorr]z$Basic test of Connection.executemanyr r×)rr3r6r®rÕrr5r r r ÚCheckConnectionExecutemanyÛs   z)ExtensionTests.CheckConnectionExecutemanycCs8t d¡}| d¡| d¡ ¡d}| |dd¡dS)Nr/z9create table test(foo); insert into test(foo) values (5);zselect foo from testrr·z&Basic test of Connection.executescript)rr3r,r6rQrr5r r r ÚCheckConnectionExecutescriptãs  z+ExtensionTests.CheckConnectionExecutescriptN) r+r,r-r-r1r3r4r6r8r9r r r r r+µs r+c@óTeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)ÚClosedConTestscCsJt d¡}| ¡| tj¡| ¡}Wdƒn1s<0YdS©Nr/)rr3r=rKr'r5r0r r r ÚCheckClosedConCursorêr2z#ClosedConTests.CheckClosedConCursorcCóJt d¡}| ¡| tj¡| ¡Wdƒn1s<0YdSr<)rr3r=rKr'rA©rrLr r r ÚCheckClosedConCommitðr2z#ClosedConTests.CheckClosedConCommitcCr>r<)rr3r=rKr'rGr?r r r ÚCheckClosedConRollbackör2z%ClosedConTests.CheckClosedConRollbackcCsTt d¡}| ¡}| ¡| tj¡| d¡Wdƒn1sF0YdS)Nr/zselect 4)rr3r5r=rKr'r6r0r r r ÚCheckClosedCurExecuteüó  z$ClosedConTests.CheckClosedCurExecutecCsXt d¡}| ¡dd„}| tj¡| dd|¡Wdƒn1sJ0YdS)Nr/cSr“©Nr†r )r—r r r rÞr²z3ClosedConTests.CheckClosedCreateFunction..fr2r )rr3r=rKr'Zcreate_function)rrLrÞr r r ÚCheckClosedCreateFunctionrCz(ClosedConTests.CheckClosedCreateFunctioncCs^t d¡}| ¡Gdd„dƒ}| tj¡| dd|¡Wdƒn1sP0YdS)Nr/c@s$eZdZdd„Zdd„Zdd„ZdS)z6ClosedConTests.CheckClosedCreateAggregate..AggcSrÝr;r rr r r r¹r?z?ClosedConTests.CheckClosedCreateAggregate..Agg.__init__cSrÝr;r r–r r r Ústepr?z;ClosedConTests.CheckClosedCreateAggregate..Agg.stepcSr“rDr rr r r Úfinalizer?z?ClosedConTests.CheckClosedCreateAggregate..Agg.finalizeN)r+r,r-r¹rFrGr r r r ÚAgg srHr2r )rr3r=rKr'Zcreate_aggregate)rrLrHr r r ÚCheckClosedCreateAggregate s  z)ClosedConTests.CheckClosedCreateAggregatecCsTt d¡}| ¡dd„}| tj¡| |¡Wdƒn1sF0YdS)Nr/cWstjSr;)rZDENY)Zargsr r r Ú authorizerr?z;ClosedConTests.CheckClosedSetAuthorizer..authorizer)rr3r=rKr'Zset_authorizer)rrLrJr r r ÚCheckClosedSetAuthorizers  z'ClosedConTests.CheckClosedSetAuthorizercCsVt d¡}| ¡dd„}| tj¡| |d¡Wdƒn1sH0YdS)Nr/cSrÝr;r r r r r Úprogress"r²z?ClosedConTests.CheckClosedSetProgressCallback..progressr³)rr3r=rKr'Zset_progress_handler)rrLrLr r r ÚCheckClosedSetProgressCallbackrCz-ClosedConTests.CheckClosedSetProgressCallbackcCsHt d¡}| ¡| tj¡|ƒWdƒn1s:0YdSr<)rr3r=rKr'r?r r r ÚCheckClosedCall&r2zClosedConTests.CheckClosedCallN) r+r,r-r=r@rArBrErIrKrMrNr r r r r;és r;c@rV)ÚClosedCurTestsc CsŽt d¡}| ¡}| ¡dD]j}|dvr0d}n|dkrFdddgf}ng}| tj¡"t||ƒ}||ŽWdƒq1s~0YqdS) Nr/)r6r®r,rÕrÍrQ)r6r,)zselect 4 union select 5r®zinsert into foo(bar) values (?)r­r7)rr3r5r=rKr'Zgetattr)rrLrËZ method_nameZparamsZmethodr r r Ú CheckClosed-s  zClosedCurTests.CheckClosedN)r+r,r-rPr r r r rO,rYrOc@r:)ÚSqliteOnConflictTestscCrò)Nr/zz CREATE TABLE test( id INTEGER PRIMARY KEY, name TEXT, unique_name TEXT UNIQUE ); rhrr r r r9Fr±zSqliteOnConflictTests.setUpcCrir;rjrr r r r>OrkzSqliteOnConflictTests.tearDowncCsœd|j_|j ¡|_|j d¡|j d¡|j d¡| tj¡|j d¡Wdƒn1sf0Y|j ¡|j d¡|  |j  ¡g¡dS)NÚBEGINú,INSERT INTO test(name) VALUES ('abort_test')ú8INSERT OR ROLLBACK INTO test(unique_name) VALUES ('foo')z"SELECT name, unique_name from test© r4Zisolation_levelr5r8r6rKrr#rArrÕrr r r Ú.CheckOnConflictRollbackWithExplicitTransactionSs    *  zDSqliteOnConflictTests.CheckOnConflictRollbackWithExplicitTransactioncCs d|j_|j ¡|_|j d¡|j d¡|j d¡| tj¡|j d¡Wdƒn1sf0Y|j ¡|j d¡|  |j  ¡ddg¡dS)NrRrSú5INSERT OR ABORT INTO test(unique_name) VALUES ('foo')ú"SELECT name, unique_name FROM test©Z abort_testNr•rUrr r r Ú2CheckOnConflictAbortRaisesWithExplicitTransactionsbs    *  zHSqliteOnConflictTests.CheckOnConflictAbortRaisesWithExplicitTransactionscCsr|j d¡|j d¡| tj¡|j d¡Wdƒn1sF0Y|j d¡| |j ¡g¡dS)NrSrTrX©r8r6rKrr#rrÕrr r r Ú)CheckOnConflictRollbackWithoutTransactionrs   * z?SqliteOnConflictTests.CheckOnConflictRollbackWithoutTransactioncCsv|j d¡|j d¡| tj¡|j d¡Wdƒn1sF0Y|j d¡| |j ¡ddg¡dS)NrSrWrXrYr•r[rr r r Ú-CheckOnConflictAbortRaisesWithoutTransactions|s   * zCSqliteOnConflictTests.CheckOnConflictAbortRaisesWithoutTransactionscCsZ|j d¡| tj¡|j d¡Wdƒn1s:0Y| |j ¡g¡dS)Nz4INSERT OR FAIL INTO test(unique_name) VALUES ('foo')r[rr r r ÚCheckOnConflictFail‡s *z)SqliteOnConflictTests.CheckOnConflictFailcCs<|j d¡|j d¡|j d¡| |j ¡dg¡dS)Nz6INSERT OR IGNORE INTO test(unique_name) VALUES ('foo')zSELECT unique_name FROM testr1©r8r6rrÕrr r r ÚCheckOnConflictIgnoreó   z+SqliteOnConflictTests.CheckOnConflictIgnorecCs<|j d¡|j d¡|j d¡| |j ¡dg¡dS)NzFINSERT OR REPLACE INTO test(name, unique_name) VALUES ('Data!', 'foo')zUINSERT OR REPLACE INTO test(name, unique_name) VALUES ('Very different data!', 'foo')rX)zVery different data!r2r_rr r r ÚCheckOnConflictReplace”raz,SqliteOnConflictTests.CheckOnConflictReplaceN) r+r,r-r9r>rVrZr\r]r^r`rbr r r r rQ?s   rQc Csˆt td¡}t td¡}t td¡}t td¡}t td¡}t td¡}t td¡}t t d¡}t t d¡}t  |||||||||f ¡S)NZCheck) rfZ makeSuiterr.rgrñrr+r;rOrQZ TestSuite) Z module_suiteZconnection_suiteZ cursor_suiteZ thread_suiteZconstructor_suiteZ ext_suiteZclosed_con_suiteZclosed_cur_suiteZon_conflict_suiter r r Úsuiteœs         ýrccCst ¡}| tƒ¡dSr;)rfZTextTestRunnerrùrc)Zrunnerr r r rè¬srèZ__main__)rÿrfZsqlite3rZ test.supportrrZTestCaserr.rgrñrr+r;rOrQrcrèr+r r r r Zs&7mA4C]