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_cli.cpython-312.opt-1.pyc

�

)Μg�����dZddlZddlZddlmZddlmZmZddl	m
Z
mZmZGd�dej�ZGd�d	ej�Zed
k(rej�yy)zsqlite3 CLI tests.�N)�main)�TESTFN�unlink)�captured_stdout�captured_stderr�captured_stdinc�H�eZdZdd�d�Zd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zy)
�CommandLineInterfaceT)�expect_successc�R�t�5}t�5}|jt�5}t	|�ddd�ddd�ddd�j�j�jjfS#1swY�NxYw#1swY�RxYw#1swY�VxYw)N)rr�assertRaises�
SystemExit�cli�getvalue�	exception�code)�selfr�args�out�err�cms      �7/usr/local/lib/python3.12/test/test_sqlite3/test_cli.py�_do_testzCommandLineInterface._do_testsx�����������j�)�R���I�
*�
�
�
�|�|�~�s�|�|�~�r�|�|�/@�/@�@�@�
*�)��
���
��s8�B�B�B�B�B�B�
B�B	�B�B&c	��|j|�\}}}|j|ddjd|��||g��|j|d�|S)Nr�
�Unexpected failure: args=�)r�assertEqual�join�rrrrrs     rrz#CommandLineInterface.expect_successs[��&�����-���S�$�����q����&@�4�'�$B�C��#M�N�	P�����b�!��
�c	��|j|ddi�\}}}|j|ddjd|��||g��|j|d�|S)NrFrrrr)r�assertNotEqualrrr s     r�expect_failurez#CommandLineInterface.expect_failures`��&�����C�U�C���S�$����D�!� �I�I�)C�d�W�'E�s�C�&P�Q�	S�����b�!��
r!c�J�|jd�}|jd|�y)Nz-hzusage: python -m sqlite3�r�assertIn�rrs  r�
test_cli_helpz"CommandLineInterface.test_cli_help#s!���!�!�$�'���
�
�0�#�6r!c�f�|jd�}|jtj|�y)Nz-v)rr'�sqlite3�sqlite_versionr(s  r�test_cli_versionz%CommandLineInterface.test_cli_version's&���!�!�$�'���
�
�g�,�,�c�2r!c�L�|jdd�}|jd|�y)N�:memory:zselect 1z(1,)r&r(s  r�test_cli_execute_sqlz)CommandLineInterface.test_cli_execute_sql+s"���!�!�*�j�9���
�
�f�c�"r!c�P�|jdd�}d}|j||�y)Nr/zselect 1; select 2z>ProgrammingError: You can only execute one statement at a time�r$r')r�stderrrs   r�test_cli_execute_too_much_sqlz2CommandLineInterface.test_cli_execute_too_much_sql/s(���$�$�Z�1E�F��N���
�
�c�6�"r!c�L�|jdd�}|jd|�y)Nr/�sel�OperationalError (SQLITE_ERROR)r2)rr3s  r�test_cli_execute_incomplete_sqlz4CommandLineInterface.test_cli_execute_incomplete_sql4s#���$�$�Z��7���
�
�7��@r!c���|jtt�|jtd�}|j	|d�|jtd�}|jd|�y)Nzcreate table t(t)rzselect count(t) from tz(0,))�
addCleanuprrrrr'r(s  r�test_cli_on_disk_dbz(CommandLineInterface.test_cli_on_disk_db8sT�������'��!�!�&�*=�>������b�!��!�!�&�*B�C���
�
�f�c�"r!N)�__name__�
__module__�__qualname__rrr$r)r-r0r4r8r;�r!rr
r

s4��-1�A���7�3�#�#�
A�#r!r
c�T�eZdZdZdZdZdd�d�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zy)�InteractiveSessionz+Connected to a transient in-memory databasezsqlite> z... r?��commandsc
�&�t�5}t�5}t�5}|jt�5}|D]}|j|dz��|j
d�t|�ddd�ddd�ddd�ddd�j�}j�}	|jjjdd|�d|�d|	���||	fS#1swY�uxYw#1swY�yxYw#1swY�}xYw#1swY��xYw)Nrrr)rrrr
r�write�seekrrrrr)
rrCr�stdin�stdoutr3r�cmdrrs
          r�run_clizInteractiveSession.run_cliEs���������������j�)�R������C�$�J�'� ��J�J�q�M���I�
*�
�
�
��o�o����o�o���������*�*�A�5��w�b���R��u�E�	G��C�x��
*�)��
���
���
��sP�D�C;�C/�8C#	�/C/�7C;�?D�#C,
�(C/�/C8�4C;�;D	�D�Dc��|j�\}}|j|j|�|j|j|�|j|j	|j
��|j
|j|j
�d�|j
|j|j�d�y)N�r�	rJr'�
MEMORY_DB_MSG�
assertTrue�endswith�PS1r�count�PS2�rrrs   r�
test_interactz InteractiveSession.test_interactWs����<�<�>���S��
�
�d�(�(�#�.��
�
�d�(�(�#�.�������T�X�X�.�/�������4�8�8�,�a�0�������4�8�8�,�a�0r!c�f�|jd��\}}|j|j|�|j|j	|j
��|j
|j|j
�d�|j
|j|j�d�y)N)z.quitrBrLrrMrTs   r�test_interact_quitz%InteractiveSession.test_interact_quit_s}���<�<��<�4���S��
�
�d�(�(�#�.�������T�X�X�.�/�������4�8�8�,�a�0�������4�8�8�,�a�0r!c���|jd��\}}|j|j|�|jtjdz|�|j|j
|j��|j|j|j�d�|j|j|j�d�|jtj|�y)N)z.versionrBr�r)rJr'rNr+r,rOrPrQrrRrSrTs   r�test_interact_versionz(InteractiveSession.test_interact_versionfs����<�<��<�7���S��
�
�d�(�(�#�.��
�
�g�,�,�t�3�S�9�������T�X�X�.�/�������4�8�8�,�a�0�������4�8�8�,�a�0��
�
�g�,�,�c�2r!c��|jd��\}}|j|j|�|jd|�|j|j	|j
��|j
|j|j
�d�|j
|j|j�d�y)N)z	SELECT 1;rB�(1,)
rYrrMrTs   r�test_interact_valid_sqlz*InteractiveSession.test_interact_valid_sqlos����<�<��<�8���S��
�
�d�(�(�#�.��
�
�h��$�������T�X�X�.�/�������4�8�8�,�a�0�������4�8�8�,�a�0r!c�f�|jd��\}}|j|j|�|j|j	|j
��|j
|j|j�d�|j
|j|j
�d�y)N)zSELECT 1rBrL)	rJr'rNrOrPrSrrRrQrTs   r�&test_interact_incomplete_multiline_sqlz9InteractiveSession.test_interact_incomplete_multiline_sqlws}���<�<��<�7���S��
�
�d�(�(�#�.�������T�X�X�.�/�������4�8�8�,�a�0�������4�8�8�,�a�0r!c���|jd��\}}|j|j|�|j|j|�|jd|�|j	|j|j��|j|j|j�d�|j|j|j�d�y)N)z
SELECT 1
;rBr\rYrL)	rJr'rNrSrOrPrQrrRrTs   r�!test_interact_valid_multiline_sqlz4InteractiveSession.test_interact_valid_multiline_sql~s����<�<�)9�<�:���S��
�
�d�(�(�#�.��
�
�d�h�h��$��
�
�h��$�������T�X�X�.�/�������4�8�8�,�a�0�������4�8�8�,�a�0r!c��|jd��\}}|j|j|�|jd|�|j|j	|j
��|j
|j|j
�d�|j
|j|j�d�y)N)zsel;rBr7rYrrMrTs   r�test_interact_invalid_sqlz,InteractiveSession.test_interact_invalid_sql�s����<�<��<�3���S��
�
�d�(�(�#�.��
�
�7��=�������T�X�X�.�/�������4�8�8�,�a�0�������4�8�8�,�a�0r!c�D�|jtt�|jtd��\}}|j	t|�|j|j
|j��|jtd��\}}|j	d|�y)N)zCREATE TABLE t(t);rB)zSELECT count(t) FROM t;z(0,)
)r:rrrJr'rOrPrQ)rrr�_s    r�test_interact_on_disk_filez-InteractiveSession.test_interact_on_disk_file�ss�������'��<�<��1H�<�I���S��
�
�f�c�"�������T�X�X�.�/����f�/K��L���Q��
�
�h��$r!N)r<r=r>rNrQrSrJrUrWrZr]r_rarcrfr?r!rrArA@sA��A�M�
�C�
�C�&(��$1�1�3�1�1�1�1�%r!rA�__main__)�__doc__r+�unittest�sqlite3.__main__rr�test.support.os_helperrr�test.supportrrr�TestCaser
rAr<r?r!r�<module>rns\�����(�1�I�I�3#�8�,�,�3#�lW%��*�*�W%�t�z���H�M�M�O�r!

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