��Qc@siddlZddlZddlZdejfd��YZd�Zd�Zedkree�ndS(i�NtRegressionTestscBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cCstjd�|_dS(Ns:memory:(tsqlitetconnecttcon(tself((s-/sys/lib/python2.7/sqlite3/test/regression.pytsetUpscCs|jj�dS(N(Rtclose(R((s-/sys/lib/python2.7/sqlite3/test/regression.pyttearDown scCs |jj�}|jd�dS(Nspragma user_version(Rtcursortexecute(Rtcur((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckPragmaUserVersion#scCsTtjddtj�}z |jj�}|jd�Wd|j�|j�XdS(Ns:memory:tdetect_typesspragma schema_version(RRtPARSE_COLNAMESRRR R(RRR
((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckPragmaSchemaVersion(s
cCs�tjddd�}gtd�D]}|j�^q"}|djd�xDtd�D]6}|djdgtd�D]}|f^qx�qXWx-td�D]}||jd|d �q�W|j�dS(
Ns:memory:tcached_statementsiiscreate table test(x)i
sinsert into test(x) values (?)t sselect x from test(RRtxrangeRR trangetexecutemanytrollback(RRtxtcursorsti((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckStatementReset2s%4cCsc|jj�}|jd�|j|jddd�|jd�|j|jddd�dS(Ns select 1 as "foo bar [datetime]"isfoo barsselect 1 as "foo baz"sfoo baz(RRR tassertEqualtdescription(RR
((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckColumnNameWithSpacesAs
cCsjtjd�}g}xDtd�D]6}|j�}|j|�|jdt|��q"W|j�dS(Ns:memory:iisselect 1 x union select (RRRRtappendR tstrR(RRRRR
((s-/sys/lib/python2.7/sqlite3/test/regression.pyt#CheckStatementFinalizationOnCloseDbIs
cCs�tjdkrdStjd�}|jd�|jd�y|jd�Wntjk
rcnX|jd�y|j�Wn!tjk
r�|jd�nXdS( Niis:memory:s3create table foo(x, unique(x) on conflict rollback)sinsert into foo(x) values (1)sinsert into foo(x) values (2)s1pysqlite knew nothing about the implicit ROLLBACK(iii(Rtsqlite_version_infoRR t
DatabaseErrortcommittOperationalErrortfail(RR((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckOnConflictRollbackWs
cCs4|jjd�|jjd�|jjd�dS(sm
pysqlite would crash with older SQLite versions unless
a workaround is implemented.
screate table foo(bar)sdrop table fooN(RR (R((s-/sys/lib/python2.7/sqlite3/test/regression.pyt-CheckWorkaroundForBuggySqliteTransferBindingsgscCs|jjd�dS(s
pysqlite used to segfault with SQLite versions 3.5.x. These return NULL
for "no-operation" statements
tN(RR (R((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckEmptyStatementpscCstjd�}|j�dS(s
With pysqlite 2.4.0 you needed to use a string or a APSW connection
object for opening database connections.
Formerly, both bytestrings and unicode strings used to work.
Let's make sure unicode strings work in the future.
u:memory:N(RRR(RR((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckUnicodeConnectws cCs�d}tjddtj�}|jd�|jdtjj�f�|j|�|jd�|jd�|jd�|j|�d S(
s�
pysqlite until 2.4.1 did not rebuild the row_cast_map when recompiling
a statement. This test exhibits the problem.
sselect * from foos:memory:Rscreate table foo(bar timestamp)sinsert into foo(bar) values (?)sdrop table fooscreate table foo(bar integer)sinsert into foo(bar) values (5)N(RRtPARSE_DECLTYPESR tdatetimetnow(RtSELECTR((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckTypeMapUsage�s
cCs|jttjid�dS(s!
See issue 3312.
N(tassertRaisest TypeErrorRtregister_adaptertNone(R((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckRegisterAdapter�scCs,tjd�}|jtt|dd�dS(s!
See issue 3312.
s:memory:tisolation_leveluéN(RRR.tUnicodeEncodeErrortsetattr(RR((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckSetIsolationLevel�scCs�dtjfd��Y}tjd�}||�}y$|jd�j�|jd�Wn'tjk
rnn|jd�nXdS(s[
Verifies that cursor methods check wether base class __init__ was called.
tCursorcBseZd�ZRS(cSsdS(N((RR((s-/sys/lib/python2.7/sqlite3/test/regression.pyt__init__�s(t__name__t
__module__R8(((s-/sys/lib/python2.7/sqlite3/test/regression.pyR7�ss:memory:s
select 4+5s#should have raised ProgrammingErrorN(RR7RR tfetchallR#tProgrammingError(RR7RR
((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckCursorConstructorCallCheck�scCspdtjfd��Y}|d�}y|j�}|jd�Wn'tjk
rXn|jd�nXdS(s_
Verifies that connection methods check wether base class __init__ was called.
t
ConnectioncBseZd�ZRS(cSsdS(N((Rtname((s-/sys/lib/python2.7/sqlite3/test/regression.pyR8�s(R9R:R8(((s-/sys/lib/python2.7/sqlite3/test/regression.pyR>�ss:memory:s#should have raised ProgrammingErrorN(RR>RR#R<(RR>RR
((s-/sys/lib/python2.7/sqlite3/test/regression.pyt#CheckConnectionConstructorCallCheck�scs�dtjf�fd��Y}dtjfd��Y�|d�}|j�}|jd�|jddddg�|jd�|j�y|j�|jd�Wn'tj k
r�n|jd�nXd
S(s�
Verifies that subclassed cursor classes are correctly registered with
the connection object, too. (fetch-across-rollback problem)
R>cseZ�fd�ZRS(cs
�|�S(N((R(R7(s-/sys/lib/python2.7/sqlite3/test/regression.pyR�s(R9R:R((R7(s-/sys/lib/python2.7/sqlite3/test/regression.pyR>�sR7cBseZd�ZRS(cSstjj||�dS(N(RR7R8(RR((s-/sys/lib/python2.7/sqlite3/test/regression.pyR8�s(R9R:R8(((s-/sys/lib/python2.7/sqlite3/test/regression.pyR7�ss:memory:screate table foo(x)sinsert into foo(x) values (?)iiisselect x from foos!should have raised InterfaceErrorN(i(i(i(
RR>R7RR RRR;R#tInterfaceError(RR>RR
((R7s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckCursorRegistration�s
cCstjddd�}dS(s�
Verifies that creating a connection in autocommit mode works.
2.5.3 introduced a regression so that these could no longer
be created.
s:memory:R3N(RRR1(RR((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckAutoCommit�scCsF|jj�}|jd�|jd�|jd�|j�}dS(s�
Verifies that running a PRAGMA statement that does an autocommit does
work. This did not work in 2.5.3/2.5.4.
screate table foo(bar)sinsert into foo(bar) values (5)spragma page_sizeN(RRR tfetchone(RR
trow((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckPragmaAutocommit�s
cCs�ddd��Y}|�}|jt|jj|�|jt|jj|�|jt|jj|�|jt|jj|�dS(s�
See http://bugs.python.org/issue7478
It was possible to successfully register callbacks that could not be
hashed. Return codes of PyDict_SetItem were not checked properly.
tNotHashablecBseZd�Zd�ZRS(c_sdS(N((Rtargstkw((s-/sys/lib/python2.7/sqlite3/test/regression.pyt__call__�scSs
t��dS(N(R/(R((s-/sys/lib/python2.7/sqlite3/test/regression.pyt__hash__�s(R9R:RJRK(((s-/sys/lib/python2.7/sqlite3/test/regression.pyRG�s N((R.R/Rtcreate_functiontcreate_aggregatetset_authorizertset_progress_handler(RRGtvar((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckSetDict�s cCs|jtj|jd�dS(s}
Call a connection with a non-string SQL request: check error handling
of the statement constructor.
iN(R.RtWarningR(R((s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckConnectionCallscs~tjd�}|j���jd��jd��fd�}|jtj���jdd�|�D��WdQXdS(s�
http://bugs.python.org/issue10811
Recursively using a cursor, such as when reusing it from a generator led to segfaults.
Now we catch recursive cursor usage and raise a ProgrammingError.
s:memory:screate table a (bar)screate table b (baz)c3s�jdd�dVdS(Nsinsert into a (bar) values (?)i(i(R ((R
(s-/sys/lib/python2.7/sqlite3/test/regression.pytfoossinsert into b (baz) values (?)css|]}|fVqdS(N((t.0R((s-/sys/lib/python2.7/sqlite3/test/regression.pys <genexpr>sN(RRRR R.R<R(RRRT((R
s-/sys/lib/python2.7/sqlite3/test/regression.pytCheckRecursiveCursorUses
cCs�tjddtj�}|j�}|jd�|jd�|jd�|jd�g|j�D]}|d^qe}|j|tjdd d d
ddd�tjdd d d
ddd
�g�dS(s�
http://bugs.python.org/issue14720
The microsecond parsing of convert_timestamp() should pad with zeros,
since the microsecond string "456" actually represents "456000".
s:memory:RsCREATE TABLE t (x TIMESTAMP)s4INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.456')s:INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.123456789')sSELECT * FROM tii�iiii@�@�N(RRR)RR R;RR*(RRR
Rtvalues((s-/sys/lib/python2.7/sqlite3/test/regression.pyt'CheckConvertTimestampMicrosecondPadding s
# (R9R:RRRRRRRR$R%R'R(R-R2R6R=R@RBRCRFRQRSRVRX(((s-/sys/lib/python2.7/sqlite3/test/regression.pyRs.
cCs"tjtd�}tj|f�S(NtCheck(tunittestt makeSuiteRt TestSuite(tregression_suite((s-/sys/lib/python2.7/sqlite3/test/regression.pytsuite;scCs tj�}|jt��dS(N(RZtTextTestRunnertrunR^(trunner((s-/sys/lib/python2.7/sqlite3/test/regression.pyttest?st__main__( R*RZtsqlite3RtTestCaseRR^RbR9(((s-/sys/lib/python2.7/sqlite3/test/regression.pyt<module>s�
|