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

�KeP���dZddlZddlZddlZddlmZddlmZ	ddlmZn
#e$rdZYnwxYwej	Z
ej�e
ej	��Z
d�Zd�Zd�ZGd	�d
��ZGd�dej��Ze��D]7Zejd
d�Zde��Zeeeejfdei��e��e<�8edkrej��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)�AnyDBMTestCasesPython: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#r5�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(r6�listr5r)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	rr6�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)rFr6�
setdefaultr+rMs  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�arrQrR)r.r	rr(rFr6�getr)�assertIsNonerB�KeyErrorr+rMs  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)NrV)r.r	rr(r8r+)r,r#r5s   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(r6r5�assertInrXrSr+rMs  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��}|�||��|���dS)NrVrr')r.r	rr(r*rcr+rGs   r�test_anydbm_accessz!AnyDBMTestCase.test_anydbm_access{sV���������H�V�S�!�!���j�j��!�!���
�
�c�1����	���	�	�	�	�	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�����dSrh)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�����dSrh)r	rrrlrrir(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')r8r)r6r*)r,r#r5rHs    rrFzAnyDBMTestCase.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!)rW�b)s12345678910s019237410982340912840198242c3� K�|]	\}}|V��
dSrr)r2r-�vs   rr3z+AnyDBMTestCase.test_keys.<locals>.<genexpr>�s&����5H�5H�F�Q��a�5H�5H�5H�5H�5H�5HrrQc����dS)NrQr)r"s�r�<lambda>z*AnyDBMTestCase.test_keys.<locals>.<lambda>�s����&�	�r)
r	rr(r6r5r4rc�assertNotInrBrZ)r,rr-rtr"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)Nra)�
addCleanup�setattrr	rar<rrr?s r�setUpzAnyDBMTestCase.setUp�sJ�������m�S�_�E�E�E��+������)�*�*�*������rN)�__name__�
__module__�__qualname__r)r.r8r@rCrIrNrTr[r]rdrfrjrmrorFrxr|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)Nrar!�w�1)rzr{r	rarrir(rrlrr}rrr6�whichdbrc)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(rrirrlrYr	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	)rzrrr�import_fresh_moduler	r?s rr|zWhichDBTestCase.setUp�s7�����)�*�*�*����� �4�U�;�;����rN)	r}r~rr��unittest�
skipUnlessrr�r|rrrr�r��sa������?�?�?�2�X���&:�;�;�;�6�6�<�;�6�<�<�<�<�<rr���	TestCase_r<�__main__)�__doc__r�r	r�test.supportrrrr�TESTFNrr��joinr(rrrr�TestCaser�rr}�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�
�\�!�"�"�
�F�#�6�#�#�H��$�x� .��0A�B� (�#��0�0�G�G�I�I�h���
�z����H�M�O�O�O�O�O��s�#�-�-