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.7/sqlite3/test/__pycache__/hooks.cpython-37.pyc
B

��g2)�@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��WdQRXdS)Nz:memory:cSs||k||kS)N�)�x�yrr�./usr/local/lib/python3.7/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�WdQRX|�t|j�d�dS)Nz:memory:�X�*zparameter must be callable)rrr
rr�assertEqual�str�	exception)rr�cmrrr�CheckCreateCollationNotCallable#s
z.CollationTests.CheckCreateCollationNotCallablec	Cs6t�d�}|�tj��|�ddd��WdQRXdS)Nz:memory:ucolläcSs||k||kS)Nr)rrrrrr	,r
z=CollationTests.CheckCreateCollationNotAscii.<locals>.<lambda>)rrr
ZProgrammingErrorr)rrrrr�CheckCreateCollationNotAscii)s
z+CollationTests.CheckCreateCollationNotAsciicCslGdd�dt�}t�d�}dd�}|�|d�|�|�d���}|�|ddd	�|�|d
dd�dS)Nc@seZdZdd�ZdS)z@CollationTests.CheckCreateCollationBadUpper.<locals>.BadUpperStrcSsdS)Nr)rrrr�upper0szFCollationTests.CheckCreateCollationBadUpper.<locals>.BadUpperStr.upperN)�__name__�
__module__�__qualname__rrrrr�BadUpperStr/srz:memory:cSs||k||kS)Nr)rrrrrr	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)rrrr�execute�fetchallr)rrrr �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��}|�|���}WdQRX|�t|j	�d�dS)NcSs||k||kS)Nr)rrrrrr Bsz3CollationTests.CheckCollationIsUsed.<locals>.mycollz:memory:r z�
            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#z#the expected order was not returned)�msgz"no such collation sequence: mycoll)
rrrr$r%rr
�OperationalErrorrr)rr r�sqlr&rrrr�CheckCollationIsUsed?s
	z#CollationTests.CheckCollationIsUsedcCsJdd�}t�d�}|�d|�d}|�|���}|j|dddgd	d
�dS)NcSs||k||kdS)Nlr)rrrrrr [sz@CollationTests.CheckCollationReturnsLargeInteger.<locals>.mycollz:memory:r z�
            select x from (
            select 'a' as x
            union
            select 'b' as x
            union
            select 'c' as x
            ) order by x collate mycoll
            )r*)r!)r#z#the expected order was not returned)r+)rrrr$r%r)rr rr-r&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.
        z:memory:r cSs||k||kS)Nr)rrrrrr	sr
z<CollationTests.CheckCollationRegisterTwice.<locals>.<lambda>cSs||k||kS)Nr)rrrrrr	tr
zi
            select x from (select 'a' as x union select 'b' as x) order by x collate mycoll
            rr!r"r#N)rrrr$r%r)rrr&rrr�CheckCollationRegisterTwicems

z*CollationTests.CheckCollationRegisterTwicec	Cs^t�d�}|�ddd��|�dd�|�tj��}|�d�WdQRX|�t|j�d�dS)zu
        Register a collation, then deregister it. Make sure an error is raised if we try
        to use it.
        z:memory:r cSs||k||kS)Nr)rrrrrr	�r
z9CollationTests.CheckDeregisterCollation.<locals>.<lambda>Nz?select 'a' as x union select 'b' as x order by x collate mycollz"no such collation sequence: mycoll)	rrrr
r,r$rrr)rrrrrr�CheckDeregisterCollation{s
z'CollationTests.CheckDeregisterCollationN)rrrrrrr'�unittest�skipIfr�sqlite_version_infor.r/r0r1rrrrrs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.
        z:memory:cs��d�dS)Nr)�appendr)�progress_callsrr�progress�s
z8ProgressTests.CheckProgressHandlerUsed.<locals>.progressr"z0
            create table foo(a, b)
            N)rr�set_progress_handlerr$�
assertTrue)rrr8r)r7r�CheckProgressHandlerUsed�s
z&ProgressTests.CheckProgressHandlerUsedcsrt�d�}g��fdd�}|�|d�|��}|�d�t��}g�|�|d�|�d�t��}|�||�dS)	z=
        Test that the opcode argument is respected.
        z:memory:cs��d�dS)Nr)r6r)r7rrr8�s
z0ProgressTests.CheckOpcodeCount.<locals>.progressr"z1
            create table foo (a, b)
            r)z1
            create table bar (a, b)
            N)rrr9�cursorr$�lenZassertGreaterEqual)rrr8�cursZfirst_countZsecond_countr)r7r�CheckOpcodeCount�s
zProgressTests.CheckOpcodeCountcCs<t�d�}dd�}|�|d�|��}|�tj|jd�dS)zW
        Test that returning a non-zero value stops the operation in progress.
        z:memory:cSsdS)Nr"rrrrrr8�sz4ProgressTests.CheckCancelOperation.<locals>.progressr"zcreate table bar (a, b)N)rrr9r<r
r,r$)rrr8r>rrr�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.
        z:memory:rcsd�dS)Nr"rrr)�actionrrr8�sz1ProgressTests.CheckClearHandler.<locals>.progressr"Nz&select 1 union select 2 union select 3z progress handler was not cleared)rrr9r$r%r)rrr8r)rAr�CheckClearHandler�s
zProgressTests.CheckClearHandlerN)rrrr;r?r@rBrrrrr5�sr5c@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.
        z:memory:cs��|�dS)N)r6)�	statement)�traced_statementsrr�trace�sz8TraceCallbackTests.CheckTraceCallbackUsed.<locals>.tracezcreate table foo(a, b)css|]}d|kVqdS)zcreate table fooNr)�.0�stmtrrr�	<genexpr>�sz<TraceCallbackTests.CheckTraceCallbackUsed.<locals>.<genexpr>N)rr�set_trace_callbackr$r:�any)rrrFr)rEr�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.
        z:memory:cs��|�dS)N)r6)rD)rErrrF�sz9TraceCallbackTests.CheckClearTraceCallback.<locals>.traceNzcreate table foo(a, b)ztrace callback was not cleared)rrrJr$ZassertFalse)rrrFr)rEr�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öäüÖÄÜ߀z:memory:cs��|�dS)N)r6)rD)rErrrF�sz5TraceCallbackTests.CheckUnicodeContent.<locals>.tracezcreate table foo(x)z insert into foo(x) values ("%s")c3s|]}�|kVqdS)Nr)rGrH)�
unicode_valuerrrI�sz9TraceCallbackTests.CheckUnicodeContent.<locals>.<genexpr>z-Unicode data %s garbled in trace callback: %sz, N)
rrrJr$Zcommitr:rK�ascii�join�map)rrrFr)rErNr�CheckUnicodeContent�s


z&TraceCallbackTests.CheckUnicodeContent)r(r(�	z#sqlite3_prepare_v2 is not availablecs�g��fdd�}ddg}|�tt�tjtdd�}t�t�}|�|�|��}|�|d�|�d�|�|d�|��|�dS)	Ncs��|�dS)N)r6)rD)rErrrF�sz;TraceCallbackTests.CheckTraceCallbackContent.<locals>.tracezcreate table foo(x)zinsert into foo(x) values(1))Zisolation_levelrzcreate table bar(x)r")	Z
addCleanuprrrrrJr<r$r)rrFZqueriesZcon1Zcon2Zcurr)rEr�CheckTraceCallbackContent�s


z,TraceCallbackTests.CheckTraceCallbackContentN)rrrrLrMrRr2r3rr4rTrrrrrC�s

rCcCs4t�td�}t�td�}t�td�}t�|||f�S)NZCheck)r2Z	makeSuiterr5rCZ	TestSuite)Zcollation_suiteZprogress_suiteZtrace_suiterrr�suitesrUcCst��}|�t��dS)N)r2ZTextTestRunner�runrU)Zrunnerrrr�testsrW�__main__)
r2Zsqlite3rZtest.supportrrZTestCaserr5rCrUrWrrrrr�<module>sjEC