%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����dZddlZddlZddlZ	ddlZddlmZddl	m
Z
ddlmZGd�dej�ZGd	�d
ej�ZGd�dej�Zy#e$rdZY�UwxYw)
z&
Tests for L{twisted.internet.fdesc}.
�N)�fdescznot supported on this platform)�untilConcludes)�unittestc��eZdZdZd�Zd�Zy)�NonBlockingTestszE
    Tests for L{fdesc.setNonBlocking} and L{fdesc.setBlocking}.
    c���tj�\}}|jtj|�|jtj|�|j	tj
|t
j�tjz�tj|�|jtj
|t
j�tjz�y)zR
        L{fdesc.setNonBlocking} sets a file description to non-blocking.
        N)�os�pipe�
addCleanup�close�assertFalse�fcntl�F_GETFL�
O_NONBLOCKr�setNonBlocking�
assertTrue��self�r�ws   �9/usr/lib/python3/dist-packages/twisted/test/test_fdesc.py�test_setNonBlockingz$NonBlockingTests.test_setNonBlockings����w�w�y���1�������!�$�������!�$�������Q��
�
�6����F�G�
���Q��������A�u�}�}�5��
�
�E�F�c��tj�\}}|jtj|�|jtj|�t	j
|�t	j|�|jtj|tj�tjz�y)zK
        L{fdesc.setBlocking} sets a file description to blocking.
        N)r	r
rrrr�setBlockingr
rrrrs   r�test_setBlockingz!NonBlockingTests.test_setBlocking'sy���w�w�y���1�������!�$�������!�$�
���Q��
���!��������Q��
�
�6����F�GrN)�__name__�
__module__�__qualname__�__doc__rr�rrrrs���	G�	Hrrc�X�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zy)�ReadWriteTestsz<
    Tests for L{fdesc.readFromFD}, L{fdesc.writeToFD}.
    c���tj�\|_|_t	j
|j�t	j
|j�y)zG
        Create a non-blocking pipe that can be used in tests.
        N)r	r
rrrr�rs r�setUpzReadWriteTests.setUp8s;�����������
���T�V�V�$�
���T�V�V�$rc��	tj|j�	tj|j�y#t$rY�,wxYw#t$rYywxYw)z
        Close pipes.
        N)r	rr�OSErrorrr%s r�tearDownzReadWriteTests.tearDown@sS��	��H�H�T�V�V��	��H�H�T�V�V����	��	���	��	�s"�A�A�	A�
A�	A�Ac�B�tj|j|�S)z)
        Write data to the pipe.
        )r�	writeToFDr)r�ds  r�writezReadWriteTests.writeMs�����t�v�v�q�)�)rc�r�g}tj|j|j�}|�|r|dSy|S)z*
        Read data from the pipe.
        rr)r�
readFromFDr�append)r�l�ress   r�readzReadWriteTests.readSs<��
�����t�v�v�q�x�x�0���;����t����Jrc���|jd�}|j|dkD�|j�}|jt	|�|�|jdd||�y)z�
        Test that the number of bytes L{fdesc.writeToFD} reports as written
        with its return value are seen by L{fdesc.readFromFD}.
        shellorN)r-rr3�assertEqual�len)r�n�ss   r�test_writeAndReadz ReadWriteTests.test_writeAndReadasW��

�J�J�x� ������A����I�I�K������Q���#�����"�1��q�)rc�|�ddz}|j|�}|j|dkD�g}d}d}||ks|dkrA|j|j��|t	|d�z
}|dz
}||kr�;|dkr�Adj|�}|j
t	|�|�|j
|d||�y)	z}
        Similar to L{test_writeAndRead}, but use a much larger string to verify
        the behavior for that case.
        s
0123456879i'r�2����rN)r-rr0r3r6�joinr5)r�orig�written�result�resultlength�is      r�test_writeAndReadLargez%ReadWriteTests.test_writeAndReadLargels���
�u�$���*�*�T�"������!��$�����
���W�$��B���M�M�$�)�)�+�&��C��r�
�O�+�L�
��F�A�	�W�$��B��
���&�!������V��g�.�����h�w���0rc��g}tj|j|j�}|j	|g�|j|�y)z�
        Verify that reading from a file descriptor with no data does not raise
        an exception and does not result in the callback function being called.
        N)rr/rr0r5�assertIsNone)rr1rAs   r�test_readFromEmptyz!ReadWriteTests.test_readFromEmpty�sA��

���!�!�$�&�&�!�(�(�3������B�����&�!rc��tj|j�|j|j	�t
j�y)z�
        Test that using L{fdesc.readFromFD} on a cleanly closed file descriptor
        returns a connection done indicator.
        N)r	rrr5r3r�CONNECTION_DONEr%s r�test_readFromCleanClosez&ReadWriteTests.test_readFromCleanClose��0��
	��������������e�&;�&;�<rc��tj|j�|j|j	d�t
j�y)z�
        Verify that writing with L{fdesc.writeToFD} when the read end is closed
        results in a connection lost indicator.
        �sN)r	rrr5r-r�CONNECTION_LOSTr%s r�test_writeToClosedz!ReadWriteTests.test_writeToClosed��3��
	�������������D�)�5�+@�+@�Arc��tj|j�|j|j	�t
j�y)z�
        Verify that reading with L{fdesc.readFromFD} when the read end is
        closed results in a connection lost indicator.
        N)r	rrr5r3rrNr%s r�test_readFromInvalidz#ReadWriteTests.test_readFromInvalid�rKrc��tj|j�|j|j	d�t
j�y)z�
        Verify that writing with L{fdesc.writeToFD} when the write end is
        closed results in a connection lost indicator.
        rMN)r	rrr5r-rrNr%s r�test_writeToInvalidz"ReadWriteTests.test_writeToInvalid�rPrc�P�tj}d�}|t_	|j|jd�d�|t_d�}|t_	|j|jd�d�|t_y#|t_wxYw#|t_wxYw)z8
        Test error path for L{fdesc.writeTod}.
        c�D�t�}tj|_|��N)r(�errno�EAGAIN��fd�data�errs   r�eagainWritez4ReadWriteTests.test_writeErrors.<locals>.eagainWrite�s���)�C����C�I��IrrMrc�D�t�}tj|_|�rW)r(rX�EINTRrZs   r�
eintrWritez3ReadWriteTests.test_writeErrors.<locals>.eintrWrite�s���)�C����C�I��IrN)r	r-r5)r�
oldOsWriter^ras    r�test_writeErrorszReadWriteTests.test_writeErrors�s����X�X�
�	�
���	"����T�Z�Z��-�q�1�!�B�H�	�
���	"����T�Z�Z��-�q�1�!�B�H��"�B�H��"�B�H�s�!B�!B�
B�
B%N)rrrr r&r)r-r3r9rDrGrJrOrRrTrcr!rrr#r#3sE���%��*��	*�1�("�=�B�=�B�"rr#c�&�eZdZdZdZd�Zd�Zd�Zy)�CloseOnExecTestszL
    Tests for L{fdesc._setCloseOnExec} and L{fdesc._unsetCloseOnExec}.
    z�
import os, errno
try:
    os.write(%d, b'lul')
except OSError as e:
    if e.errno == errno.EBADF:
        os._exit(0)
    os._exit(5)
except BaseException:
    os._exit(10)
else:
    os._exit(20)
c��tj�}|dk(rS	tjtjtjd|j
|j
�fzg�yttj|d�dS#t$r,ddl}|j�tjd�YywxYw)Nrz-c�r=)
r	�fork�execv�sys�
executable�program�fileno�
BaseException�	traceback�	print_exc�_exitr�waitpid)r�fObj�pidros    r�_execWithFileDescriptorz(CloseOnExecTests._execWithFileDescriptor�s����g�g�i���!�8�	
�����N�N��^�^�T�4�<�<�4�;�;�=�:J�+J�K��"�"�*�*�c�1�5�a�8�8��!�
� ��#�#�%������	
�s�AB�2C�?Cc�\�t|j�d�5}tj|j	��|j|�}|j
tj|��|jtj|�d�ddd�y#1swYyxYw)z�
        A file descriptor passed to L{fdesc._setCloseOnExec} is not inherited
        by a new process image created with one of the exec family of
        functions.
        �wbrN)�open�mktempr�_setCloseOnExecrmrurr	�	WIFEXITEDr5�WEXITSTATUS�rrs�statuss   r�test_setCloseOnExecz$CloseOnExecTests.test_setCloseOnExec�s}���$�+�+�-��
&�	8�$��!�!�$�+�+�-�0��1�1�$�7�F��O�O�B�L�L��0�1����R�^�^�F�3�Q�7�		8�	8�	8�s�A>B"�"B+c��t|j�d�5}tj|j	��tj
|j	��|j
|�}|jtj|��|jtj|�d�ddd�y#1swYyxYw)z�
        A file descriptor passed to L{fdesc._unsetCloseOnExec} is inherited by
        a new process image created with one of the exec family of functions.
        rw�N)rxryrrzrm�_unsetCloseOnExecrurr	r{r5r|r}s   r�test_unsetCloseOnExecz&CloseOnExecTests.test_unsetCloseOnExec�s���
�$�+�+�-��
&�	9�$��!�!�$�+�+�-�0��#�#�D�K�K�M�2��1�1�$�7�F��O�O�B�L�L��0�1����R�^�^�F�3�R�8�	9�	9�	9�s�B!C�CN)rrrr rlrurr�r!rrrere�s����G�9�$
8�
9rre)r rXr	rjr�twisted.internetr�ImportError�skip�twisted.python.utilr�
twisted.trialr�SynchronousTestCaserr#rer!rr�<module>r�sz���
�	�
�'��'�.�"�H�x�3�3�H�8Q"�X�1�1�Q"�h;9�x�3�3�;9��s�,�+�D�,�s�A&�&A0�/A0

Zerion Mini Shell 1.0