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__/hooks.cpython-310.pyc
o

�i�*�@s�ddlZddlZddlZddlmZmZGdd�dej�ZGdd�dej�Z	Gdd�dej�Z
d	d
�Zdd�Ze
d
kr@e�dSdS)�N)�TESTFN�unlinkc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�CollationTestscCsJt�d�}|�t��|�ddd��Wd�dS1swYdS)N�:memory:cS�||k||kS�N���x�yrr�//usr/local/lib/python3.10/sqlite3/test/hooks.py�<lambda>"�zACollationTests.test_create_collation_not_string.<locals>.<lambda>)�sqlite�connect�assertRaises�	TypeError�create_collation��self�conrrr� test_create_collation_not_strings
"�z/CollationTests.test_create_collation_not_stringcCsVt�d�}|�t��}|�dd�Wd�n1swY|�t|j�d�dS)Nr�X�*zparameter must be callable)rrrrr�assertEqual�str�	exception�rr�cmrrr�"test_create_collation_not_callable$s

�z1CollationTests.test_create_collation_not_callablecCsLt�d�}|�tj��|�ddd��Wd�dS1swYdS)NrucolläcSrrrr	rrrr
-rz@CollationTests.test_create_collation_not_ascii.<locals>.<lambda>)rrrZProgrammingErrorrrrrr�test_create_collation_not_ascii*s
"�z.CollationTests.test_create_collation_not_asciicCslGdd�dt�}t�d�}dd�}|�|d�|�|�d���}|�|ddd	�|�|d
dd�dS)Nc@seZdZdd�ZdS)zCCollationTests.test_create_collation_bad_upper.<locals>.BadUpperStrcSsdSrr)rrrr�upper1�zICollationTests.test_create_collation_bad_upper.<locals>.BadUpperStr.upperN)�__name__�
__module__�__qualname__r!rrrr�BadUpperStr0sr&rcS�||k||kSrrr	rrrr
4�z@CollationTests.test_create_collation_bad_upper.<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�test_create_collation_bad_upper/s
�z.CollationTests.test_create_collation_bad_uppercCs�dd�}t�d�}|�d|�d}|�|���}|j|gd�dd�|�dd�|�tj��}|�|���}Wd�n1s@wY|�t|j	�d	�dS)
NcSr'rrr	rrrr)Asz5CollationTests.test_collation_is_used.<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�test_collation_is_used@s
	��z%CollationTests.test_collation_is_usedcCsHdd�}t�d�}|�d|�d}|�|���}|j|gd�dd�dS)	NcSs||k||kdS)Nlrr	rrrr)ZszCCollationTests.test_collation_returns_large_integer.<locals>.mycollrr)r1r2r4r5�rrrr-r.r)rr)rr9r/rrr�$test_collation_returns_large_integerYs
	
�z3CollationTests.test_collation_returns_large_integercCsdt�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)cSrrrr	rrrr
rrz>CollationTests.test_collation_register_twice.<locals>.<lambda>cSr'rrr	rrrr
sr(zi
            select x from (select 'a' as x union select 'b' as x) order by x collate mycoll
            rr*r+r,Nr;)rrr/rrr�test_collation_register_twicels
�z,CollationTests.test_collation_register_twicecCsrt�d�}|�ddd��|�dd�|�tj��
}|�d�Wd�n1s)wY|�t|j�d�dS)zu
        Register a collation, then deregister it. Make sure an error is raised if we try
        to use it.
        rr)cSrrrr	rrrr
�rz:CollationTests.test_deregister_collation.<locals>.<lambda>Nz?select 'a' as x union select 'b' as x order by x collate mycollr7)	rrrrr8r-rrrrrrr�test_deregister_collationzs
�z(CollationTests.test_deregister_collationN)r#r$r%rrr r0r:r<r=r>rrrrrs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.
        rc���d�dS�Nr��appendr�Zprogress_callsrr�progress��
z:ProgressTests.test_progress_handler_used.<locals>.progressr+z0
            create table foo(a, b)
            N)rr�set_progress_handlerr-�
assertTrue�rrrErrDr�test_progress_handler_used�s

z(ProgressTests.test_progress_handler_usedcsrt�d�}g��fdd�}|�|d�|��}|�d�t��}g�|�|d�|�d�t��}|�||�dS)	z=
        Test that the opcode argument is respected.
        rcr@rArBrrDrrrE�rFz1ProgressTests.test_opcode_count.<locals>.progressr+z1
            create table foo (a, b)
            �z1
            create table bar (a, b)
            N)rrrG�cursorr-�lenZassertGreaterEqual)rrrE�cursZfirst_countZsecond_countrrDr�test_opcode_count�s


zProgressTests.test_opcode_countcCs<t�d�}dd�}|�|d�|��}|�tj|jd�dS)zW
        Test that returning a non-zero value stops the operation in progress.
        rcSsdS)Nr+rrrrrrE�r"z5ProgressTests.test_cancel_operation.<locals>.progressr+zcreate table bar (a, b)N)rrrGrLrr8r-)rrrErNrrr�test_cancel_operation�s
�z#ProgressTests.test_cancel_operationcsRt�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��actionrrrE�sz2ProgressTests.test_clear_handler.<locals>.progressr+Nz&select 1 union select 2 union select 3z progress handler was not cleared)rrrGr-r.rrIrrQr�test_clear_handler�s
z ProgressTests.test_clear_handlerN)r#r$r%rJrOrPrSrrrrr?�s
r?c@sBeZdZejdd��Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
S)�TraceCallbackTestsc
#sT�zg�|��fdd��dVW|��|�|�d�dS|��|�|�d�w)Ncs
��|�SrrB)�stmt�Ztracedrrr
�s
z5TraceCallbackTests.check_stmt_trace.<locals>.<lambda>)�set_trace_callbackr)r�cx�expectedrrVr�check_stmt_trace�s��z#TraceCallbackTests.check_stmt_tracecsTt�d�}g��fdd�}|�|�|�d�|���|�tdd��D���dS)zI
        Test that the trace callback is invoked once it is set.
        rc���|�dSrrB�Z	statement��traced_statementsrr�trace��z:TraceCallbackTests.test_trace_callback_used.<locals>.trace�create table foo(a, b)css�|]}d|vVqdS)zcreate table fooNr��.0rUrrr�	<genexpr>���z>TraceCallbackTests.test_trace_callback_used.<locals>.<genexpr>N)rrrWr-rH�any�rrr_rr]r�test_trace_callback_used�s



z+TraceCallbackTests.test_trace_callback_usedcsHt�d�}g��fdd�}|�|�|�d�|�d�|��d�dS)zb
        Test that setting the trace callback to None clears the previously set callback.
        rcr[rrBr\r]rrr_�r`z;TraceCallbackTests.test_clear_trace_callback.<locals>.traceNraztrace callback was not cleared)rrrWr-ZassertFalsergrr]r�test_clear_trace_callback�s



z,TraceCallbackTests.test_clear_trace_callbackc
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öäüÖÄÜ߀rcr[rrBr\r]rrr_�r`z6TraceCallbackTests.test_unicode_content.<locals>.trace�create table foo(x)z insert into foo(x) values ('%s')c3s�|]}�|vVqdSrrrb)�
unicode_valuerrrd�rez:TraceCallbackTests.test_unicode_content.<locals>.<genexpr>z-Unicode data %s garbled in trace callback: %sz, N)
rrrWr-ZcommitrHrf�ascii�join�maprgr)r^rkr�test_unicode_content�s


��z'TraceCallbackTests.test_unicode_contentcs�g��fdd�}ddg}|�tt�tjtdd�}t�t�}|�|�|��}|�|d�|�d�|�|d�|��|�dS)	Ncr[rrBr\r]rrr_r`z=TraceCallbackTests.test_trace_callback_content.<locals>.tracerjzinsert into foo(x) values(1))Zisolation_levelrzcreate table bar(x)r+)	Z
addCleanuprrrrrWrLr-r)rr_ZqueriesZcon1Zcon2Zcurrr]r�test_trace_callback_contents�


z.TraceCallbackTests.test_trace_callback_contentc	Cs�gd�}t�d�}|�||��5|�|�d�|�ddd�td�D��Wd�n1s/wYWd�dSWd�dS1sGwYdS)N)�create table t(t)zBEGIN zinsert into t values(0)zinsert into t values(1)zinsert into t values(2)ZCOMMITrrqzinsert into t values(?)css�|]}|fVqdSrr)rc�vrrrrd s�z=TraceCallbackTests.test_trace_expanded_sql.<locals>.<genexpr>�)rrrZr-Zexecutemany�range)rrYrXrrr�test_trace_expanded_sqls

��"�z*TraceCallbackTests.test_trace_expanded_sqlN)r#r$r%�
contextlib�contextmanagerrZrhrirorprurrrrrT�s
	

rTcCstttg}t�dd�|D��S)NcSsg|]	}t���|��qSr)�unittestZ
TestLoaderZloadTestsFromTestCase)rc�trrr�
<listcomp>*szsuite.<locals>.<listcomp>)rr?rTrxZ	TestSuite)Ztestsrrr�suite#s��r{cCst��}|�t��dSr)rxZTextTestRunner�runr{)Zrunnerrrr�test-sr}�__main__)rvrxZsqlite3rZtest.support.os_helperrrZTestCaserr?rTr{r}r#rrrr�<module>shEX

�