Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/test/test_sqlite3/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/test/test_sqlite3/__pycache__/test_hooks.cpython-312.opt-1.pyc

�

)Μg�2����ddlZddlZddlZddlmZmZddlmZm	Z	ddl
mZGd�dej�Z
Gd�dej�ZGd	�d
ej�Zedk(rej"�yy)�N)�TESTFN�unlink)�memory_database�cx_limit)�with_tracebacksc�<�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)
�CollationTestsc��tjd�}|jt�5|j	dd��ddd�y#1swYyxYw)N�:memory:c��||kD||kz
S�N���x�ys  �9/usr/local/lib/python3.12/test/test_sqlite3/test_hooks.py�<lambda>zACollationTests.test_create_collation_not_string.<locals>.<lambda>%���Q��U�q�1�u�4E�)�sqlite�connect�assertRaises�	TypeError�create_collation��self�cons  r� test_create_collation_not_stringz/CollationTests.test_create_collation_not_string"s;���n�n�Z�(��
�
�
�y�
)�� � ��'E�F�*�
)�
)�s�A�Ac���tjd�}|jt�5}|j	dd�ddd�|jt
j�d�y#1swY�/xYw)Nr�X�*zparameter must be callable)rrrrr�assertEqual�str�	exception�rr�cms   r�"test_create_collation_not_callablez1CollationTests.test_create_collation_not_callable'sX���n�n�Z�(��
�
�
�y�
)�R�� � ��b�)�*�����R�\�\�*�,H�I�*�
)�s�A,�,A5c�T�tjd�}|jdd��y)Nrucolläc��||kD||kz
Sr
rrs  rrz@CollationTests.test_create_collation_not_ascii.<locals>.<lambda>/rr)rrrrs  r�test_create_collation_not_asciiz.CollationTests.test_create_collation_not_ascii-s!���n�n�Z�(�����X�'E�Frc� �Gd�dt�}tjd�}d�}|j|d�|�|j	d�j�}|j
|ddd�|j
|d	dd
�y)Nc��eZdZd�Zy)�CCollationTests.test_create_collation_bad_upper.<locals>.BadUpperStrc��yr
r�rs r�upperzICollationTests.test_create_collation_bad_upper.<locals>.BadUpperStr.upper3s��rN)�__name__�
__module__�__qualname__r0rrr�BadUpperStrr-2s��
rr4rc��||kD||kz
Sr
rrs  rrz@CollationTests.test_create_collation_bad_upper.<locals>.<lambda>6s���Q��1�q�5� 1�2r�mycollz�
            select x from (
            select 'a' as x
            union
            select 'b' as x
            ) order by x collate mycoll
            r�b��a)r#rrr�execute�fetchallr")rr4rr6�results     r�test_create_collation_bad_upperz.CollationTests.test_create_collation_bad_upper1s���	�#�	��n�n�Z�(��2�����[��2�F�;���������
	�	
������1��s�+�������1��s�+rc���d�}tjd�}|jd|�d}|j|�j	�}|j|gd�d��|jdd�|j
tj�5}|j|�j	�}ddd�|jtj�d�y#1swY�/xYw)	Nc��||kD||kz
Sr
rrs  rr6z5CollationTests.test_collation_is_used.<locals>.mycollCs���!�e��A��&�'�'rrr6��
            select x from (
            select 'a' as x
            union
            select 'b' as x
            union
            select 'c' as x
            ) order by x collate mycoll
            �)�c)r7)r9�#the expected order was not returned��msg�"no such collation sequence: mycoll)
rrrr:r;r"r�OperationalErrorr#r$)rr6r�sqlr<r&s      r�test_collation_is_usedz%CollationTests.test_collation_is_usedBs���	(��n�n�Z�(�����X�v�.������S�!�*�*�,������!9�B�	�	D�	���X�t�,�
�
�
�v�6�6�
7�2��[�[��%�.�.�0�F�8�����R�\�\�*�,P�Q�8�
7�s� C!�!C*c���d�}tjd�}|jd|�d}|j|�j	�}|j|gd�d��y)Nc� �||kD||kz
dzS)Nlrrs  rr6zCCollationTests.test_collation_returns_large_integer.<locals>.mycoll\s���!�e��A��&�'�%�/�/rrr6r@rArCrD�rrrr:r;r")rr6rrHr<s     r�$test_collation_returns_large_integerz3CollationTests.test_collation_returns_large_integer[sc��	0��n�n�Z�(�����X�v�.������S�!�*�*�,������!9�B�	�	Drc��tjd�}|jdd��|jdd��|jd�j	�}|j|ddd�|j|ddd	�y
)z�
        Register two different collation functions under the same name.
        Verify that the last one is actually used.
        rr6c��||kD||kz
Sr
rrs  rrz>CollationTests.test_collation_register_twice.<locals>.<lambda>trrc��||kD||kz
Sr
rrs  rrz>CollationTests.test_collation_register_twice.<locals>.<lambda>us��q�1�u��Q��6G�4Hrzi
            select x from (select 'a' as x union select 'b' as x) order by x collate mycoll
            rr7r8r9NrL)rrr<s   r�test_collation_register_twicez,CollationTests.test_collation_register_twicens���
�n�n�Z�(�����X�'E�F����X�'H�I���������	�	
������1��s�+�������1��s�+rc�L�tjd�}|jdd��|jdd�|jtj�5}|jd�ddd�|j
tj�d�y#1swY�/xYw)zu
        Register a collation, then deregister it. Make sure an error is raised if we try
        to use it.
        rr6c��||kD||kz
Sr
rrs  rrz:CollationTests.test_deregister_collation.<locals>.<lambda>�rrNz?select 'a' as x union select 'b' as x order by x collate mycollrF)	rrrrrGr:r"r#r$r%s   r�test_deregister_collationz(CollationTests.test_deregister_collation|s~��
�n�n�Z�(�����X�'E�F����X�t�,�
�
�
�v�6�6�
7�2��K�K�Y�Z�8�����R�\�\�*�,P�Q�8�
7�s�B�B#N)r1r2r3rr'r*r=rIrMrQrTrrrr	r	!s0��G�
J�G�,�"R�2D�&,�
Rrr	c�d�eZdZd�Zd�Zd�Zd�Zeed��d��Z	eed��d��Z
y	)
�
ProgressTestsc���tjd�}g��fd�}|j|d�|jd�|j	��y)zK
        Test that the progress handler is invoked once it is set.
        rc�(���jd�y�Nr��append��progress_callss�r�progressz:ProgressTests.test_progress_handler_used.<locals>.progress������!�!�$�'�rr8z0
            create table foo(a, b)
            N)rr�set_progress_handlerr:�
assertTrue)rrr^r]s   @r�test_progress_handler_usedz(ProgressTests.test_progress_handler_used�sN����n�n�Z�(����	�	� � ��1�-�����	�	
����'rc�>��tjd�}g��fd�}|j|d�|j�}|j	d�t��}g�|j|d�|j	d�t��}|j
||�y)z=
        Test that the opcode argument is respected.
        rc�(���jd�yrYrZr\s�rr^z1ProgressTests.test_opcode_count.<locals>.progress�r_rr8z1
            create table foo (a, b)
            �z1
            create table bar (a, b)
            N)rrr`�cursorr:�len�assertGreaterEqual)rrr^�curs�first_count�second_countr]s      @r�test_opcode_countzProgressTests.test_opcode_count�s�����n�n�Z�(����	�	� � ��1�-��z�z�|������	��.�)����� � ��1�-�����	��>�*������\�:rc���tjd�}d�}|j|d�|j�}|j	tj
|jd�y)zW
        Test that returning a non-zero value stops the operation in progress.
        rc��y)Nr8rrrrr^z5ProgressTests.test_cancel_operation.<locals>.progress�s��rr8zcreate table bar (a, b)N)rrr`rfrrGr:)rrr^ris    r�test_cancel_operationz#ProgressTests.test_cancel_operation�sS���n�n�Z�(��	�� � ��1�-��z�z�|������#�#��L�L�%�	'rc����tjd�}d��fd�}|j|d�|jdd�|jd�j	�|j�dd�y)zc
        Test that setting the progress handler to None clears the previously set handler.
        rrc�
��d�y�Nr8rr)�actions�rr^z2ProgressTests.test_clear_handler.<locals>.progress�s����F�rr8Nz&select 1 union select 2 union select 3z progress handler was not cleared)rrr`r:r;r")rrr^rss   @r�test_clear_handlerz ProgressTests.test_clear_handler�sh����n�n�Z�(����	�	� � ��1�-�� � ��q�)����<�=�F�F�H������$F�Gr�bad_progress)�namec���tjd�}d�}|j|d�|jtj�5|jd�ddd�y#1swYyxYw)Nrc��ddzyrrrrrrruzBProgressTests.test_error_in_progress_handler.<locals>.bad_progress�s	��
��Err8�8
                create table foo(a, b)
                �rrr`rrGr:)rrrus   r�test_error_in_progress_handlerz,ProgressTests.test_error_in_progress_handler�sV���n�n�Z�(��	�� � ��q�1�
�
�
�v�6�6�
7��K�K��
�8�
7�
7�s�
A%�%A.c���tjd�}Gd�d���fd�}|j|d�|jtj�5|jd�ddd�y#1swYyxYw)Nrc��eZdZd�Zy)�DProgressTests.test_error_in_progress_handler_result.<locals>.BadBoolc��ddzyrrrr/s r�__bool__zMProgressTests.test_error_in_progress_handler_result.<locals>.BadBool.__bool__�s	���A�rN)r1r2r3r�rrr�BadBoolr~�s��
rr�c�����Sr
r)r�s�rruzIProgressTests.test_error_in_progress_handler_result.<locals>.bad_progress�s����9�rr8ryrz)rrrur�s   @r�%test_error_in_progress_handler_resultz3ProgressTests.test_error_in_progress_handler_result�sa����n�n�Z�(��	�	�	�� � ��q�1�
�
�
�v�6�6�
7��K�K��
�8�
7�
7�s�A2�2A;N)r1r2r3rbrlrortr�ZeroDivisionErrorr{r�rrrrVrV�sO��
(�;�.'�
H��&�^�<��=���&�^�<��=�rrVc��eZdZejd��Zd�Zd�Zd�Zd�Z	d�Z
eejd��d	��Zeed
��d��Zy)
�TraceCallbackTestsc#���K�	g�|j�fd��d��|j�|�|jd�y#|j�|�|jd�wxYw�w)Nc�&���j|�Sr
rZ)�stmt�traceds �rrz5TraceCallbackTests.check_stmt_trace.<locals>.<lambda>�s���v�}�}�T�/Br)�set_trace_callbackr")r�cx�expectedr�s   @r�check_stmt_tracez#TraceCallbackTests.check_stmt_trace�sb�����	(��F��!�!�"B�C�����V�X�.��!�!�$�'��
���V�X�.��!�!�$�'�s�A+�A�$A+�%A(�(A+c����tjd�}g��fd�}|j|�|jd�|j	��|j	td��D���y)zI
        Test that the trace callback is invoked once it is set.
        rc�(���j|�yr
rZ��	statement�traced_statementss �r�tracez:TraceCallbackTests.test_trace_callback_used.<locals>.trace������$�$�Y�/r�create table foo(a, b)c3�$K�|]}d|v���
y�w)zcreate table fooNr)�.0r�s  r�	<genexpr>z>TraceCallbackTests.test_trace_callback_used.<locals>.<genexpr>�s����U�CT�4�.�$�6�CT�s�N)rrr�r:ra�any�rrr�r�s   @r�test_trace_callback_usedz+TraceCallbackTests.test_trace_callback_used�s^����n�n�Z�(����	0����u�%����,�-����)�*�����U�CT�U�U�Vrc����tjd�}g��fd�}|j|�|jd�|jd�|j	�d�y)zb
        Test that setting the trace callback to None clears the previously set callback.
        rc�(���j|�yr
rZr�s �rr�z;TraceCallbackTests.test_clear_trace_callback.<locals>.tracer�rNr�ztrace callback was not cleared)rrr�r:�assertFalser�s   @r�test_clear_trace_callbackz,TraceCallbackTests.test_clear_trace_callback�sY����n�n�Z�(����	0����u�%����t�$����,�-����*�,L�Mrc�p���d�tjd�}g��fd�}|j|�|jd�|jd�z�|j	�|jt
�fd��D��dt���dd	jtt������y
)zG
        Test that the statement can contain unicode literals.
        uöäüÖÄÜ߀rc�(���j|�yr
rZr�s �rr�z6TraceCallbackTests.test_unicode_content.<locals>.tracer�r�create table foo(x)z insert into foo(x) values ('%s')c3�&�K�|]}�|v���
y�wr
r)r�r��
unicode_values  �rr�z:TraceCallbackTests.test_unicode_content.<locals>.<genexpr>s�����P�>O�d�M�T�1�>O�s�z
Unicode data z garbled in trace callback: z, N)
rrr�r:�commitrar��ascii�join�map)rrr�r�r�s   @@r�test_unicode_contentz'TraceCallbackTests.test_unicode_contents����=�
��n�n�Z�(����	0����u�%����)�*����6��F�G��
�
������P�>O�P�P� ��/����3�u�FW�;X�1Y�[�	\rc���g��fd�}ddg}|jtt�tjtd��}tjt�}	|j|�|j
�}|j|d�|jd�|j|d�|j�|j�|j�|�y#|j�|j�wxYw)Nc�(���j|�yr
rZr�s �rr�z=TraceCallbackTests.test_trace_callback_content.<locals>.tracer�rr�zinsert into foo(x) values(1))�isolation_levelrzcreate table bar(x)r8)
�
addCleanuprrrrr�rfr:�closer")rr��queries�con1�con2�curr�s      @r�test_trace_callback_contentz.TraceCallbackTests.test_trace_callback_contents������	0�)�1�3�������'��~�~�f�d�;���~�~�f�%��	��#�#�E�*��+�+�-�C��K�K���
�#��L�L�.�/��K�K���
�#��J�J�L��J�J�L����*�G�4��
�J�J�L��J�J�L�s
�AC)�)"Dc
�,�gd�}t�5}|j||�5|5|jd�|jdd�t	d�D��ddd�ddd�ddd�y#1swY�xYw#1swY�xYw#1swYyxYw)N)�create table t(t)zBEGIN zinsert into t values(0)zinsert into t values(1)zinsert into t values(2)�COMMITr�zinsert into t values(?)c3�"K�|]}|f���	y�wr
r)r��vs  rr�z=TraceCallbackTests.test_trace_expanded_sql.<locals>.<genexpr>>s����:R��A�A�4��s�
�)rr�r:�executemany�range)rr�r�s   r�test_trace_expanded_sqlz*TraceCallbackTests.test_trace_expanded_sql2ss��
���
�"�d�&;�&;�B��&I���
�
�.�/����8�:R��q��:R�S��'J�
�
����'J�&I��
�
�s9�B
�A>�4A2�A>�!B
�2A;�7A>�>B	�B
�
Bz5Expanded SQL string exceeds the maximum string length)�regexc���d}tj}t�5}t||��5}d}d|z}|dz}|g}tjdkrg}|j||�5|j
||f�ddd�|�d|�d�}	|j||	g�5|j
||f�ddd�ddd�ddd�y#1swY�QxYw#1swY�&xYw#1swY�*xYw#1swYyxYw)Nzselect 1 as a where a=)�categoryr9�?)r��r�')r�SQLITE_LIMIT_LENGTHrr�sqlite_version_infor�r:)
r�templater�r��lim�ok_param�	bad_param�unexpanded_queryr��expanded_querys
          r� test_trace_too_much_expanded_sqlz3TraceCallbackTests.test_trace_too_much_expanded_sql@s���,���-�-��
�
�"�h�r�H�&E���H��c�	�I�'�#�~��(�)�H��)�)�J�6����&�&�r�8�4��
�
�+�i�\�:�5�!)�z��8�*�A�6�N��&�&�r�N�+;�<��
�
�+�h�[�9�=�'F�
�
�5�4��=�<��'F�&E��
�
�sR�C*�7C�"C�6#C�C�-C�5C*�C�C�C�C�C'	�#C*�*C3zdivision by zeroc��t�5}|jd��|jd�ddd�y#1swYyxYw)Nc��ddzS)N�rr)r�s rrz;TraceCallbackTests.test_trace_bad_handler.<locals>.<lambda>]s��q��srzselect 1)rr�r:)rr�s  r�test_trace_bad_handlerz)TraceCallbackTests.test_trace_bad_handlerZs1��
�
�"��!�!�"2�3��J�J�z�"��
�
�s	�$8�AN)r1r2r3�
contextlib�contextmanagerr�r�r�r�r�r�rr�	DataErrorr�r�r�rrrr�r��sz�����(��(�W�N�\�"5�,T�����E��:�	�:�,�&�.@�A�#�B�#rr��__main__)r��sqlite3r�unittest�test.support.os_helperrr�test.test_sqlite3.test_dbapirr�$test.test_sqlite3.test_userfunctionsr�TestCaser	rVr�r1�mainrrr�<module>r�st��.���1�B�@�eR�X�&�&�eR�N[�H�%�%�[�|x#��*�*�x#�v�z���H�M�M�O�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists