Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_dbm_gnu.cpython-311.pyc
�

�KeJ����ddlmZddlmZmZejd��ZddlZddlZddl	m
Z
mZmZm
Z
e
ZGd�dej��Zedkrej��dSdS)	�)�support)�
import_helper�cpython_onlyzdbm.gnuN)�TESTFN�TESTFN_NONASCII�unlink�FakePathc���eZdZed���Zd�Zd�Zed���Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zejed
��d���Zd�Zd�Zd�Zd�ZdS)�TestGdbmc�v�tjr,	ddlm}t	d|����dS#t
$rYdSwxYwdS)Nr)�
_GDBM_VERSIONzgdbm version: )r�verbose�_gdbmr
�print�ImportError)�versions �;/usr/local/apps/python3/lib/python3.11/test/test_dbm_gnu.py�
setUpClasszTestGdbm.setUpClasssp���?�	2�
2�:�:�:�:�:�:��0�w�0�0�1�1�1�1�1���
�
�
����
����	2�	2s�(�
6�6c��d|_dS�N��g��selfs r�setUpzTestGdbm.setUps
�������c�n�|j�|j���tt��dSr)r�closer�filenamers r�tearDownzTestGdbm.tearDowns-���6���F�L�L�N�N�N��x�����rc��t�td��|_t	j|t
|j����dS�N�c)�gdbm�openrrr�check_disallow_instantiation�typers r�test_disallow_instantiationz$TestGdbm.test_disallow_instantiations:�����8�S�)�)����,�T�4���<�<�@�@�@�@�@rc� �t�td��|_|�|j���g��d|jd<d|jd<d|jd<t
|j�����}|�|t
gd�����|�d|j��|�d	|j��|�|jdd��|j���}|rG|�||��|�	|��|j�
|��}|�G|�|j�d	��d
��|�|j�d����|�|j�dd��d��|�
t��5|jd
ddd��n#1swxYwY|�|j�dd��d��|�|jdd��dS)Nr#�b�a�019237410982340912840198242�12345678910sdata�bytes)�ar.s12345678910r/�bsxxxsfoo�xxx)r$r%rr�assertEqual�keys�set�assertIn�firstkey�remove�nextkey�get�assertIsNone�assertRaises�KeyError�
setdefault)r�key_set�keys   r�test_key_methodszTestGdbm.test_key_methods$sg�����8�S�)�)�������������+�+�+����s�� =���}��"���x���d�f�k�k�m�m�$�$������#�&F�&F�&F�"G�"G�H�H�H��
�
�c�4�6�"�"�"��
�
�d�D�F�#�#�#�������)�7�3�3�3��f�o�o�����	&��M�M�#�w�'�'�'��N�N�3�����&�.�.��%�%�C��	&�
	
�������D�)�)�4�0�0�0����$�&�*�*�V�,�,�-�-�-��������F�F�3�3�V�<�<�<�
�
�
�x�
(�
(�	�	��F�5�M�M�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	������*�*�6�6�:�:�F�C�C�C���������0�0�0�0�0s�H3�3H7�:H7c���tt����tjtjtd��t�td���_�j�����tj�fd�����tjd���dS)N�rr#c����jdS)Nr+rrs�r�<lambda>z0TestGdbm.test_error_conditions.<locals>.<lambda>Ds
���d�f�S�k�rc�f�t�td�����S)N�rx)r$r%rr�rrrDz0TestGdbm.test_error_conditions.<locals>.<lambda>Fs ��d�i�i��$�.G�.G�.M�.M�.O�.O�r)rrr;r$�errorr%rrrs`r�test_error_conditionszTestGdbm.test_error_conditions=s�����x�������$�*�d�i��3�?�?�?����8�S�)�)�������������$�*�&9�&9�&9�&9�:�:�:����$�*�&O�&O�P�P�P�P�Prc��ttj��}|td��z
}t|��D]@}t�t
|��|_|j����A|td��z
}|D]H}|D]C}t�t
||z��|_|j����D�IdS)N�fsu�crwn)r4r$�
open_flags�sortedr%rrr)r�all�modes�mode�flags�flags      r�
test_flagszTestGdbm.test_flagsHs����$�/�"�"���c�%�j�j� ���5�M�M�	�	�D��Y�Y�x��.�.�D�F��F�L�L�N�N�N�N��c�&�k�k�!���	�	�D��
�
�����8�T�D�[�9�9�����������
�	�	rc��t�td��|_tj�t��}t|d��}d|z|jd<tj�t��}|�||��|jd=|�	tj�t��|��|j�
��tj�t��}|�||��|�||��dS)Nr#i'�x)
r$r%rr�os�path�getsize�max�
assertGreaterr2�
reorganize�
assertLess�assertGreaterEqual)r�size0�
value_size�size1�size2s     r�test_reorganizezTestGdbm.test_reorganizeXs������8�S�)�)��������)�)��
���&�&�
��J�&���s�������)�)�����5�%�(�(�(��F�3�K���������2�2�E�:�:�:�������������)�)������u�%�%�%�����u�-�-�-�-�-rc�B�t�td��5}d|d<ddd��n#1swxYwYt�td��5}|�t	|�����dg��ddd��n#1swxYwY|�tj��5}|���ddd��n#1swxYwY|�t|j	��d��dS)Nr#zcontext managerzgdbm context managerrBsgdbm context managerz#GDBM object has already been closed)
r$r%rr2�listr3r;rH�str�	exception)r�db�cms   r�test_context_managerzTestGdbm.test_context_managerms���
�Y�Y�x��
%�
%�	;��):�B�%�&�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;��Y�Y�x��
%�
%�	I�����T�"�'�'�)�)�_�_�/F�.G�H�H�H�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I����	I�	I�	I�	I��
�
�t�z�
*�
*�	�b��G�G�I�I�I�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����R�\�*�*�>�	@�	@�	@�	@�	@s0�3�7�7�7B!�!B%�(B%�C,�,C0�3C0c���t�td��5}d|d<ddd��n#1swxYwYt�td��5}|�t	|�����dg��|�d|v��|�|dd��ddd��dS#1swxYwYdS)Nr#s
bytes value �sbytes key �rB)r$r%rr2rer3�
assertTrue�rrhs  r�
test_byteszTestGdbm.test_bytesysX��
�Y�Y�x��
%�
%�	8��$7�B� �!�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�
�Y�Y�x��
%�
%�	I�����T�"�'�'�)�)�_�_�/@�.A�B�B�B��O�O�-��3�4�4�4����R� 1�2�4G�H�H�H�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I����	I�	I�	I�	I�	I�	Is�3�7�7�A*C�C�Cc���t�td��5}d|d<ddd��n#1swxYwYt�td��5}|�t	|�����d���g��|�d���|v��|�d|v��|�|d���d�����|�|dd�����ddd��dS#1swxYwYdS)Nr#uUnicode value 🐍uUnicode key 🐍rB)r$r%rr2rer3�encoderlrms  r�test_unicodezTestGdbm.test_unicode�s���
�Y�Y�x��
%�
%�	F��+E�B�'�(�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�
�Y�Y�x��
%�
%�	B�����T�"�'�'�)�)�_�_�/G�/N�/N�/P�/P�.Q�R�R�R��O�O�4�;�;�=�=��C�D�D�D��O�O�4��:�;�;�;����R� 8� ?� ?� A� A�B�7�>�>�@�@�
B�
B�
B����R� 8�9�7�>�>�@�@�
B�
B�
B�
	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�	B�	Bs�3�7�7�C7E"�"E&�)E&c�R�t�td��5}d|d<ddd��n#1swxYwYt�td��5}|�tj��5|d=ddd��n#1swxYwY|�tj��5|d=ddd��n#1swxYwY|�tj��5d|d<ddd��n#1swxYwYddd��dS#1swxYwYdS)Nr#sbytes values	bytes keyrBs
not exist keysnot exist value)r$r%rr;rHrms  r�test_write_readonly_filez!TestGdbm.test_write_readonly_file�sD��
�Y�Y�x��
%�
%�	.��-�B�|��	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�
�Y�Y�x��
%�
%�	:���"�"�4�:�.�.�
)�
)��'�(�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)����
)�
)�
)�
)��"�"�4�:�.�.�
%�
%��|�$�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%����
%�
%�
%�
%��"�"�4�:�.�.�
:�
:�'9��#�$�
:�
:�
:�
:�
:�
:�
:�
:�
:�
:�
:����
:�
:�
:�
:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:s��3�7�7� D�>B�D�B	�D�B	�"D�8C�<D�C	�D�C	�"D�2D�8D�D	�D�D	�D�D �#D z*requires OS support of non-ASCII encodingsc�X�t}|�t|��t�|d��5}d|d<ddd��n#1swxYwY|�tj�|����t�|d��5}|�	t|�����dg��|�d|v��|�	|dd��ddd��dS#1swxYwYdS)Nr#svalueskeyrB)r�
addCleanuprr$r%rlrWrX�existsr2rer3)rrrhs   r�test_nonascii_filenamezTestGdbm.test_nonascii_filename�sw��#�������)�)�)�
�Y�Y�x��
%�
%�	"��!�B�v�J�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"��������x�0�0�1�1�1�
�Y�Y�x��
%�
%�	3�����T�"�'�'�)�)�_�_�v�h�7�7�7��O�O�F�b�L�)�)�)����R��Z��2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3s$�A�A�A�(A*D�D#�&D#c�<�d}|�tj��5}t�|��ddd��n#1swxYwY|�|t|j����|�|jj|��dS)Nznonexisting-file)	r;r$rHr%r5rfrgr2r)r�nonexisting_fileris   r�test_nonexisting_filezTestGdbm.test_nonexisting_file�s���-��
�
�
�t�z�
*�
*�	(�b��I�I�&�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(��
�
�&��B�L�(9�(9�:�:�:������.�0@�A�A�A�A�As�A	�	A
�A
c��t�tt��d�����dSr")r$r%r	rrrs r�test_open_with_pathlib_pathz$TestGdbm.test_open_with_pathlib_path�s0���	�	�(�8�$�$�c�*�*�0�0�2�2�2�2�2rc��t�tjt��d�����dSr")r$r%rW�fsencoderrrs r�test_open_with_bytes_pathz"TestGdbm.test_open_with_bytes_path�s2���	�	�"�+�h�'�'��-�-�3�3�5�5�5�5�5rc��t�ttjt
����d�����dSr")r$r%r	rWr~rrrs r�!test_open_with_pathlib_bytes_pathz*TestGdbm.test_open_with_pathlib_bytes_path�s:���	�	�(�2�;�x�0�0�1�1�3�7�7�=�=�?�?�?�?�?rN)�__name__�
__module__�__qualname__�staticmethodrrr rr(r@rIrTrcrjrnrqrs�unittest�
skipUnlessrrwrzr|rr�rGrrrrsg�������2�2��\�2�������
�A�A��\�A�
1�1�1�2	Q�	Q�	Q���� .�.�.�*
@�
@�
@�I�I�I�
B�
B�
B�	:�	:�	:��X���E�G�G�	3�	3�G�G�	3�B�B�B�3�3�3�6�6�6�@�@�@�@�@rr�__main__)�testr�test.supportrr�
import_moduler$r�rW�test.support.os_helperrrrr	r�TestCaserr��mainrGrr�<module>r�s���������4�4�4�4�4�4�4�4�"�}�"�9�-�-������	�	�	�	�L�L�L�L�L�L�L�L�L�L�L�L���h@�h@�h@�h@�h@�x� �h@�h@�h@�V�z����H�M�O�O�O�O�O��r