HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/sqlite3/test/__pycache__/regression.cpython-310.pyc
o

�i�C�@s�ddlZddlZddlZddlZddlZddlmZddlm	Z	Gdd�dej
�ZGdd�dej
�Zdd	�Z
d
d�ZedkrCe�dSdS)
�N)�support)�patchc@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�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"dAS)B�RegressionTestscCst�d�|_dS)N�:memory:)�sqlite�connect�con��self�r�4/usr/local/lib/python3.10/sqlite3/test/regression.py�setUp"szRegressionTests.setUpcCs|j��dS�N)r�closer	rrr�tearDown%szRegressionTests.tearDowncCs|j��}|�d�dS)Nzpragma user_version)r�cursor�execute�r
�currrr�test_pragma_user_version(s
z(RegressionTests.test_pragma_user_versioncCsNtjdtjd�}z|j��}|�d�W|��|��dS|��|��w)Nr�Zdetect_typeszpragma schema_version)rr�PARSE_COLNAMESrrrr�r
rrrrr�test_pragma_schema_version-s
�
z*RegressionTests.test_pragma_schema_versioncs�tjddd���fdd�td�D�}|d�d�td�D]}|d�d	d
d�td�D��qtd�D]
}||�d|d�q3���dS)
Nr�)Zcached_statementscsg|]}����qSr)r��.0�x�rrr�
<listcomp><�z8RegressionTests.test_statement_reset.<locals>.<listcomp>rzcreate table test(x)�
�insert into test(x) values (?)cSsg|]}|f�qSrrrrrrr?s� zselect x from test)rr�ranger�executemany�rollback)r
�cursors�irrr�test_statement_reset7s z$RegressionTests.test_statement_resetcCsN|j��}|�d�|�|jddd�|�d�|�|jddd�dS)Nz select 1 as "foo bar [datetime]"rzfoo bar [datetime]zselect 1 as "foo baz"zfoo baz)rrr�assertEqual�descriptionrrrr�test_column_name_with_spacesFs



z,RegressionTests.test_column_name_with_spacescCsLt�d�}g}td�D]}|��}|�|�|�dt|��q|��dS)Nr�izselect 1 x union select )rrr$r�appendr�strr)r
rr'r(rrrr�'test_statement_finalization_on_close_dbNs

z7RegressionTests.test_statement_finalization_on_close_dbcCs|t�d�}|�d�|�d�z|�d�Wn
tjy Ynw|�d�z|��WdStjy=|�d�YdSw)Nrz3create table foo(x, unique(x) on conflict rollback)zinsert into foo(x) values (1)zinsert into foo(x) values (2)z1pysqlite knew nothing about the implicit ROLLBACK)rrrZ
DatabaseError�commit�OperationalErrorZfail�r
rrrr�test_on_conflict_rollback\s


�
�z)RegressionTests.test_on_conflict_rollbackcCs(|j�d�|j�d�|j�d�dS)zm
        pysqlite would crash with older SQLite versions unless
        a workaround is implemented.
        �create table foo(bar)�drop table fooN�rrr	rrr�2test_workaround_for_buggy_sqlite_transfer_bindingsjszBRegressionTests.test_workaround_for_buggy_sqlite_transfer_bindingscCs|j�d�dS)z
        pysqlite used to segfault with SQLite versions 3.5.x. These return NULL
        for "no-operation" statements
        �Nr7r	rrr�test_empty_statementssz$RegressionTests.test_empty_statementcCspd}tjdtjd�}|�d�|�dtj��f�|�|���|�d�|�d�|�d�|�|���d	S)
z�
        pysqlite until 2.4.1 did not rebuild the row_cast_map when recompiling
        a statement. This test exhibits the problem.
        zselect * from foorrzcreate table foo(bar timestamp)zinsert into foo(bar) values (?)r6zcreate table foo(bar integer)�insert into foo(bar) values (5)N)rr�PARSE_DECLTYPESr�datetimeZnowr)r
ZSELECTrrrr�test_type_map_usagezs



z#RegressionTests.test_type_map_usagecsrG�fdd�d�}|�dg�tjdtjd�}|�d�|�t��|�d��Wd�dS1s2wYdS)Nc�eZdZ�fdd�ZdS)z2RegressionTests.test_bind_mutating_list.<locals>.Xcs���dS)Nz...)�clear)r
�protocol�Z
parametersrr�__conform__�sz>RegressionTests.test_bind_mutating_list.<locals>.X.__conform__N)�__name__�
__module__�__qualname__rCrrBrr�X��rGrrrz$create table foo(bar X, baz integer)z'insert into foo(bar, baz) values (?, ?))rrr<r�assertRaises�
IndexError)r
rGrrrBr�test_bind_mutating_list�s

"�z'RegressionTests.test_bind_mutating_listcCsd|�tj��}|j�dttdg��f���Wd�n1s wYd}|�|t	|j
��dS)Nz"select 'xxx' || ? || 'yyy' colname�z9Could not decode to UTF-8 column 'colname' with text 'xxx)rIrr2rr�bytes�	bytearray�fetchoneZassertInr/�	exception)r
�cm�msgrrr�test_error_msg_decode_error�s��z+RegressionTests.test_error_msg_decode_errorcCs|�ttjid�dS)z!
        See issue 3312.
        N)rI�	TypeErrorrZregister_adapterr	rrr�test_register_adapter�sz%RegressionTests.test_register_adapterc
s(G�fdd�dt�}t�d��d�_dD]*}|j|d��|�_|���_|���_||��_Wd�n1s9wYqd�_d�_dtfdtfd	tfd
tfdtfg}|D]9\}}|j|d��'|�	|��|�_Wd�n1svwY|�
�jd�Wd�n1s�wYqXdS)Ncs eZdZdd�Z�fdd�ZdS)z;RegressionTests.test_set_isolation_level.<locals>.CustomStrcS�dSrrr	rrr�upper��zARegressionTests.test_set_isolation_level.<locals>.CustomStr.uppercs
d�_dS)Nr9��isolation_levelr	rrr�__del__�s
zCRegressionTests.test_set_isolation_level.<locals>.CustomStr.__del__N)rDrErFrWr[rrrr�	CustomStr�sr\r)r9�DEFERREDZ	IMMEDIATEZ	EXCLUSIVE)�levelr]���abczIMMEDIATEEXCLUSIVE�é)r/rrrZ�subTest�lower�
capitalizerT�
ValueErrorrIr*)r
r\r^�pairs�value�excrrr�test_set_isolation_level�s2


�������z(RegressionTests.test_set_isolation_levelcCs�Gdd�dtj�}t�d�}||�}|�tj��|�d���Wd�n1s*wY|�tjd��
|��Wd�dS1sFwYdS)zd
        Verifies that cursor methods check whether base class __init__ was
        called.
        c@�eZdZdd�ZdS)zBRegressionTests.test_cursor_constructor_call_check.<locals>.CursorcSrVrrr3rrr�__init__�rXzKRegressionTests.test_cursor_constructor_call_check.<locals>.Cursor.__init__N�rDrErFrlrrrr�Cursor��rnrz
select 4+5Nz$^Base Cursor\.__init__ not called\.$)	rrnrrI�ProgrammingErrorr�fetchall�assertRaisesRegexr)r
rnrrrrr�"test_cursor_constructor_call_check�s
��
"�z2RegressionTests.test_cursor_constructor_call_checkcCs(Gdd�dt�}|j�d|d�f�dS)za
        The Python 3.0 port of the module didn't cope with values of subclasses of str.
        c@seZdZdS)z0RegressionTests.test_str_subclass.<locals>.MyStrN)rDrErFrrrr�MyStr�srtzselect ?raN)r/rr)r
rtrrr�test_str_subclass�sz!RegressionTests.test_str_subclasscCsTGdd�dtj�}|d�}|�tj��
|��}Wd�dS1s#wYdS)zh
        Verifies that connection methods check whether base class __init__ was
        called.
        c@rk)zJRegressionTests.test_connection_constructor_call_check.<locals>.ConnectioncSrVrr)r
�namerrrrl�rXzSRegressionTests.test_connection_constructor_call_check.<locals>.Connection.__init__Nrmrrrr�
Connection�rorwrN)rrwrIrpr�r
rwrrrrr�&test_connection_constructor_call_check�s

"�z6RegressionTests.test_connection_constructor_call_checkcs�G�fdd�dtj�}Gdd�dtj��|d�}|��}|�d�|�dgd��|�d	�|��|�tj��
|�	�Wd
�d
S1sHwYd
S)z�
        Verifies that subclassed cursor classes are correctly registered with
        the connection object, too.  (fetch-across-rollback problem)
        cr?)z<RegressionTests.test_cursor_registration.<locals>.Connectioncs�|�Srrr	�rnrrr�szCRegressionTests.test_cursor_registration.<locals>.Connection.cursorN)rDrErFrrrzrrrw�rHrwc@rk)z8RegressionTests.test_cursor_registration.<locals>.CursorcSstj�||�dSr)rrnrlr3rrrrl�szARegressionTests.test_cursor_registration.<locals>.Cursor.__init__Nrmrrrrrn�rornrzcreate table foo(x)zinsert into foo(x) values (?)))�)�)rzselect x from fooN)
rrwrnrrr%r&rIZInterfaceErrorrqrxrrzr�test_cursor_registration�s


"�z(RegressionTests.test_cursor_registrationcCstjddd�}dS)z�
        Verifies that creating a connection in autocommit mode works.
        2.5.3 introduced a regression so that these could no longer
        be created.
        rNrY)rrr3rrr�test_auto_commit�sz RegressionTests.test_auto_commitcCs4|j��}|�d�|�d�|�d�|��}dS)z�
        Verifies that running a PRAGMA statement that does an autocommit does
        work. This did not work in 2.5.3/2.5.4.
        r5r;zpragma page_sizeN)rrrrO)r
r�rowrrr�test_pragma_autocommits




z&RegressionTests.test_pragma_autocommitcCs|�t|jd�dS)z}
        Call a connection with a non-string SQL request: check error handling
        of the statement constructor.
        r_N)rIrTrr	rrr�test_connection_callsz$RegressionTests.test_connection_callcCs"dd�}|�tj|jjd|�dS)NcSsdS)Nr_r)�a�brrr�collation_cbrXz4RegressionTests.test_collation.<locals>.collation_cbu�)rIrrprZcreate_collation)r
r�rrr�test_collations�zRegressionTests.test_collationcs|t�d�}|�����d���d��fdd�}|�tj����ddd�|�D��Wd	�d	S1s7wYd	S)
z�
        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.
        rzcreate table a (bar)zcreate table b (baz)c3s���dd�dVdS)Nzinsert into a (bar) values (?))r_r_)rr�rrr�foo-s�
z6RegressionTests.test_recursive_cursor_use.<locals>.foozinsert into b (baz) values (?)css�|]}|fVqdSrr)rr(rrr�	<genexpr>3s�z<RegressionTests.test_recursive_cursor_use.<locals>.<genexpr>N)rrrrrIrpr%)r
rr�rr�r�test_recursive_cursor_use s


�"�z)RegressionTests.test_recursive_cursor_usec
Cs�tjdtjd�}|��}|�d�|�d�|�d�|�d�dd�|��D�}|�|t�d	d
d
ddd
d�t�d	d
d
ddd
d�g�dS)z�
        http://bugs.python.org/issue14720

        The microsecond parsing of convert_timestamp() should pad with zeros,
        since the microsecond string "456" actually represents "456000".
        rrzCREATE TABLE t (x TIMESTAMP)z4INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.456')z:INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.123456789')zSELECT * FROM tcSsg|]}|d�qS)rrrrrrrHr zNRegressionTests.test_convert_timestamp_microsecond_padding.<locals>.<listcomp>i�r|��ri@�i@�N)rrr<rrrqr*r=)r
rr�valuesrrr�*test_convert_timestamp_microsecond_padding5s




�z:RegressionTests.test_convert_timestamp_microsecond_paddingcCs|jttjddd�dS)Nr�{rY)rIrTrrr	rrr�!test_invalid_isolation_level_typeOs
�z1RegressionTests.test_invalid_isolation_level_typecCsRt�d�}|�t|d�|�t|d�|��}|�t|jd�|�t|jd�dS)Nrz	select 1z	select 1z
 select 2z	select 2)rrrIrfrrrrrr�test_null_characterUs
z#RegressionTests.test_null_characterc	Cs�t�d�}|�d�|�|jd�d}t|�d��D]P\}}|j||d��=|�d|f�|��|dkr>|�|dd�n|dkrK|�|dd�n|d	krW|�|dd	�|d7}Wd
�n1sewYq|�|dd�d
S)
z�
        Connection.commit() did reset cursors, which made sqlite3
        to return rows multiple times when fetched from cursors
        after commit. See issues 10513 and 23129 for details.
        rz�
        create table t(c);
        create table t2(c);
        insert into t values(0);
        insert into t values(1);
        insert into t values(2);
        r9rzselect c from t)r(rzinsert into t2(c) values (?)r_�Nr{z'should have returned exactly three rows)	rrZ
executescriptr*rZ�	enumeraterrcr1)r
rZcounterr(rrrr�test_commit_cursor_reset^s$


��
z(RegressionTests.test_commit_cursor_resetcCsBdd�}t�d�}t�|�}t�||�}|�|�~~t��dS)zm
        The interpreter shouldn't crash in case Cursor.__init__() is called
        more than once.
        cWrVrr)�argsrrr�callback�rXz/RegressionTests.test_bpo31770.<locals>.callbackrN)rrrn�weakref�refrlr�
gc_collect)r
r�rrr�rrr�
test_bpo31770}s


zRegressionTests.test_bpo31770cCs6|�t��|j`Wd�dS1swYdSr)rI�AttributeErrorrrZr	rrr�!test_del_isolation_level_segfault�s"�z1RegressionTests.test_del_isolation_level_segfaultcCsfGdd�d�}|jjtj|jjdd�|jjfD]}|�}||j�||j�|j�d�|d�qdS)Nc@rk)z.RegressionTests.test_bpo37347.<locals>.PrintercWstjSr)rZ	SQLITE_OK)r
r�rrr�log�sz2RegressionTests.test_bpo37347.<locals>.Printer.logN)rDrErFr�rrrr�Printer�ror�r_)�nzselect 1)rZset_trace_callback�	functools�partialZset_progress_handlerZset_authorizerr�r)r
r��methodZprinter_instancerrr�
test_bpo37347�s�


�zRegressionTests.test_bpo37347cCs(|j�d�}|��d}|�|d�dS)Nz
select X''rr`)rrrOr*)r
r�valrrr�test_return_empty_bytestring�sz,RegressionTests.test_return_empty_bytestringN)#rDrErFr
rrrr)r,r0r4r8r:r>rKrSrUrjrsruryr}r~r�r�r�r�r�r�r�r�r�r�r�r�rrrrr!sB
	
	
	rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�RecursiveUseOfCursorsz$Recursive use of cursors not allowedcCs@tjdtjd�|_|j��|_|j�d�|j�dddg�dS)Nrrzcreate table test(x foo)r")r�)Zbar)rrrrrrrr%r	rrrr
�s��zRecursiveUseOfCursors.setUpcCs|j��|j��dSr)rrrr	rrrr�s
zRecursiveUseOfCursors.tearDownc	��fdd�}t�tjd|i��/��tj�j���j�d�Wd�n1s)wYWd�dSWd�dS1sAwYdS)Ncs�j��j�Sr)rrlr�rr	rr�<lambda>�szBRecursiveUseOfCursors.test_recursive_cursor_init.<locals>.<lambda>ZINITz#select x as "x [INIT]", x from test�	r�dictr�
convertersrrrprRrr�r
�convrr	r�test_recursive_cursor_init����"�z0RecursiveUseOfCursors.test_recursive_cursor_initc	r�)Ncs
�j��Sr)rrr�r	rrr��s
zCRecursiveUseOfCursors.test_recursive_cursor_close.<locals>.<lambda>ZCLOSEz$select x as "x [CLOSE]", x from testr�r�rr	r�test_recursive_cursor_close�r�z1RecursiveUseOfCursors.test_recursive_cursor_closec	s�gf�fdd�	}t�tjd|i��4�j�d���tj�j��
�j�	�Wd�n1s0wYWd�dSWd�dS1sHwYdS)Ncs|r�j��S|�d�Sr)rrOr.)r�lr	rrr��szCRecursiveUseOfCursors.test_recursive_cursor_fetch.<locals>.<lambda>ZITERz#select x as "x [ITER]", x from test)
rr�rr�rrrrrprRrqr�rr	r�test_recursive_cursor_fetch�s��"�z1RecursiveUseOfCursors.test_recursive_cursor_fetchN)	rDrErFrRr
rr�r�r�rrrrr��sr�cCsttg}t�dd�|D��S)NcSsg|]	}t���|��qSr)�unittestZ
TestLoaderZloadTestsFromTestCase)r�trrrr�szsuite.<locals>.<listcomp>)rr�r�Z	TestSuite)Ztestsrrr�suite�s��r�cCst��}|�t��dSr)r�ZTextTestRunner�runr�)Zrunnerrrr�test�sr��__main__)r=r�Zsqlite3rr�r�r�rZ
unittest.mockrZTestCaserr�r�rDrrrr�<module>s"$	
�