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

�KeP����dZddlZddlZddlZddlmZddlmZ	ddlmZn
#e$rdZYnwxYwej	Z
ej�e
ej	��Z
d�Zd�Zd�ZGd	�d
��ZGd�dej��Ze��D]SZej�d
��sJ�ejdd�Zde��Zeeeejfdei��e��e<�Tedkrej��dSdS)z=Test script for the dbm.open function based on testdumbdbm.py�N)�
import_helper)�	os_helper)�ndbmc#�K�tjD]9}	t|dg���}n#t$rY�"wxYw|tj|<|V��:dS)N�open)�fromlist)�dbm�_names�
__import__�ImportError�_modules)�name�mods  �7/usr/local/apps/python3/lib/python3.11/test/test_dbm.py�dbm_iteratorrss�����
����	��T�V�H�5�5�5�C�C���	�	�	��H�	���� ���T���	�	�	�	�
�s�%�
2�2c�8�tjt��dS�N)r�rmtree�dirname��r�cleaunup_test_dirr s��
��W�����rc�T�t��tjt��dSr)r�os�mkdirrrrr�setup_test_dirr#s$�������H�W�����rc��eZdZddddddd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�AnyDBMTestCase�Python:sProgrammingstheswaysGuidosintended)�a�b�c�d�f�gc��tjtd��}|jD]%}|j|||�d��<�&|���dS)N�n�ascii)r	r�_fname�_dict�encode�close)�selfr$�ks   r�init_dbzAnyDBMTestCase.init_db1sT���H�V�S�!�!����	1�	1�A�#'�:�a�=�A�a�h�h�w��� � �	���	�	�	�	�	rc���td�|���D����}t|j�����}|�||��|S)Nc3�@K�|]}|�d��V��dS)r(N)�decode)�.0r.s  r�	<genexpr>z-AnyDBMTestCase.keys_helper.<locals>.<genexpr>8s.����:�:�A�a�h�h�w�'�'�:�:�:�:�:�:r)�sorted�keysr*�assertEqual)r-r$r6�dkeyss    r�keys_helperzAnyDBMTestCase.keys_helper7sZ���:�:������:�:�:�:�:���t�z���(�(�)�)������u�%�%�%��rc�j�|�t|jjt����dSr)�
assertTrue�
issubclass�module�error�OSError�r-s r�
test_errorzAnyDBMTestCase.test_error=s)�����
�4�;�#4�g�>�>�?�?�?�?�?rc�f�|�tjtjt��dSr)�assertRaisesr	r>rr)r@s r�test_anydbm_not_existingz'AnyDBMTestCase.test_anydbm_not_existing@s$�����#�)�S�X�v�6�6�6�6�6rc�P�tjtd��}|�t	|�����g��|jD]%}|j|||�d��<�&|�|��|�	��dS)Nr"r()
r	rr)r7�listr6r*r+�read_helperr,�r-r$�keys   r�test_anydbm_creationz#AnyDBMTestCase.test_anydbm_creationCs����H�V�S�!�!������a�f�f�h�h����,�,�,��:�	5�	5�C�%)�Z��_�A�c�j�j��!�!�"�"��������	���	�	�	�	�	rc���tjt��tjtd��5}|�t
|��d��ddd��dS#1swxYwYdS)Nr'r)r�create_empty_filer)r	rr7�len�r-r$s  r�8test_anydbm_creation_n_file_exists_with_invalid_contentszGAnyDBMTestCase.test_anydbm_creation_n_file_exists_with_invalid_contentsKs����#�F�+�+�+�
�X�f�c�
"�
"�	(�a����S��V�V�Q�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�$A%�%A)�,A)c�^�|���tjtd��}dx|jd<|d<|�|��|�|�dd��d��|�|dd��|���dS)Nr"sindentedr%�g�xxx�foo)	r/r	rr)r*rGr7�
setdefaultr,rNs  r�test_anydbm_modificationz'AnyDBMTestCase.test_anydbm_modificationQs����������H�V�S�!�!��$/�/��
�3��!�D�'��������������f�f�5�5�v�>�>�>�����6��F�+�+�+�	���	�	�	�	�	rc�4�|���tjtd��}|�|��|�|�d��|jd��|�|�dd��d��|�|�d����|�	t��5|dddd��n#1swxYwY|���dS)N�r�ar rRrS)r/r	rr)rGr7�getr*�assertIsNonerC�KeyErrorr,rNs  r�test_anydbm_readzAnyDBMTestCase.test_anydbm_read[s���������H�V�S�!�!���������������t���d�j��o�6�6�6�������v�v�.�.��7�7�7����!�%�%��-�-�(�(�(�
�
�
�x�
(�
(�	�	�
�f�I�I�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	���	�	�	�	�	s�$	C9�9C=�C=c��|���tjtd��}|�|��}|���dS)NrW)r/r	rr)r9r,)r-r$r6s   r�test_anydbm_keyszAnyDBMTestCase.test_anydbm_keysgsD���������H�V�S�!�!������"�"��	���	�	�	�	�	rc�~�ttjdd��dkr|�d��tjt
d��}|�|���g��d|d<|�|���dg��|�d|��|�|dd��|�|�	d��d��|�|�
d��d��|���dS)N�libraryzBerkeley DBzCBerkeley DB doesn't distinguish the empty value from the absent oner"rsempty)�getattrr	�_defaultmod�skipTestrr)r7r6�assertInrYrTr,rNs  r�test_empty_valuezAnyDBMTestCase.test_empty_valuems���3�?�I�t�4�4�
�E�E��M�M�0�
1�
1�
1��H�V�S�!�!����������2�&�&�&���(����������H�:�.�.�.��
�
�h��"�"�"�����8��c�*�*�*�������x���#�.�.�.�������h�/�/��5�5�5�	���	�	�	�	�	rc��|���tjtd��}d�d��}|�||��||dksJ�|���dS)NrWr r(r)r/r	rr)r+rdr,rHs   r�test_anydbm_accessz!AnyDBMTestCase.test_anydbm_access{sk���������H�V�S�!�!���j�j��!�!���
�
�c�1������v��#�#�#�#�	���	�	�	�	�	rc��tjtjt��d�����dS�Nr")r	rr�fsencoder)r,r@s r�test_open_with_bytesz#AnyDBMTestCase.test_open_with_bytes�s0������V�$�$�c�*�*�0�0�2�2�2�2�2rc��tjtjt��d�����dSri)r	rr�FakePathr)r,r@s r�test_open_with_pathlib_pathz*AnyDBMTestCase.test_open_with_pathlib_path�s1�����#�F�+�+�S�1�1�7�7�9�9�9�9�9rc��tjtjt	jt����d�����dSri)r	rrrmrrjr)r,r@s r�!test_open_with_pathlib_path_bytesz0AnyDBMTestCase.test_open_with_pathlib_path_bytes�s;�����#�B�K��$7�$7�8�8�#�>�>�D�D�F�F�F�F�Frc��|�|��}|jD]<}|�|j|||�d�����=dS)Nr()r9r*r7r+)r-r$r6rIs    rrGzAnyDBMTestCase.read_helper�sd������"�"���:�	F�	F�C����T�Z��_�a��
�
�7�0C�0C�.D�E�E�E�E�	F�	Frc�T��tjtd��5�|�����g��ddg}|D]
\}}|�|<�|�t������td�|D������|D]7\}}|�|���|��||���8|�d���|�t�fd���ddd��dS#1swxYwYdS)Nr")rX�b)s12345678910s019237410982340912840198242c3� K�|]	\}}|V��
dSrr)r3r.�vs   rr4z+AnyDBMTestCase.test_keys.<locals>.<genexpr>�s&����5H�5H�F�Q��a�5H�5H�5H�5H�5H�5HrrRc����dS)NrRr)r#s�r�<lambda>z*AnyDBMTestCase.test_keys.<locals>.<lambda>�s����&�	�r)
r	rr)r7r6r5rd�assertNotInrCr[)r-r r.rur#s    @r�	test_keyszAnyDBMTestCase.test_keys�st���
�X�f�c�
"�
"�
	;�a����Q�V�V�X�X�r�*�*�*��O�P�A��
�
���1���!������V�A�F�F�H�H�-�-�v�5H�5H�a�5H�5H�5H�/H�/H�I�I�I��
*�
*���1��
�
�a��#�#�#�� � ��1��q�)�)�)�)����V�Q�'�'�'����h�(9�(9�(9�(9�:�:�:�
	;�
	;�
	;�
	;�
	;�
	;�
	;�
	;�
	;�
	;�
	;�
	;����
	;�
	;�
	;�
	;�
	;�
	;s�C4D�D!�$D!c���|�ttdtj��|jt_|�t
��t
��dS)Nrb)�
addCleanup�setattrr	rbr=rrr@s r�setUpzAnyDBMTestCase.setUp�sJ�������m�S�_�E�E�E��+������)�*�*�*������rN)�__name__�
__module__�__qualname__r*r/r9rArDrJrOrUr\r^rergrkrnrprGryr}rrrrr(s:������� �����
�
�E�������@�@�@�7�7�7����(�(�(����
�
�
����������3�3�3�:�:�:�G�G�G�F�F�F�
;�;�;�����rrc�P�eZdZd�Zejed���d���Zd�ZdS)�WhichDBTestCasec�f�|�ttdtj��t	jt��}ttjt��|tj|��g}t��D�]'}|j
}t��|t_|�td��5ddd��n#1swxYwY|D]0}|�
||j�|�����1|�td��5}d|d<|�d|��|�
|dd��ddd��n#1swxYwY|D]0}|�
||j�|�����1��)dS)Nrbr"�w�1)r{r|r	rbrrjr)rrmrr~rrr7�whichdbrd)r-�_bytes_fname�fnamesr=r�pathr$s       r�test_whichdbzWhichDBTestCase.test_whichdb�s��������m�S�_�E�E�E��{�6�*�*���)�,�V�4�4��	� 2�<� @� @�B��"�n�n�	?�	?�F��?�D�����$�C�O����V�S�)�)�/�/�/�/�/�/�/�/�/�/�/�/�/����/�/�/�/��
?�
?��� � ��t�x�'7�'7��'=�'=�>�>�>�>����V�S�)�)�
0�Q���$���
�
�d�A�&�&�&�� � ��4��$�/�/�/�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0��
?�
?��� � ��t�x�'7�'7��'=�'=�>�>�>�>�
?�#	?�	?s$�C�C	�C	�-8E1�1E5	�8E5	zTest requires ndbm)�reasonc�d�ttdzd��5ddd��n#1swxYwYtjt��}tt	jt��|t	j|��g}|D]/}|�|j�|�����0dS)Nz.db�wb)	rr)rrjrrmrZr	r�)r-r�r�r�s    r�test_whichdb_ndbmz!WhichDBTestCase.test_whichdb_ndbm�s����&�5�.�$�
'�
'�-�-�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-��{�6�*�*���)�,�V�4�4��	� 2�<� @� @�B���	6�	6�D����d�h�.�.�t�4�4�5�5�5�5�	6�	6s�&�*�*c��|�t��t��tjd��|_dS)Nr	)r{rrr�import_fresh_moduler	r@s rr}zWhichDBTestCase.setUp�s7�����)�*�*�*����� �4�U�;�;����rN)	r~rr�r��unittest�
skipUnlessrr�r}rrrr�r��sa������?�?�?�2�X���&:�;�;�;�6�6�<�;�6�<�<�<�<�<rr�zdbm.��	TestCase_r=�__main__)�__doc__r�r	r�test.supportrrrr�TESTFNrr��joinr)rrrr�TestCaser�rr~�
startswith�suffix�testname�type�globals�mainrrr�<module>r�s���C�C�����
�
�
�
�	�	�	�	�&�&�&�&�&�&�"�"�"�"�"�"���������������D�D�D������
��	����g�y�/�	0�	0��
���������
z�z�z�z�z�z�z�z�z'<�'<�'<�'<�'<�h�'�'<�'<�'<�T�<�>�>�0�0�C��<�"�"�6�*�*�*�*�*�
�\�!�"�"�
�F�#�6�#�#�H��$�x� .��0A�B� (�#��0�0�G�G�I�I�h���
�z����H�M�O�O�O�O�O��s�#�-�-