a ZÚß^&Šã@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)Ú ModuleTestscCs| tjddtj¡dS)Nz2.0zapilevel is %s, should be 2.0)Ú assertEqualÚsqliteZapilevel©Úself©r ú*/usr/lib64/python3.9/sqlite3/test/dbapi.pyÚ CheckAPILevel s ÿzModuleTests.CheckAPILevelcCs| tjddtj¡dS)Nézthreadsafety is %d, should be 1)rrZ threadsafetyrr r r ÚCheckThreadSafety$s ÿzModuleTests.CheckThreadSafetycCs| tjddtj¡dS)NZqmarkz%paramstyle is '%s', should be 'qmark')rrZ paramstylerr r r ÚCheckParamStyle(s  ÿÿzModuleTests.CheckParamStylecCs| ttjtƒd¡dS)Nz&Warning is not a subclass of Exception)Ú assertTrueÚ issubclassrÚWarningÚ Exceptionrr r r Ú CheckWarning-sÿzModuleTests.CheckWarningcCs| ttjtƒd¡dS)Nz$Error is not a subclass of Exception)rrrÚErrorrrr r r Ú CheckError1sÿzModuleTests.CheckErrorcCs| ttjtjƒd¡dS)Nz)InterfaceError is not a subclass of Error)rrrÚInterfaceErrorrrr r r ÚCheckInterfaceError5sÿzModuleTests.CheckInterfaceErrorcCs| ttjtjƒd¡dS)Nz(DatabaseError is not a subclass of Error)rrrÚ DatabaseErrorrrr r r ÚCheckDatabaseError9sÿzModuleTests.CheckDatabaseErrorcCs| ttjtjƒd¡dS)Nz,DataError is not a subclass of DatabaseError)rrrÚ DataErrorrrr r r ÚCheckDataError=sÿzModuleTests.CheckDataErrorcCs| ttjtjƒd¡dS)Nz3OperationalError is not a subclass of DatabaseError)rrrÚOperationalErrorrrr r r ÚCheckOperationalErrorAsÿz!ModuleTests.CheckOperationalErrorcCs| ttjtjƒd¡dS)Nz1IntegrityError is not a subclass of DatabaseError)rrrÚIntegrityErrorrrr r r ÚCheckIntegrityErrorEsÿzModuleTests.CheckIntegrityErrorcCs| ttjtjƒd¡dS)Nz0InternalError is not a subclass of DatabaseError)rrrÚ InternalErrorrrr r r ÚCheckInternalErrorIsÿzModuleTests.CheckInternalErrorcCs| ttjtjƒd¡dS)Nz3ProgrammingError is not a subclass of DatabaseError)rrrÚProgrammingErrorrrr r r ÚCheckProgrammingErrorMsÿz!ModuleTests.CheckProgrammingErrorcCs| ttjtjƒd¡dS)Nz4NotSupportedError is not a subclass of DatabaseError)rrrÚNotSupportedErrorrrr r r ÚCheckNotSupportedErrorQs  ÿþz"ModuleTests.CheckNotSupportedErrorN)Ú__name__Ú __module__Ú __qualname__r r rrrrrrrrr!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.setUpcCs|j ¡dS©N©r/Úcloserr r r ÚtearDown^szConnectionTests.tearDowncCs|j ¡dSr5©r/Úcommitrr r r Ú CheckCommitaszConnectionTests.CheckCommitcCs|j ¡|j ¡dSr5r9rr r r ÚCheckCommitAfterNoChangesds z)ConnectionTests.CheckCommitAfterNoChangescCs|j ¡dSr5©r/Úrollbackrr r r Ú CheckRollbackkszConnectionTests.CheckRollbackcCs|j ¡|j ¡dSr5r=rr r r ÚCheckRollbackAfterNoChangesns z+ConnectionTests.CheckRollbackAfterNoChangescCs|j ¡}dSr5)r/r0r2r r r Ú CheckCursoruszConnectionTests.CheckCursorcCs>d}| tj¡t |¡}Wdƒn1s00YdS)Nz/foo/bar/bla/23534/mydb.db)Ú assertRaisesrrr.)rZYOU_CANNOT_OPEN_THISÚconr r r ÚCheckFailedOpenxszConnectionTests.CheckFailedOpencCs|j ¡dSr5r6rr r r Ú CheckClose}szConnectionTests.CheckClosecCs¸| |jjtj¡| |jjtj¡| |jjtj¡| |jjtj¡| |jjtj¡| |jjtj¡| |jj tj ¡| |jj tj ¡| |jj tj ¡| |jj tj ¡dSr5) rr/rrrrrrrrr 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 (?)r,Tz-select name from transactiontest where name=?r-)rr.r0rÚin_transactionr1Úfetchoner:)rr/r3Úrowr r r ÚCheckInTransactions   z"ConnectionTests.CheckInTransactioncCs6| t¡d|j_Wdƒn1s(0YdS)NT)rBÚAttributeErrorr/rGrr r r ÚCheckInTransactionROŸs z$ConnectionTests.CheckInTransactionROcCsX| tt¡Gdd„dƒ}|ƒ}t |¡}| d¡Wdƒn1sJ0YdS)Nc@seZdZdd„ZdS)z9ConnectionTests.CheckOpenWithPathLikeObject..PathcSstSr5)rrr r r Ú __fspath__¨szDConnectionTests.CheckOpenWithPathLikeObject..Path.__fspath__N)r&r'r(rMr r r r ÚPath§srNúcreate table test(id integer))Ú addCleanuprrrr.r1)rrNÚpathr/r 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)éérTr*T)ZurirOzfile:zinsert into test(id) values(0)z?mode=rozinsert into test(id) values(1)) rÚsqlite_version_inforBr$r.rPrrr1r)rr/r r r Ú CheckOpenUri®s ,  ((zConnectionTests.CheckOpenUri)rSrSr 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)rBrr$r.rÚstrÚ exception©rÚcmr r r Ú CheckSameThreadErrorOnOldVersion¼s,z0ConnectionTests.CheckSameThreadErrorOnOldVersionN)r&r'r(r4r8r;r<r?r@rArDrErFrJrLrRrVÚunittestZskipIfrrUr[r 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)r+r,©rr.r/r0r3r1rr r r r4Äs   ÿzCursorTests.setUpcCs|j ¡|j ¡dSr5©r3r7r/rr r r r8Ís zCursorTests.tearDowncCs|j d¡dS)Núdelete from test©r3r1rr r r ÚCheckExecuteNoArgsÑszCursorTests.CheckExecuteNoArgscCs<| tj¡|j d¡Wdƒn1s.0YdS)Nz select asdf)rBrrr3r1rr r r ÚCheckExecuteIllegalSqlÔsz"CursorTests.CheckExecuteIllegalSqlcCs<| tj¡|j d¡Wdƒn1s.0YdS)Nzselect 5+4; select 4+5)rBrrr3r1rr r r ÚCheckExecuteTooMuchSqlØsz"CursorTests.CheckExecuteTooMuchSqlcCs|j d¡dS)Nzselect 5+4; -- foo barrarr r r ÚCheckExecuteTooMuchSql2Üsz#CursorTests.CheckExecuteTooMuchSql2cCs|j d¡dS)NzT select 5+4; /* foo */ rarr r r ÚCheckExecuteTooMuchSql3ßsz#CursorTests.CheckExecuteTooMuchSql3cCs:| t¡|j d¡Wdƒn1s,0YdS©Né*)rBÚ TypeErrorr3r1rr r r ÚCheckExecuteWrongSqlArgès z#CursorTests.CheckExecuteWrongSqlArgcCs|j dd¡dS)Núinsert into test(id) values (?))rhrarr r r ÚCheckExecuteArgIntìszCursorTests.CheckExecuteArgIntcCs|j dd¡dS)Nú#insert into test(income) values (?))gq= ×£ˆ£@rarr r r ÚCheckExecuteArgFloatïsz CursorTests.CheckExecuteArgFloatcCs|j dd¡dS)Nr+)ZHugorarr r r ÚCheckExecuteArgStringòsz!CursorTests.CheckExecuteArgStringcCs@|j dd¡|j d|jjf¡|j ¡}| |dd¡dS)Nr+)úHugoz select name from test where id=?rrp)r3r1Ú lastrowidrHr©rrIr r r Ú!CheckExecuteArgStringWithZeroByteõs z-CursorTests.CheckExecuteArgStringWithZeroBytecCsN| t¡}|j dd¡Wdƒn1s.0Y| t|jƒd¡dS)Nrkrhz"parameters are of unsupported type)rBÚ ValueErrorr3r1rrWrXrYr r r ÚCheckExecuteNonIterableüs ,z#CursorTests.CheckExecuteNonIterablecCs>| tj¡|j dd¡Wdƒn1s00YdS)Nrk)éZEgon©rBrr"r3r1rr r r ÚCheckExecuteWrongNoOfArgs1sz&CursorTests.CheckExecuteWrongNoOfArgs1cCs<| tj¡|j d¡Wdƒn1s.0YdS©Nrkrwrr r r ÚCheckExecuteWrongNoOfArgs2sz&CursorTests.CheckExecuteWrongNoOfArgs2cCs<| tj¡|j d¡Wdƒn1s.0YdSryrwrr r r ÚCheckExecuteWrongNoOfArgs3 sz&CursorTests.CheckExecuteWrongNoOfArgs3cCs:|j d¡|j ddg¡|j ¡}| |dd¡dS)Nú%insert into test(name) values ('foo')ú"select name from test where name=?r-r©r3r1rHrrrr r r ÚCheckExecuteParamLists  z!CursorTests.CheckExecuteParamListcCsJGdd„dtƒ}|j d¡|j d|ƒ¡|j ¡}| |dd¡dS)Nc@seZdZdd„Zdd„ZdS)z0CursorTests.CheckExecuteParamSequence..LcSsdS)Nr r rr r r Ú__len__sz8CursorTests.CheckExecuteParamSequence..L.__len__cSsdS©Nr-r ©rÚxr r r Ú __getitem__sz.L.__getitem__N)r&r'r(r€r„r r r r ÚLsr…r|r}rr-)Úobjectr3r1rHr)rr…rIr r r ÚCheckExecuteParamSequences   z%CursorTests.CheckExecuteParamSequencecCs<|j d¡|j dddi¡|j ¡}| |dd¡dS)Nr|ú&select name from test where name=:nameÚnamer-rr~rrr r r ÚCheckExecuteDictMapping#s  z#CursorTests.CheckExecuteDictMappingcCsJGdd„dtƒ}|j d¡|j d|ƒ¡|j ¡}| |dd¡dS)Nc@seZdZdd„ZdS)z6CursorTests.CheckExecuteDictMapping_Mapping..DcSsdSrr )rÚkeyr r r Ú __missing__+szBCursorTests.CheckExecuteDictMapping_Mapping..D.__missing__N)r&r'r(rŒr r r r ÚD*srr|rˆrr-)Údictr3r1rHr)rrrIr r r ÚCheckExecuteDictMapping_Mapping)s   z+CursorTests.CheckExecuteDictMapping_MappingcCsN|j d¡| tj¡"|j dddi¡Wdƒn1s@0YdS)Nr|z1select name from test where name=:name and id=:idr‰r-©r3r1rBrr"rr r r Ú$CheckExecuteDictMappingTooLittleArgs3s z0CursorTests.CheckExecuteDictMappingTooLittleArgscCsH|j d¡| tj¡|j d¡Wdƒn1s:0YdS)Nr|rˆrrr r r ÚCheckExecuteDictMappingNoArgs8s z)CursorTests.CheckExecuteDictMappingNoArgscCsN|j d¡| tj¡"|j dddi¡Wdƒn1s@0YdS)Nr|r}r‰r-rrr r r ÚCheckExecuteDictMappingUnnamed=s z*CursorTests.CheckExecuteDictMappingUnnamedcCs|j ¡dSr5)r3r7rr r r rEBszCursorTests.CheckClosecCsD|j d¡|j d¡|j d¡|j d¡| |jjd¡dS)Nr`r|zupdate test set name='bar'é©r3r1rÚrowcountrr r r ÚCheckRowcountExecuteEs     z CursorTests.CheckRowcountExecutecCs |j d¡| |jjd¡dS)Nzselect 5 union select 6éÿÿÿÿr•rr r r ÚCheckRowcountSelectLs zCursorTests.CheckRowcountSelectcCs2|j d¡|j dgd¢¡| |jjd¡dS)Nr`r+))r )r”©rSrS)r3r1Ú executemanyrr–rr r r ÚCheckRowcountExecutemanyUs z$CursorTests.CheckRowcountExecutemanycCs0|j d¡|j d¡|jd|jjdddS)Nr|r”z"total changes reported wrong value)Úmsg)r3r1Z assertLessr/Z total_changesrr r r ÚCheckTotalChangesZs  zCursorTests.CheckTotalChangescCs"|j ddd„tddƒDƒ¡dS)NrmcSsg|] }|f‘qSr r )Ú.0rƒr r r Ú dóz8CursorTests.CheckExecuteManySequence..édén)r3r›Úrangerr r r ÚCheckExecuteManySequencecsz$CursorTests.CheckExecuteManySequencecCs"Gdd„dƒ}|j d|ƒ¡dS)Nc@seZdZdd„Zdd„ZdS)z4CursorTests.CheckExecuteManyIterator..MyItercSs d|_dS©Né)Úvaluerr r r Ú__init__hsz=CursorTests.CheckExecuteManyIterator..MyIter.__init__cSs*|jdkrt‚n|jd7_|jfSdS)Né r )r¨Ú StopIterationrr r r Ú__next__ks z=CursorTests.CheckExecuteManyIterator..MyIter.__next__N)r&r'r(r©r¬r r r r ÚMyItergsr­rm©r3r›)rr­r r r ÚCheckExecuteManyIteratorfs z$CursorTests.CheckExecuteManyIteratorcCsdd„}|j d|ƒ¡dS)NcsstdƒD] }|fVqdSr¦)r¤)Úir r r Úmygenus z4CursorTests.CheckExecuteManyGenerator..mygenrmr®)rr±r r r ÚCheckExecuteManyGeneratortsz%CursorTests.CheckExecuteManyGeneratorcCs>| t¡ |j ddg¡Wdƒn1s00YdS)Nrhrš©rBrir3r›rr r r ÚCheckExecuteManyWrongSqlArg{s z'CursorTests.CheckExecuteManyWrongSqlArgcCs@| tj¡ |j ddg¡Wdƒn1s20YdS)Nzselect ?rš)rBrr"r3r›rr r r ÚCheckExecuteManySelectsz"CursorTests.CheckExecuteManySelectcCs<| t¡|j dd¡Wdƒn1s.0YdS)Nrmrhr³rr r r ÚCheckExecuteManyNotIterableƒs z'CursorTests.CheckExecuteManyNotIterablecCsv|j d¡|j dd¡|j dd¡|j d¡g}|jD]}| |d¡q>| |dd¡| |dd ¡dS) Nr`rk)r§)ézselect id from test order by idrr§r r·)r3r1Úappendr)rZlstrIr r r ÚCheckFetchIter‡s   zCursorTests.CheckFetchItercCs@|j d¡|j ¡}| |dd¡|j ¡}| |d¡dS)Núselect name from testrr-r~rrr r r Ú CheckFetchone“s    zCursorTests.CheckFetchonecCs"|j ¡}| ¡}| |d¡dSr5)r/r0rHr)rÚcurrIr 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”r`z#insert into test(name) values ('A')z#insert into test(name) values ('B')z#insert into test(name) values ('C')rº)rr3Z arraysizer1Ú fetchmanyÚlen©rÚresr r r ÚCheckArraySizeŸs      zCursorTests.CheckArraySizecCsD|j d¡|j d¡}| t|ƒd¡|j d¡}| |g¡dS)Nrºr¢r ©r3r1r¾rr¿rÀr r r ÚCheckFetchmany°s    zCursorTests.CheckFetchmanycCs.|j d¡|jjdd}| t|ƒd¡dS)Nrºr¢)Úsizer rÃrÀr r r ÚCheckFetchmanyKwArg·s zCursorTests.CheckFetchmanyKwArgcCs@|j d¡|j ¡}| t|ƒd¡|j ¡}| |g¡dS)Nrºr )r3r1Úfetchallrr¿rÀr r r Ú CheckFetchall½s    zCursorTests.CheckFetchallcCs|j gd¢¡dS)N)rSér§)r3Z setinputsizesrr r r ÚCheckSetinputsizesÄszCursorTests.CheckSetinputsizescCs|j dd¡dS)Nr§r©r3Z setoutputsizerr r r ÚCheckSetoutputsizeÇszCursorTests.CheckSetoutputsizecCs|j d¡dSrgrËrr r r ÚCheckSetoutputsizeNoColumnÊsz&CursorTests.CheckSetoutputsizeNoColumncCs| |jj|j¡dSr5)rr3Ú connectionr/rr r r ÚCheckCursorConnectionÍsz!CursorTests.CheckCursorConnectioncCsB| t¡$dd„}|j |¡}Wdƒn1s40YdS)NcSsdSr5r r r r r ÚfÓr¡z/CursorTests.CheckWrongCursorCallable..f)rBrir/r0)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Ò)rBrirZCursor)rrÒr-r¼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 r-r )ÚsubTestr3r1Úformatrrq)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”)r3r1rrqrr 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ÝrSrà©rÞrÉrá) rÖr×r3r1r¸rqrBrrr)rÚresultsrÕrØZexpectedr r r ÚCheckLastRowIDInsertORðs42z"CursorTests.CheckLastRowIDInsertORN)5r&r'r(r4r8rbrcrdrerfrjrlrnrorsrurxrzr{rr‡rŠrr‘r’r“rEr—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 r]Ãsd         r]c@s\eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dS)Ú ThreadTestscCs(t d¡|_|j ¡|_|j d¡dS)Nr*z\create table test(id integer primary key, name text, bin binary, ratio number, ts timestamp))rr.rCr0r¼r1rr r r r4s  zThreadTests.setUpcCs|j ¡|j ¡dSr5)r¼r7rCrr r r r8s zThreadTests.tearDowncCsRdd„}g}tj||j|dœd}| ¡| ¡t|ƒdkrN| d |¡¡dS)NcSsHz| ¡}| d¡WdStjy.YdS| d¡Yn0dS©Núdid not raise ProgrammingErrorúraised wrong exception)r0r¸rr")rCÚerrorsr¼r r r Úrun s z'ThreadTests.CheckConCursor..run©rCrè©ÚtargetÚkwargsrÚ ©Ú threadingÚThreadrCÚstartÚjoinr¿Úfail©rrérèÚtr r r ÚCheckConCursor s  zThreadTests.CheckConCursorcCsRdd„}g}tj||j|dœd}| ¡| ¡t|ƒdkrN| d |¡¡dS)NcSsHz| ¡| d¡WdStjy.YdS| d¡Yn0dSrå)r:r¸rr"rêr r r rés z'ThreadTests.CheckConCommit..runrêrërrîrïrõr r r ÚCheckConCommits  zThreadTests.CheckConCommitcCsRdd„}g}tj||j|dœd}| ¡| ¡t|ƒdkrN| d |¡¡dS)NcSsHz| ¡| d¡WdStjy.YdS| d¡Yn0dSrå)r>r¸rr"rêr r r ré1s z)ThreadTests.CheckConRollback..runrêrërrîrïrõr r r ÚCheckConRollback0s  zThreadTests.CheckConRollbackcCsRdd„}g}tj||j|dœd}| ¡| ¡t|ƒdkrN| d |¡¡dS)NcSsHz| ¡| d¡WdStjy.YdS| d¡Yn0dSrå©r7r¸rr"rêr r r réCs z&ThreadTests.CheckConClose..runrêrërrîrïrõr r r Ú CheckConCloseBs  zThreadTests.CheckConClosecCsRdd„}g}tj||j|dœd}| ¡| ¡t|ƒdkrN| d |¡¡dS)NcSsJz| d¡| d¡WdStjy0YdS| d¡Yn0dS)Nú#insert into test(name) values ('a')rærç©r1r¸rr"©r¼rèr r r réUs  z.ThreadTests.CheckCurImplicitBegin..runrþrërrî©rðrñr¼ròrór¿rôrõr r r ÚCheckCurImplicitBeginTs  z!ThreadTests.CheckCurImplicitBegincCsRdd„}g}tj||j|dœd}| ¡| ¡t|ƒdkrN| d |¡¡dS)NcSsHz| ¡| d¡WdStjy.YdS| d¡Yn0dSrårúrþr r r régs z&ThreadTests.CheckCurClose..runrþrërrîrÿrõr r r Ú CheckCurClosefs  zThreadTests.CheckCurClosecCs^dd„}g}|j d¡tj||j|dœd}| ¡| ¡t|ƒdkrZ| d |¡¡dS)NcSsJz| d¡| d¡WdStjy0YdS| d¡Yn0dS)Nrºrærçrýrþr r r réys  z(ThreadTests.CheckCurExecute..runrürþrërrî©r¼r1rðrñròrór¿rôrõr r r ÚCheckCurExecutexs   zThreadTests.CheckCurExecutecCsjdd„}g}|j d¡|j d¡tj||j|dœd}| ¡| ¡t|ƒdkrf| d |¡¡dS) NcSsHz| ¡}| d¡WdStjy.YdS| d¡Yn0dSrå)rHr¸rr")r¼rèrIr r r réŒs z)ThreadTests.CheckCurIterNext..runrürºrþrërrîrrõr r r ÚCheckCurIterNext‹s    zThreadTests.CheckCurIterNextN) r&r'r(r4r8r÷rørùrûrrrrr r r r räsräc@sDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)ÚConstructorTestscCst ddd¡}dS)NéÔrªé)rZDate©rÚdr r r Ú CheckDate szConstructorTests.CheckDatecCst ddd¡}dS)Né é'é#)rZTime©rrör r r Ú CheckTime£szConstructorTests.CheckTimecCst dddddd¡}dS)Nrrªrr r r )rZ Timestamp©rÚtsr r r ÚCheckTimestamp¦szConstructorTests.CheckTimestampcCst d¡}dSrg)rZ DateFromTicksrr r r ÚCheckDateFromTicks©sz#ConstructorTests.CheckDateFromTickscCst d¡}dSrg)rZ TimeFromTicksrr r r ÚCheckTimeFromTicks¬sz#ConstructorTests.CheckTimeFromTickscCst d¡}dSrg)rZTimestampFromTicksrr r r ÚCheckTimestampFromTicks¯sz(ConstructorTests.CheckTimestampFromTickscCst d¡}dS)Ns')rZBinary)rÚbr r r Ú CheckBinary²szConstructorTests.CheckBinaryN) r&r'r(r rrrrrrr r r r rŸsrc@sDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)Ú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§)rr.r0Ú executescriptr1rHr)rrCr¼rÁr r r ÚCheckScriptStringSql¶s     z#ExtensionTests.CheckScriptStringSqlcCsLt d¡}| ¡}| tj¡| d¡Wdƒn1s>0YdS)Nr*z1create table test(x); asdf; create table test2(x)©rr.r0rBrr©rrCr¼r r r ÚCheckScriptSyntaxErrorÃs z%ExtensionTests.CheckScriptSyntaxErrorcCsLt d¡}| ¡}| tj¡| d¡Wdƒn1s>0YdS)Nr*z5create table test(sadfsadfdsa); select foo from hurz;rrr r r ÚCheckScriptErrorNormalÉs z%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.) rr.r0rBrtrrrWrX)rrCr¼rZr r r ÚCheckCursorExecutescriptAsBytesÏs   (z.ExtensionTests.CheckCursorExecutescriptAsBytescCs.t d¡}| d¡ ¡d}| |dd¡dS)Nr*zselect 5rr§z Basic test of Connection.execute)rr.r1rHr©rrCÚresultr 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 foorrSz$Basic test of Connection.executemanyr rÉ)rr.r1r›rÇrr r 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)rr.rr1rHrr r r r ÚCheckConnectionExecutescriptãs  z+ExtensionTests.CheckConnectionExecutescriptN) r&r'r(rrrrr"r$r%r r r r rµs rc@sTeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)ÚClosedConTestscCsJt d¡}| ¡| tj¡| ¡}Wdƒn1s<0YdS©Nr*)rr.r7rBr"r0rr r r ÚCheckClosedConCursorês z#ClosedConTests.CheckClosedConCursorcCsJt d¡}| ¡| tj¡| ¡Wdƒn1s<0YdSr')rr.r7rBr"r:©rrCr r r ÚCheckClosedConCommitðs z#ClosedConTests.CheckClosedConCommitcCsJt d¡}| ¡| tj¡| ¡Wdƒn1s<0YdSr')rr.r7rBr"r>r)r r r ÚCheckClosedConRollbackös z%ClosedConTests.CheckClosedConRollbackcCsTt d¡}| ¡}| ¡| tj¡| d¡Wdƒn1sF0YdS)Nr*zselect 4)rr.r0r7rBr"r1rr r r ÚCheckClosedCurExecuteüs  z$ClosedConTests.CheckClosedCurExecutecCsXt d¡}| ¡dd„}| tj¡| dd|¡Wdƒn1sJ0YdS)Nr*cSsdS©Nrvr )rƒr r r rÐr¡z3ClosedConTests.CheckClosedCreateFunction..fr-r )rr.r7rBr"Zcreate_function)rrCrÐr r r ÚCheckClosedCreateFunctions  z(ClosedConTests.CheckClosedCreateFunctioncCs^t d¡}| ¡Gdd„dƒ}| tj¡| dd|¡Wdƒn1sP0YdS)Nr*c@s$eZdZdd„Zdd„Zdd„ZdS)z6ClosedConTests.CheckClosedCreateAggregate..AggcSsdSr5r rr r r r©sz?ClosedConTests.CheckClosedCreateAggregate..Agg.__init__cSsdSr5r r‚r r r Ústepsz;ClosedConTests.CheckClosedCreateAggregate..Agg.stepcSsdSr-r rr r r Úfinalizesz?ClosedConTests.CheckClosedCreateAggregate..Agg.finalizeN)r&r'r(r©r/r0r r r r ÚAgg sr1r-r )rr.r7rBr"Zcreate_aggregate)rrCr1r r r ÚCheckClosedCreateAggregate s  z)ClosedConTests.CheckClosedCreateAggregatecCsTt d¡}| ¡dd„}| tj¡| |¡Wdƒn1sF0YdS)Nr*cWstjSr5)rZDENY)Úargsr r r Ú authorizersz;ClosedConTests.CheckClosedSetAuthorizer..authorizer)rr.r7rBr"Zset_authorizer)rrCr4r r r ÚCheckClosedSetAuthorizers  z'ClosedConTests.CheckClosedSetAuthorizercCsVt d¡}| ¡dd„}| tj¡| |d¡Wdƒn1sH0YdS)Nr*cSsdSr5r r r r r Úprogress"r¡z?ClosedConTests.CheckClosedSetProgressCallback..progressr¢)rr.r7rBr"Zset_progress_handler)rrCr6r r r ÚCheckClosedSetProgressCallbacks  z-ClosedConTests.CheckClosedSetProgressCallbackcCsHt d¡}| ¡| tj¡|ƒWdƒn1s:0YdSr')rr.r7rBr"r)r r r ÚCheckClosedCall&s zClosedConTests.CheckClosedCallN) r&r'r(r(r*r+r,r.r2r5r7r8r r r r r&és r&c@seZdZdd„ZdS)ÚClosedCurTestsc CsŽt d¡}| ¡}| ¡dD]j}|dvr0d}n|dkrFdddgf}ng}| tj¡"t||ƒ}||ŽWdƒq1s~0YqdS) Nr*)r1r›rrÇr¾rH)r1r)zselect 4 union select 5r›zinsert into foo(bar) values (?)ršr#)rr.r0r7rBr"Úgetattr)rrCr¼Z method_nameÚparamsÚmethodr r r Ú CheckClosed-s  zClosedCurTests.CheckClosedN)r&r'r(r=r r r r r9,sr9c@sTeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)ÚSqliteOnConflictTestscCs(t d¡|_|j ¡|_|j d¡dS)Nr*zz CREATE TABLE test( id INTEGER PRIMARY KEY, name TEXT, unique_name TEXT UNIQUE ); r^rr r r r4Fs  zSqliteOnConflictTests.setUpcCs|j ¡|j ¡dSr5r_rr r r r8Os zSqliteOnConflictTests.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© r/Zisolation_levelr0r3r1rBrrr:rrÇ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)Nr?r@ú5INSERT OR ABORT INTO test(unique_name) VALUES ('foo')ú"SELECT name, unique_name FROM test©Z abort_testNrrBrr r r Ú2CheckOnConflictAbortRaisesWithExplicitTransactionsbs    *  zHSqliteOnConflictTests.CheckOnConflictAbortRaisesWithExplicitTransactionscCsr|j d¡|j d¡| tj¡|j d¡Wdƒn1sF0Y|j d¡| |j ¡g¡dS)Nr@rArE©r3r1rBrrrrÇrr r r Ú)CheckOnConflictRollbackWithoutTransactionrs   * z?SqliteOnConflictTests.CheckOnConflictRollbackWithoutTransactioncCsv|j d¡|j d¡| tj¡|j d¡Wdƒn1sF0Y|j d¡| |j ¡ddg¡dS)Nr@rDrErFrrHrr 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')rHrr 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 testr,©r3r1rrÇrr r r ÚCheckOnConflictIgnores   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')rE)zVery different data!r-rLrr r r ÚCheckOnConflictReplace”s   z,SqliteOnConflictTests.CheckOnConflictReplaceN) r&r'r(r4r8rCrGrIrJrKrMrNr r r r r>?s   r>c 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) r\Z makeSuiterr)r]rärrr&r9r>Z TestSuite) Z module_suiteZconnection_suiteZ cursor_suiteZ thread_suiteZconstructor_suiteZ ext_suiteZclosed_con_suiteZclosed_cur_suiteZon_conflict_suiter r r Úsuiteœs         ýrOcCst ¡}| tƒ¡dSr5)r\ZTextTestRunnerrérO)Zrunnerr r r rÚ¬srÚÚ__main__)rðr\Zsqlite3rZ test.supportrrZTestCaserr)r]rärrr&r9r>rOrÚr&r r r r Ús&7mA4C]