Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/sqlite3/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/sqlite3/test/__pycache__/hooks.cpython-38.pyc
U

?��gz*�@sxddlZddlZddlmZmZGdd�dej�ZGdd�dej�ZGdd�dej�Z	d	d
�Z
dd�Zed
krte�dS)�N)�TESTFN�unlinkc@s^eZdZdd�Zdd�Zdd�Zdd�Ze�e	j
d	kd
�dd��Zd
d�Zdd�Z
dd�ZdS)�CollationTestsc	Cs4t�d�}|�t��|�ddd��W5QRXdS)N�:memory:cSs||k||kS�N���x�yrr�1/opt/cppython/lib/python3.8/sqlite3/test/hooks.py�<lambda>!�z>CollationTests.CheckCreateCollationNotString.<locals>.<lambda>)�sqlite�connect�assertRaises�	TypeError�create_collation��self�conrrr�CheckCreateCollationNotStrings
z,CollationTests.CheckCreateCollationNotStringc	CsBt�d�}|�t��}|�dd�W5QRX|�t|j�d�dS)Nr�X�*zparameter must be callable)rrrrr�assertEqual�str�	exception�rr�cmrrr�CheckCreateCollationNotCallable#s
z.CollationTests.CheckCreateCollationNotCallablec	Cs6t�d�}|�tj��|�ddd��W5QRXdS)NrucolläcSs||k||kSrrrrrrr,r
z=CollationTests.CheckCreateCollationNotAscii.<locals>.<lambda>)rrrZProgrammingErrorrrrrr�CheckCreateCollationNotAscii)s
z+CollationTests.CheckCreateCollationNotAsciicCslGdd�dt�}t�d�}dd�}|�|d�|�|�d���}|�|ddd	�|�|d
dd�dS)Nc@seZdZdd�ZdS)z@CollationTests.CheckCreateCollationBadUpper.<locals>.BadUpperStrcSsdSrr)rrrr�upper0szFCollationTests.CheckCreateCollationBadUpper.<locals>.BadUpperStr.upperN)�__name__�
__module__�__qualname__r rrrr�BadUpperStr/sr$rcSs||k||kSrrrrrrr3r
z=CollationTests.CheckCreateCollationBadUpper.<locals>.<lambda>�mycollz�
            select x from (
            select 'a' as x
            union
            select 'b' as x
            ) order by x collate mycoll
            r�b��a)rrrr�execute�fetchallr)rr$rr%�resultrrr�CheckCreateCollationBadUpper.s
z+CollationTests.CheckCreateCollationBadUpper)��r'z&old SQLite versions crash on this testc	Cs�dd�}t�d�}|�d|�d}|�|���}|j|dddgd	d
�|�dd�|�tj��}|�|���}W5QRX|�t|j	�d�dS)NcSs||k||kSrrrrrrr%Bsz3CollationTests.CheckCollationIsUsed.<locals>.mycollrr%��
            select x from (
            select 'a' as x
            union
            select 'b' as x
            union
            select 'c' as x
            ) order by x collate mycoll
            ��c�r&�r(�#the expected order was not returned��msg�"no such collation sequence: mycoll)
rrrr)r*rr�OperationalErrorrr)rr%r�sqlr+rrrr�CheckCollationIsUsed?s
	�z#CollationTests.CheckCollationIsUsedcCsJdd�}t�d�}|�d|�d}|�|���}|j|dddgd	d
�dS)NcSs||k||kdS)Nlrrrrrr%[sz@CollationTests.CheckCollationReturnsLargeInteger.<locals>.mycollrr%r/r0r2r3r4r5�rrrr)r*r)rr%rr9r+rrr�!CheckCollationReturnsLargeIntegerZs
	�z0CollationTests.CheckCollationReturnsLargeIntegercCsdt�d�}|�ddd��|�ddd��|�d���}|�|ddd�|�|d	dd
�dS)z�
        Register two different collation functions under the same name.
        Verify that the last one is actually used.
        rr%cSs||k||kSrrrrrrrsr
z<CollationTests.CheckCollationRegisterTwice.<locals>.<lambda>cSs||k||kSrrrrrrrtr
zi
            select x from (select 'a' as x union select 'b' as x) order by x collate mycoll
            rr&r'r(Nr;)rrr+rrr�CheckCollationRegisterTwicems
z*CollationTests.CheckCollationRegisterTwicec	Cs^t�d�}|�ddd��|�dd�|�tj��}|�d�W5QRX|�t|j�d�dS)zu
        Register a collation, then deregister it. Make sure an error is raised if we try
        to use it.
        rr%cSs||k||kSrrrrrrr�r
z9CollationTests.CheckDeregisterCollation.<locals>.<lambda>Nz?select 'a' as x union select 'b' as x order by x collate mycollr7)	rrrrr8r)rrrrrrr�CheckDeregisterCollation{s
z'CollationTests.CheckDeregisterCollationN)r!r"r#rrrr,�unittest�skipIfr�sqlite_version_infor:r<r=r>rrrrrs�
rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
ProgressTestscs>t�d�}g��fdd�}|�|d�|�d�|���dS)zK
        Test that the progress handler is invoked once it is set.
        rcs��d�dS�Nr��appendr�Zprogress_callsrr�progress�s
z8ProgressTests.CheckProgressHandlerUsed.<locals>.progressr'z0
            create table foo(a, b)
            N)rr�set_progress_handlerr)�
assertTrue�rrrGrrFr�CheckProgressHandlerUsed�s

z&ProgressTests.CheckProgressHandlerUsedcsrt�d�}g��fdd�}|�|d�|��}|�d�t��}g�|�|d�|�d�t��}|�||�dS)	z=
        Test that the opcode argument is respected.
        rcs��d�dSrCrDrrFrrrG�s
z0ProgressTests.CheckOpcodeCount.<locals>.progressr'z1
            create table foo (a, b)
            r.z1
            create table bar (a, b)
            N)rrrH�cursorr)�lenZassertGreaterEqual)rrrG�cursZfirst_countZsecond_countrrFr�CheckOpcodeCount�s


zProgressTests.CheckOpcodeCountcCs<t�d�}dd�}|�|d�|��}|�tj|jd�dS)zW
        Test that returning a non-zero value stops the operation in progress.
        rcSsdS)Nr'rrrrrrG�sz4ProgressTests.CheckCancelOperation.<locals>.progressr'zcreate table bar (a, b)N)rrrHrLrr8r))rrrGrNrrr�CheckCancelOperation�s
�z"ProgressTests.CheckCancelOperationcsRt�d�}d��fdd�}|�|d�|�dd�|�d���|��dd�dS)	zc
        Test that setting the progress handler to None clears the previously set handler.
        rrcsd�dS)Nr'rrr��actionrrrG�sz1ProgressTests.CheckClearHandler.<locals>.progressr'Nz&select 1 union select 2 union select 3z progress handler was not cleared)rrrHr)r*rrJrrQr�CheckClearHandler�s
zProgressTests.CheckClearHandlerN)r!r"r#rKrOrPrSrrrrrB�srBc@s>eZdZdd�Zdd�Zdd�Ze�ej	dkd�d	d
��Z
dS)�TraceCallbackTestscsTt�d�}g��fdd�}|�|�|�d�|���|�tdd��D���dS)zI
        Test that the trace callback is invoked once it is set.
        rcs��|�dSrrD�Z	statement��traced_statementsrr�trace�sz8TraceCallbackTests.CheckTraceCallbackUsed.<locals>.trace�create table foo(a, b)css|]}d|kVqdS)zcreate table fooNr��.0Zstmtrrr�	<genexpr>�sz<TraceCallbackTests.CheckTraceCallbackUsed.<locals>.<genexpr>N)rr�set_trace_callbackr)rI�any�rrrXrrVr�CheckTraceCallbackUsed�s



z)TraceCallbackTests.CheckTraceCallbackUsedcsHt�d�}g��fdd�}|�|�|�d�|�d�|��d�dS)zb
        Test that setting the trace callback to None clears the previously set callback.
        rcs��|�dSrrDrUrVrrrX�sz9TraceCallbackTests.CheckClearTraceCallback.<locals>.traceNrYztrace callback was not cleared)rrr]r)ZassertFalser_rrVr�CheckClearTraceCallback�s



z*TraceCallbackTests.CheckClearTraceCallbackc
s�d�t�d�}g��fdd�}|�|�|�d�|�d��|��|�t�fdd��D��d	t��d
�t	t���f�dS)zG
        Test that the statement can contain unicode literals.
        uöäüÖÄÜ߀rcs��|�dSrrDrUrVrrrX�sz5TraceCallbackTests.CheckUnicodeContent.<locals>.trace�create table foo(x)z insert into foo(x) values ("%s")c3s|]}�|kVqdSrrrZ)�
unicode_valuerrr\�sz9TraceCallbackTests.CheckUnicodeContent.<locals>.<genexpr>z-Unicode data %s garbled in trace callback: %sz, N)
rrr]r)ZcommitrIr^�ascii�join�mapr_r)rWrcr�CheckUnicodeContent�s


��z&TraceCallbackTests.CheckUnicodeContent)r-r-�	z#sqlite3_prepare_v2 is not availablecs�g��fdd�}ddg}|�tt�tjtdd�}t�t�}|�|�|��}|�|d�|�d�|�|d�tjd	kr�|�	|d
�|�
�|�dS)Ncs��|�dSrrDrUrVrrrX�sz;TraceCallbackTests.CheckTraceCallbackContent.<locals>.tracerbzinsert into foo(x) values(1))Zisolation_levelrzcreate table bar(x)r')r-�����)Z
addCleanuprrrrr]rLr)rArEr)rrXZqueriesZcon1Zcon2ZcurrrVr�CheckTraceCallbackContent�s �



z,TraceCallbackTests.CheckTraceCallbackContentN)r!r"r#r`rargr?r@rrArlrrrrrT�s


rTcCs4t�td�}t�td�}t�td�}t�|||f�S)NZCheck)r?Z	makeSuiterrBrTZ	TestSuite)Zcollation_suiteZprogress_suiteZtrace_suiterrr�suitesrmcCst��}|�t��dSr)r?ZTextTestRunner�runrm)Zrunnerrrr�testsro�__main__)
r?Zsqlite3rZtest.supportrrZTestCaserrBrTrmror!rrrr�<module>sjEK

F1le Man4ger