Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_dbm_dumb.cpython-312.opt-1.pyc

�

'ΜgN,����dZddlZddlZddlZddlZddlZddlZddlmZ	ddl
mZddlm
Z
ddlmZe
j Zd�ZGd�dej&�Zed	k(rej,�yy)
zATest script for the dumbdbm module
   Original by Roger E. Masse
�N)�support)�	os_helper)�partialc�j�dD]}	tjt|z��!y#t$rY�.wxYw)N��.dir�.dat�.bak)�os�unlink�_fname�OSError)�exts �//usr/local/lib/python3.12/test/test_dbm_dumb.py�
_delete_filesrs5��'��	��I�I�f�s�l�#�(���	��	�s�&�	2�2c��eZdZddddddddd	d
ddd
ddjd�diZd�Zejee	d�d�e
jd���Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zd"�Zd#�Zd$�Zd%�Zd&�Zd'�Zd(�Zd)�Z e
jd*��Z!eje
jDd+�d,��Z#d-�Z$d.�Z%d/�Z&d0�Z'd1�Z(y2)3�DumbDBMTestCase�0��asPython:�bsProgramming�csthe�dsway�fsGuido�gsintended�ü�utf-8�!c�B�tjtjtd��5}|jt
|j��g�|jD]}|j|||<�|j|�ddd�y#1swYyxYw�N�c)
�
contextlib�closing�dumbdbm�openr
�assertEqual�list�keys�_dict�read_helper)�self�f�keys   r�test_dumbdbm_creationz%DumbDBMTestCase.test_dumbdbm_creation%sp��
�
�
����V�S� 9�
:�a����T�!�&�&�(�^�R�0��z�z�����C���#��"����Q��	;�
:�
:�s�AB�B�umaskztest needs os.umask()c�:�	tjd�}tjtdd�}|j�tj|�d}tjdk7rd}ddl}tjtdz�}|j|j|j�|�tjtd	z�}|j|j|j�|�y#tj�wxYw)
N�r!i�i��posixi�rr	r)rr/r$r%r
�close�name�statr&�S_IMODE�st_mode)r+�	old_umaskr,�
expected_moder5�sts      r�test_dumbdbm_creation_modez*DumbDBMTestCase.test_dumbdbm_creation_mode,s���	 ������I����V�S�%�0�A�
�G�G�I��H�H�Y���
�
�7�7�g��"�M��
�W�W�V�f�_�
%���������b�j�j�1�=�A�
�W�W�V�f�_�
%���������b�j�j�1�=�A��
�H�H�Y��s�AD�Dc��tjt�}d|d<|j|dd�|j	�|j	�y)Nrr)r$r%r
r&r3�r+r,s  r�test_close_twicez DumbDBMTestCase.test_close_twiceBs?���L�L�� ����$������4��$�'�	���	�	���	rc�`�|j�tjtjt
d��5}dx|jd<|d<|j|�|j|jdd�d�|j|dd�ddd�y#1swYyxYw)N�wsindentedr�xxx�foo)
�init_dbr"r#r$r%r
r)r*r&�
setdefaultr=s  r�test_dumbdbm_modificationz)DumbDBMTestCase.test_dumbdbm_modificationIs�������
�
�
����V�S� 9�
:�a�)4�4�D�J�J�t��q��w����Q�����Q�\�\�&�&�9�6�B����Q�v�Y��/�;�
:�
:�s�AB$�$B-c���|j�tjtjt
d��5}|j
|�|jtjd�5d|d<ddd�|jtjd�5|d=ddd�|j|jd�|jd�|j|jdd�d�|j|jd��|jt�5|dddd�ddd�y#1swY��xYw#1swY��xYw#1swY�*xYw#1swYyxYw)N�rz'The database is opened for reading only�xrrrArB)rCr"r#r$r%r
r*�assertRaisesRegex�errorr&�getr)�assertIsNone�assertRaises�KeyErrorr=s  r�test_dumbdbm_readz!DumbDBMTestCase.test_dumbdbm_readRs$������
�
�
����V�S� 9�
:�a����Q���'�'��
�
�$M�O���$��O��'�'��
�
�$M�O��d�G�O�
���Q�U�U�4�[�$�*�*�T�*:�;����Q�U�U�6�6�2�F�;����a�e�e�F�m�,��"�"�8�,��&�	�-�;�
:�O�O��O�O��-�,��;�
:�sT�2E*�0E�6(E*�E�"B
E*�/E�5E*�E	�E*�E	�E*�E'	�#E*�*E3c���|j�tjtjt
��5}|j
|�}ddd�y#1swYyxYw�N)rCr"r#r$r%r
�keys_helper)r+r,r(s   r�test_dumbdbm_keysz!DumbDBMTestCase.test_dumbdbm_keyscs@������
�
�
����V� 4�
5���#�#�A�&�D�6�
5�
5�s�A�A!c��tjtjt��5}d|d<|jd|�ddd�y#1swYyxYw)N�hello�1)r"r#r$r%r
�assertInr=s  r�test_write_containsz#DumbDBMTestCase.test_write_containshs>��
�
�
����V� 4�
5���A�d�G��M�M�$��"�6�
5�
5�s�A�Ac�F�tjtjt��5}d|d<d|d<ddd�tjtjt��5}|j|dd�ddd�y#1swY�TxYw#1swYyxYw)NrUrV�hello2)r"r#r$r%r
r&r=s  r�test_write_write_readz%DumbDBMTestCase.test_write_write_readms{��
�
�
����V� 4�
5���A�d�G��A�d�G�6��
�
����V� 4�
5�����Q�t�W�i�0�6�
5�6�
5��6�
5�s�B�,B�B�B c�
�|j�tjtjt
d��5}|j
|d|jdjd��ddd�y#1swYyxYw)NrGrr)	rCr"r#r$r%r
r&r)�encoder=s  r�
test_str_readzDumbDBMTestCase.test_str_readusX������
�
�
����V�S� 9�
:�a����Q�x�[�$�*�*�X�_�_�W�5M�*N�O�;�
:�
:�s�2A9�9Bc��|j�tjtjt
��5}d|d<d|d<ddd�tjtjt
d��5}|j
d|�|j|djd�|jdjd��|j|dd�ddd�y#1swY��xYw#1swYyxYw)	Nrr�a�1rGrrVr)
rCr"r#r$r%r
rWr&r]r)r=s  r�test_str_write_containsz'DumbDBMTestCase.test_str_write_containszs�������
�
�
����V� 4�
5���A�h�K��A�c�F�6��
�
����V�S� 9�
:�a��M�M�(�A�&����Q�x���w�7�8�!�Z�Z�����(@�A�
C����Q�t�W�d�+�	;�
:�6�
5��;�
:�s�C.�=A(C:�.C7�:Dc��tjtjt��5}d|d<d|d<ddd�tjtdzd�5}|j
�}ddd�tjdk(rjdd	�}njd	d�}tjtdzd
�5}|j|�ddd�tjt�}|j|dd�|j|dd�y#1swY��xYw#1swY��xYw#1swY�exYw)NrUrVrZ�2r�rb�
�
s
�wb)r"r#r$r%r
�io�readr�linesep�replace�writer&)r+r,�file�datas    r�test_line_endingsz!DumbDBMTestCase.test_line_endings�s����
�
����V� 4�
5���A�d�G��A�d�G�6�
�W�W�V�f�_�d�
+�t��9�9�;�D�,�
�:�:����<�<��w�/�D��<�<���/�D�
�W�W�V�f�_�d�
+�t��J�J�t��,�
�L�L�� ������4��(�+�����4��)�,�!6�
5��
,�
+��,�
+�s#�D)�D5�E�)D2�5D>�E
c��|j|�}|jD]$}|j|j|||��&yrQ)rRr)r&)r+r,r(r-s    rr*zDumbDBMTestCase.read_helper�s<������"���:�:�C����T�Z�Z��_�a��f�5�rc���tjtjtd��5}|j
D]}|j
|||<�	ddd�y#1swYyxYw�N�n)r"r#r$r%r
r)�r+r,�ks   rrCzDumbDBMTestCase.init_db�sH��
�
�
����V�S� 9�
:�a��Z�Z���z�z�!�}��!�� �;�
:�
:�s�$A�A%c��t|j��}t|jj��}|j||�|SrQ)�sortedr(r)r&)r+r,r(�dkeyss    rrRzDumbDBMTestCase.keys_helper�s<���a�f�f�h����t�z�z���(�)������u�%��rc���ddl}i}td�D�];}tjt	j
t��5}td�D]t}|jd�}|j�dkr||vs�,||=||=�3|jd�|jd�z}|||<|||<|j|||��v	ddd�tjt	j
t��5}td�|j�D��}t|j��}|j||�ddd���>y#1swY��xYw#1swY��VxYw)	Nr��d�
abcdefghijklmg�������?)rrri'c3�HK�|]\}}|jd�|f���y�w)zlatin-1N)r])�.0rv�vs   r�	<genexpr>z.DumbDBMTestCase.test_random.<locals>.<genexpr>�s#����!Q�y�t�q�!�1�8�8�I�#6��":�y�s� ")�random�ranger"r#r$r%r
�choice�	randranger&rx�items)	r+r��d�dummyr,rvr��expected�gots	         r�test_randomzDumbDBMTestCase.test_random�s$������1�X�E��#�#�G�L�L��$8�9�Q�"�3�Z�E��
�
�o�6�A��}�}���,���6� !�!�� !�!��"�M�M�*<�=��@P�@P�QV�@W�W�� ��!�� ��!���(�(��1��q�1�(�:��#�#�G�L�L��$8�9�Q�!�!Q�q�w�w�y�!Q�Q���Q�W�W�Y�'��� � ��3�/�:�9��9�9��:�9�s �7E�:AE�:AE�E	�E(	c��tjtd�5}d|d<ddd�tjtd�5}|jt	|j��dg�ddd�|j
tj�5j�ddd�y#1swY��xYw#1swY�NxYw#1swYyxYw)Nr!zcontext managerzdumbdbm context managerrGsdumbdbm context manager)r$r%r
r&r'r(rMrJ)r+�dbs  r�test_context_managerz$DumbDBMTestCase.test_context_manager�s���
�\�\�&�#�
&�"�,=�B�(�)�'��\�\�&�#�
&�"����T�"�'�'�)�_�/I�.J�K�'��
�
�w�}�}�
-��G�G�I�.�
-�
'�
&��'�
&��.�
-�s#�B/�+B;�C�/B8�;C�Cc�D�tjtd�}|j�t	t
j|�t	t
j|d�t	t
j|�t	t
j|�fD]W}|jtj�5}|d�ddd�|jtj�d��Ytjd�tjd�tjd�t fD]W}|jtj�5}||�ddd�|jtj�d��Yy#1swY��xYw#1swY�=xYw)Nr!�b�testz"DBM object has already been closedr(�iterkeysr�)r$r%r
r3r�operator�delitem�setitem�getitem�containsrMrJr&�str�	exception�methodcaller�len)r+r,�meth�cms    r�test_check_closedz!DumbDBMTestCase.test_check_closed�s4���L�L���%��	���	��X�-�-�q�1��X�-�-�q�#�6��X�-�-�q�1��X�.�.��2�4�D��"�"�7�=�=�1�R��V��2����S����.�A�
C�
4��*�*�6�2��*�*�:�6��*�*�7�3���D��"�"�7�=�=�1�R��Q��2����S����.�A�
C�
�2�1��2�1�s�4	F
�	F�
F	�F	c�H�tjtd�5}|jD]}|j|||<�	ddd�tjtd�5}|j	|j�g�ddd�y#1swY�MxYw#1swYyxYwrs)r$r%r
r)r&r(rus   r�test_create_newzDumbDBMTestCase.test_create_new�sx��
�\�\�&�#�
&�!��Z�Z���z�z�!�}��!�� �'��\�\�&�#�
&�!����Q�V�V�X�r�*�'�
&�	'�
&��'�
&�s�$B�"!B�B�B!c��ttdzdd��5}|jd�ddd�tj�5}|jt�5tjt�5}	ddd�ddd�|j|j�d�ddd�y#1swY��xYw#1swY�FxYw#1swY�JxYw#1swYyxYw)Nrr@r)�encodingzstr(print('Hacked!')), 0
�)
r%r
rmr�captured_stdoutrM�
ValueErrorr$r&�getvalue)r+�stream�stdoutr,s    r�	test_evalzDumbDBMTestCase.test_eval�s���
�&�6�/�3��
9�V��L�L�5�6�:�
�
$�
$�
&�&��"�"�:�.��\�\�&�)�Q��*�/�
���V�_�_�.��3�	'�
&�:�
9��*�)��/�.��'�
&�sG�B/�C�C�4B;�6C�>(C�/B8�;C�C�C	�C�Cc��dD]�}t�|jt�5tjt
|�ddd�|j
tjjt
dz��|j
tjjt
dz����y#1swY�vxYw)N�rGr@rr
)
rrM�FileNotFoundErrorr$r%r
�assertFalser�path�exists)r+�values  r�test_missing_dataz!DumbDBMTestCase.test_missing_data�sx���E��O��"�"�#4�5����V�U�+�6����R�W�W�^�^�F�V�O�<�=����R�W�W�^�^�F�V�O�<�=� �5�5�s�B5�5B>	c��tjtd�5}	ddd�tjtdz�dD]�}|jt�5tjt|�ddd�|jtjjtdz��|jtjjtdz����y#1swY��xYw#1swY��xYw)Nrtrr�r
)
r$r%r
rrrMr�r�r�r�)r+r,r�s   r�test_missing_indexz"DumbDBMTestCase.test_missing_index�s���
�\�\�&�#�
&�!��'�
�	�	�&�6�/�"��E��"�"�#4�5����V�U�+�6����R�W�W�^�^�F�V�O�<�=����R�W�W�^�^�F�V�O�<�=�	 �'�
&��6�5�s�C+�C7�+C4�7D	c��dD];}|jtd�5tjt|�ddd��=y#1swY�HxYw)N)�x�rfNz)Flag must be one of 'r', 'w', 'c', or 'n')rIr�r$r%r
)r+�flags  r�test_invalid_flagz!DumbDBMTestCase.test_invalid_flagsL��%�D��'�'�
�)@�A����V�T�*�A�A�&�A�A�s�A�A	c�|�tj�5}tjj	|d�}tj|d�5}|jt|j��g�|jD]}|j|||<�	ddd�tj|dztj�tj|dztj�tj|tjtjz�tj|d�5}|jt|j��t|j��|j!�ddd�ddd�y#1swY��xYw#1swY�xYw#1swYyxYw)Nr�rtrr	rG)r�temp_dirrr��joinr$r%r&r'r(r)�chmodr5�S_IRUSR�S_IXUSRrxr3)r+�dir�fnamer,r-s     r�test_readonly_filesz#DumbDBMTestCase.test_readonly_files
s��
�
�
�
!�S��G�G�L�L��d�+�E����e�S�)�Q�� � ��a�f�f�h���4��:�:�C�!�Z�Z��_�A�c�F�&�*�
�H�H�U�V�^�T�\�\�2��H�H�U�V�^�T�\�\�2��H�H�S�$�,�,�t�|�|�3�4����e�S�)�Q�� � ������!1�6�$�*�*�3E�F����	�*�"�
!�)�)��*�)��"�
!�s>�7F2�A
F�B!F2�;A
F&�F2�F#	�F2�&F/	�+F2�2F;z*requires OS support of non-ASCII encodingsc��tj}dD]%}|jtj||z��'t	j
|d�5}d|d<ddd�|j
tjj|dz��|j
tjj|dz��t	j
|d�5}|jt|j��dg�|j
d|v�|j|dd�ddd�y#1swY��xYw#1swYyxYw)Nrr!svalueskeyr	rrG)
r�TESTFN_NONASCII�
addCleanuprr$r%�
assertTruerr�r�r&r'r()r+�filename�suffixr�s    r�test_nonascii_filenamez&DumbDBMTestCase.test_nonascii_filenames����,�,��.�F��O�O�I�,�,�h��.?�@�/�
�\�\�(�C�
(�B�!�B�v�J�)���������x�&�'8�9�:���������x�&�'8�9�:�
�\�\�(�C�
(�B����T�"�'�'�)�_�v�h�7��O�O�F�b�L�)����R��Z��2�)�
(�	)�
(��)�
(�s�D3�AD?�3D<�?Ec�z�tjtjt�d�j�yr )r$r%r�FakePathr
r3�r+s r�test_open_with_pathlib_pathz+DumbDBMTestCase.test_open_with_pathlib_path+s$�����Y�'�'��/��5�;�;�=rc�z�tjtjt�d�j�yr )r$r%r�fsencoder
r3r�s r�test_open_with_bytes_pathz)DumbDBMTestCase.test_open_with_bytes_path.s"�����R�[�[��(�#�.�4�4�6rc��tjtjt	j
t��d�j�yr )r$r%rr�rr�r
r3r�s r�!test_open_with_pathlib_bytes_pathz1DumbDBMTestCase.test_open_with_pathlib_bytes_path1s-�����Y�'�'����F�(;�<�c�B�H�H�Jrc��t�yrQ�rr�s r�tearDownzDumbDBMTestCase.tearDown4����rc��t�yrQr�r�s r�setUpzDumbDBMTestCase.setUp7r�rN))�__name__�
__module__�__qualname__r]r)r.�unittest�
skipUnless�hasattrrr�skip_unless_working_chmodr;r>rErOrSrXr[r^rbrpr*rCrRr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��rrrrsC��
�3�
�:�
�>�
�6�
�6�
�8�
�;�
�_�_�W�
%��
�E� ��X�����W�-�/F�G��(�(�B�)�H�B�(�0��"'�
#�
1�P�
	,�-�,6�
%�
�0�,�C�,+�4�>�>�+��(�(��)���X����2�2�E�G�3�G�3�>�7�K��rr�__main__)�__doc__r"rir�rr5r��dbm.dumb�dumbr$r�r�test.supportr�	functoolsr�TESTFNr
r�TestCaserr��mainr�rr�<module>r�si����	��	�����"��	�	�	���^�h�'�'�^�B	�z���H�M�M�O�r

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